The game file to import and load for this session is 5961_06_11.stencyl
.
Level
, with the configuration shown in the following screenshot:We have created a new game attribute called Level
, which will be used to record the current level of the game.
A game attribute is being used here, because we need to access this value in other scenes within our game; local attributes have their values reset whenever a scene is loaded, whereas game attributes' values are retained regardless of whether or not a different scene has been loaded.
We'll be putting this game attribute to good use in Chapter 7, Polishing the game!
We've finished designing and creating the gameplay for the Monkey Run game, and the scoring behaviors are almost complete. However, there is an anomaly with the management of the Lives
game attribute. The monkey correctly loses a life when it collides with an enemy actor, but currently, when the countdown expires, the monkey is simply repositioned at the start of the level, and the countdown starts again from the beginning!
If we leave the game as it is, the player will have an unlimited number of attempts to complete the level — that's not much of a challenge!
The game file to import and load for this session is 5961_06_12.stencyl
.
The recommended tasks in this Have a go hero session should be attempted, as Chapter 7, Polishing the Game, relies on some of these modifications.
Suggested solutions together with comments, can be found in the Health
and Manage Player Collisions
behaviors in the download file named 5961_06_13.stencyl
.
Countdown expired
event, which is found in the Health
actor behavior, modify the test for the countdown so that it checks for the countdown timer being exactly equal to zero, rather than the current test, which is for the Countdown
attribute being less than 1. We only want the ShowAngel
event to be triggered once when the countdown equals exactly zero!Show Angel
event manages the complete process of losing a life, that is, either when a collision occurs between the monkey and an enemy, or when the countdown timer expires. A single event should deduct a life and restart the level.Display HUD
event in the Score Management
scene behavior, so that the timer bar is only drawn when the countdown is greater than zero.There are many different ways to implement the above modifications, so take some time and plan the recommended modifications!
Test the game thoroughly to ensure that the lives are reduced correctly and the level restarts as expected, when the monkey collides with the enemy, and when the countdown expires. It would certainly be a good idea to review the download file for this session, compare it with your own solutions, and review each event carefully, along with the accompanying comment blocks. There are some useful tips in the example file, so do take the time to have a look!
18.218.212.102