Friday, April 05, 2024

Firefly Complete, Level Map Rotation, Microkorg Adaptations

Completed the Firefly update, to the v1.03 standard with a little more. As with Bool and other games, I now need to work on boosting the game, so I'll pause to plan.

It certainly looks better than ever. This is one of the few games I made with a plot. Arcangel and Taskforce had one, though convoluted, but Firefly and Gunstorm II had more of a story.

One thing I did was code in level rotation, a way to rotate a square map. This was quite complex. The easiest way is simply read the map from top-left to bottom-right, and paste those values into a second map which scans from bottom-left to top-right, and 'clockwise', but that's wasteful of memory as it demands a full second map as a temporary store. I knew rotation was possible with a simple swap function, so spent the morning working this out.

The map is read from top left, but not to quite the far right on the first pass, then it moves down a row and starts at index one, effectively scanning an inverted triangle shape that ends with its point in the centre of the map, like an envelope flap. The important thing is that this shape is 4-way symmetrical. Then each block can be copied in a cycle from its corresponding place in the quarters. Here's the code:

for (y=0; y<MAPSIZE/2; y++)
  for (x=y; x<MAPSIZE-y-1; x++)
    {
      topleft=block[y*MAPSIZE+x];
      block[y*MAPSIZE+x]=block[(MAPSIZE-1-x)*MAPSIZE+y];
      block[(MAPSIZE-1-x)*MAPSIZE+y]=block[(MAPSIZE-1-y)*MAPSIZE+(MAPSIZE-1-x)];
      block[(MAPSIZE-1-y)*MAPSIZE+(MAPSIZE-1-x)]=block[x*MAPSIZE+(MAPSIZE-1-y)];
      block[x*MAPSIZE+(MAPSIZE-1-y)]=topleft;
    }

The next step is to rotate the map parts themselves so that the top-right wall, for example, becomes the bottom-right. This is a simple matter of a look-up table. This was fun to work out. I struggled for ages on it, then the image of the triangle shape jumped into my head and the rest was easy.

After this, I took the wooden sides off my Microkorg. Korg are one of the few synthesizer manufacturers to use wood, and actually these parts are a really good feature because they allow personal customisation. I used acetone to remove the varnish, then sanded them and painted them black. They now await the guitar buttons. I will need, it seems, M3 self tapping screws for these sides. The ones present are 10 or 12mm, but I need longer ones to fit the guitar button. I could do with bigger diameter screws really; these screws are very thin and it's a heavy keyboard. The wooden sides give me options.