If you were unfortunate enough to be caught by one of the monsters in the game, you may have found it rather unsatisfying to have the game immediately end – you may have had the feeling that a slip of the keys was to game, or a miscalculation about the speed of the monster that you won’t fall for again.
The majority of arcade style games in which the player character can be “killed” offer the player the chance to play again. So common is the idea of “three lives then you’re out” that it could almost be described as a convention – and something that players will expect the game to offer.
So how can we introduce the notion of lives into our maze game?
As in Who’s Best? Keeping Track of High Scores and Upping the Stakes – Bonus Points, we will call on a controller object to manage the lives of our player character. Create a new controller object (
controller_lives, for example; no sprite required) and add the following events:
– from the Event Selector, choose Other and then
Draw Lives No More Lives. You will need to add two actions to this event: Display a message (“You lost *all* your lives!”,maybe?!), which can be found in the Info panel of the main2 actions tab; and an End Game action, from the Game panel of the same tab;
– again from the Event Selector, choose Draw, and add the Draw the lives as image action from the score actions tab. Double click on the Draw the lives as image action to raise it properties dialogue, and put in the co-ordinates of where you would like the lives counter to appear on the screen. Select an appropriate image for the life counter (for 3 lives, 3 images will show…)
Now add the controller object to the room (it doesn’t really matter where). The controller object will manage what happens when you lose a life, or when your lives run out. But how do we get our lives in the first place? And how do we lose them?
In the player object (
obj_player), add a Create event, containing the Set lives action from the score tab; set the number of lives to 3. When an instance of the player object is created, it will now be initialised with three lives.
To lose a life, we need to revise what happens when a monster collides with the player character. Still referring to the player object, select the appropriate Collision Event, remove the End Game action (this is now being managed by the controller object), and add the following actions: Set Lives (from the score tab, and with the properties “relative to -1”); and Jump to Start (from the move tab).
Run your game. Hopefully, you should find that you now get three chances to cross the room. If a monster catches you, your player character is returned to the point at which it entered the room.
Does the addition of multiple lives improve the playability of the game. I certainly found it less frustrating when I got caught, knowing that I’d be able to have another go (having possibly worked out how to get round a particularly trickily placed monster!)
How important is the number of lives that a player is given? Why do you think the game might be less satisfying if the player had four or five lives, for example?
As well as losing something – lives in this case! – we also want our player character to be rewarded in some way as they progress through a room, so that the player can gain some sort of points scoring reward even if they don’t manage to cross the room completely.
In the next post, I’ll show how to add some ‘treasure’ to the room that will reward the player with points as they collect the treasure items.
In the meantime, what do you think should happen when a player collects (i.e. collides with) a treasure object? What objects, sprites, events and actions will we need to add to the game in order to implement “treasure”? ;-)
[Screenshots missing – I will add them by first thing tomorrow morning…]