Asylum – Dev Diary 25 – Mega May Day
3 day weekend – Woo Hoo!
I wanted to try and utilise as much time as possible this weekend. Focusing on several different aspects of the game.
First up was to continue the optimisation of the lighting and to get the frame rate as high as possible in debug mode. Before I started this weekend the framerate would average around 95fps, but would drop in the strangest of places to 45fps which is not great. After investigating for some time the first thing I discovered is that the lighting engine doesn’t like light casters to be scaled, unfortunately I had gone through my map and stretched and rotated the lights so they appear exactly as I wanted them. Discovering this little issue meant I had to revisit the sizing and positions of all the lights; and this is something I will refine once the entire floor is done and I can walk the player through the entire environment. I will also need to create some new light shapes. During the course of this exercise I also found a bug. I have a light shape that is designed to emit like a fluorescent tube, but an error in my code meant it was being switched out on creation to be a spot light – oops. Using lights scaled to 100% increased the framerate to 65fps in the awkward place.
On Monday during further experiments with the lights I decided to perform a test with the lights being set to static. Strangely this had a massive impact and the game still cast shadows correctly. The only thing I can think of is that the code was constantly stuck setting lights from static to dynamic and back again every frame. This one discovery increased the framerate average from 95fps to 360fps and the awkward place maintained a framerate above 200 ! So, I’m putting that one done as solved.
Whilst solving the lighting performance I also discovered that the player wasn’t being created at the correct depth. I was using the instance_create_layer() command to create the player object on my Instances layer, but despite this the shower heads (see below) which were on a layer above the Instances layer were still going under the player?! So, I changed the way the player was created by using the instance_create_depth() command instead – this command creates a new dynamic layer at a specific height. This worked beautifully and had an extra benefit – the lights were now illuminating the player correctly without the need of my light source objects and distance checks that I’d set up a few weeks ago, this means that the player will now appear darker in dark areas automatically and correctly. Bonus!
During Saturday I made a list of more sprites I was going to need to decorate the map. This includes cell windows, glass windows, guards table, recreational tables and chairs, book shelves and books, wall mounted TV, bath tub, shower head, gurney, pill bottles, batteries, medicine cart, wetroom floor tiles, to name a few. On Sunday and Monday and went to work producing these new items. I really wanted to get to the position on Monday that I could play through a fair amount of the map and have final access to the torch.
I didn’t get the time to create all of the objects but I made some solid progress which has moved the map a lot closer to being feature complete.
For the rest, things mostly went to plan…
2 doors on the lower half of the map refused to activate. When a player approaches a door a small circle displays in the middle of it to indicate that it can be activated (unless its locked), when the mouse is placed over the door the small circle is replaced with the open door icon, and finally a mouse click triggers the door and it opens. However, these 2 doors, which are just clones of other doors on the map, would not show the interaction circle. It took almost half an hour before I discovered (using debug messages) that the door hinge (pivot point, which is used for player position and distance checking) was slightly clipping the collision square of the wall. This means that when the door is checked to see if the player has line of sight it fails because the wall is in the way, and that disables the door. By moving the collision box down 1 pixel (yup, one darn pixel) the door was usable again.
The wet room has been decked out partially with showers and bath tubs. It still needs some seating in the changing area, but it’s looking pretty good so far. I have some interesting ideas here and it will also allow me to introduce one last system into the game – player anxiety! More on that at a later date though.
Other smaller tweaks I’ve completed this weekend:
The torch light has been made slightly whiter, although I still want to keep it a little yellow so it stands out against the normal ambient lighting, when the torch is on there is also now an improved illumination around the player.
The telephones were too large, and some of the storage rooms have had there items moved about to improve the look and feel.
The player movement has been tweaked. When you move via keyboard you have 2 different types of movement; left and right and up and down, and the diagonals. When you press a movement key a variable is set to indicate the directionality. This is fine when you press on direction because move_h (for example) would be set to 1 and move_v would be set to 0, which is then applied to the walk speed multiplier and the player moves. However, when 2 directions are used at the same time (diagonal) both move_h and move_v are set to 1, and this results in a faster movement when walking diagonally. Not ideal, especially when the player is running. So, I added in a check for diagonal movement and applied a restriction to the movement multiplier to ensure that the speed diagonally is the same as the single direction speed. This works great, but I am toying with the ideal of slightly increasing the players normal walking speed.
The quick message handler needed a tweak to fix a bug that caused the message to jump up and down on the screen a bit if some conversational dialogue was going on at the same time. Turned out to simply be the vertical text alignment not being reset between scripts. Phew.
Finally, I added a fair few new bits of interaction for the player to find. Various items in the environment can be examined for more information. Eventually I will need to extend this slightly so that examining an item such as a storage box could yield inventory items (hidden items).