Asylum – Dev Diary 22 – Foot steps in the dark

There were a few bugs left over from last weekend that needed to be resolved. The main one was the keypad sprite not being interactive if it was flipped on the other side of the wall. This was purely because the pivot point for the sprite was on the left, so when the sprite was flipped the coordinates went from the right instead and messed everything up. Simply moving the pivot point to the centre resolved the problem.

I also continued the process of revising the map a bit from last weekend. The bottom half was still a bit too large for my liking so that’s been revised to make things tighter.

And so on to new things. The first complex situation on the game involves the segment of the map following on from when the payer collects the torch. I’m trying to be a little obscure here to avoid any spoilers. There is a corridor that triggers a message stating that a torch is required to go further. Now, that means that when the player has the torch they can proceed without the message showing. This involves moving a collision block out of the way. But, it is needed again later, so I have to save the state of the collision block which allows me to move it back when needed, but ensuring that if the game is reloaded that it is in the correct place depending upon the circumstances. Complicated I know. But after a few hours of tinkering it is working as it should.

One aspect I wanted to put in place from the beginning is the players brightness. You can probably tell from previous screenshots that the player is also visible even in the very dark areas. This has bugged me and I wanted the player to be reasonably dark in those areas as well – for realism. Obviously I don’t want the player vanishing completely in the blackness but he should still be difficult to see.

One way around this was to work out how far away the player is from a light source. The problem, as I soon found out, was that he is never away from a light source as I gave him a subtle glow light to ensure the environment isn’t totally black around the player. So, after much head scratching I’ve added a new invisible element called oLightSource to indicate where the lightest parts of the map are. Then I calculate the distance from the player to the nearest light source and clamp the values between 100 and 255. Finally creating a white tint based on this number and applying that the player sprites. And it works really nicely. Although the frame rate dropped a bit and in some places it went to 40fps, but in fully compiled mode on my ageing 10 year old PC it still managed an average of 300fps – so nothing to worry about.

Finally I wanted to bring in some footsteps. I’ve split a sound effect file that contained footsteps of a man walking barefoot on wood into 6 different step sounds. One of these is then played randomly at the appropriate frames for the players movement. It’s really nice to start hearing things in the game as it helps bring things together.

One week of development always introduces at least one new bug and so in continuing that tradition a new one has sneaked in. When the player collects the torch it completes a quest, but for some reason when the quests are reloaded the ‘Find a torch’ quest is back. I’ll probably have a quick look after posting this as I think I know what’s causing it – but we’ll see.