Faking lifts


In 'Octavius Kitten The Game' there are three mine-shafts that lead to distinct areas of the map.  I added these because I wanted non-linear progression through the game - once you've got past the first few rooms, you can tackle exploration and the collection of objects in any order.

During gameplay, traversal of the mine-shafts looks like this:


Now, you would be perfectly justified in assuming that there is one lift that goes up and down several floors.  Congratulations - you've just been fooled by a bit of fakery!

Having the lift presented me with a problem - what happens if you go down a floor, and re-enter the mine-shaft on a different level?  What do you do about the lift, which is supposed to still be on a level above?  Do you add a 'call button'?  Or make the lift automatically descend to the player's level?

You could ensure that if areas that exit from the mine-shaft never connect to the same mine-shaft on a different level. Sure, that solves this problem, but it imposes a huge restriction on room layout, and I didn't want that.

So I chose to 'fool' the player!  Here is the whole mine-shaft (as rendered in the game editor):


You might notice that instead of one lift, there are actually 5 of them.  You might also notice that they are at the same position in each room (tile [14,15]).  But in game, the lifts don't appear at this place when the player is travelling on the lift!

The algorithm works like this:

- If the player is standing above a lift and presses up or down, the player state changes to 'on lift up' or 'on lift down';

- During the update phase, the player is moved up or down a specific amount

- Input controls are disabled while in this state

- The sprite list is searched for a lift that is in this room, and when found it is positioned below the feet of the player sprite.

- When the player reaches the lift's 'home' position at [14,15] (to be more accurate, above that position), the player state is set back to normal.

So really, all we are doing is moving the player, and glueing any lift that is in the room to the player's feet.  The lifts don't need to exist at all - they are just 'eye candy'.  

The advantages of this approach are:

- We have solved the problem of re-entrance to a mine-shaft with a missing lift, as it can never be missing;

- The algorithm works when changing rooms without having to consider whether this is happening - it logically works regardless of the room you are currently in;

- And the biggest win - we don't need to store any state for this lift nor any others.  And as any good programmer knows, less state means less bugs.

Most games fool the player in many ways, and this is just one way that I've chosen.  Another is the 'jump buffer'.  When you reach the end of the platform, I give a couple of frames 'grace' where you may still jump.  This is common in platforming games.  Take away the jump buffer, and you irritate the player when they fall down instead of jumping, when they would swear blind that they pressed jump in time.  Humans are funny creatures, and sometimes need a little fooling to keep them happy.

Get Octavius Kitten (The Game!)

Leave a comment

Log in with itch.io to leave a comment.