Reflex – Dev Diary 7

This week in the UK the weather has been very hot which restricts the amount of time I can bear being in my study. So, development on both titles has been a lot lower than usual.

For Reflex there was a small bug fix session to correct an issue with the rotateable reflector, and also a funny bug that meant if the launchpad was pointing down the missile would point down, which is correct, but would fly off to the right instead. Opps. And there was a positioning issue when the player returns to the level select after playing a level.

The main new addition this week is something that will save me a lot of time when it comes to creating levels.

Normally, and as is the case with Asylum, each map contains 2 tilemaps, the flooring and the walls. Neither of which are actually used for collision detection. This is because, if you look at the screenshots of the game…

… you’ll see that the walls are angled so that you can see a certain amount of them rather than just the top of the wall. This means that the collision area doesn’t match the full tilemap cell (64×64). So, what I was doing is to have a series of invisible rectangles over the wall tops that act as the collision elements for the missiles. This works really well but it is very time consuming having to place, position and scale dozens of wall sprites.

So, this week I hit on the idea of trying to generate them dynamically. Each time the room/level starts I would need to run through each tile in the wall tilemap, work out the wall piece on the square and create the wall objects accordingly. This gets a little harder with rotated wall pieces because GameMaker, for some odd reason, has decided that tile.rotated returns either true or false, i.e. either at 0 degrees angle or at 90 degree angle. What about the other angles you ask? Well, they can be found using tile.flipped and tile.mirrored. This adds another level of fun because, for example the corner wall piece, if it’s rotated 270 degrees, it’s actually flipped and rotated to get there. I had to write down all the different configrations: rotated, rotated flipped, flipped, mirrored, rotated mirrored, and work out which one applied to each wall state and then create the wall elements for that angle. It took quite a bit of time to sort it all out but I’m happy to say that it is generating all the wall sprites perfectly.

In the screenshot of level 1-5 above you can see the green tint on the top of the walls, this is the generated collision map for the level.

This will let me spend more time creating levels rather than setting up all the collision sprites.