I spent a good chunk of today doing something incredibly boring in order to make something incredibly tedious and slow slightly less tedious and slow. It was completely worth it.
Some elements of game development are dull. With Arcus, one of my least favourite things is building levels. Actually designing levels and challenges on paper is fun, but when it comes to placing objects in the editor, it was dull, and took ages.
One of the worst aspects of building levels was placing the floors and walls. Each individual wall sprite is a 32 x 32 square, and there are dozens of variations of these sprites, depending on whether the wall is a corner, an inside corner, a side bit, a top bit, etc. I think there were about 20 variations in total. 40+ if you count different rotations of each variation.
This meant that actually placing walls in the editor took aaaaaages. It was a case of ‘select the correct wall variation, place it here, then select a different variation, place it here, etc., then test it – oh, not quite right, delete, place, select different variation, place…” and so on. It was a pain.
My solution to this? I now have one wall object, with 42 sprite variations. I can now basically ‘draw’ levels instantly by just placing this one wall object over and over. I wrote a bunch of code that makes the wall object check each of the eight directions (up, down, left, right, and the diagonals) for another wall object, and to choose the relevant sprite index depending on the positioning of others next to it. When I place walls in the editor, it just looks like this:
And in the game, it looks like this:
If I make changes in the editor, the wall sprites adjust accordingly. It’s hugely sped up the level creation process, and made it a hell of a lot more enjoyable.