Time for action — giving our player a life
In video games, a player gets a Game Over when the character they control runs out of lives. Right now, our player doesn't have that luxury, so let's change that. In our game, the player will have a Score
private variable to store how many enemies they stomped in that life, while a Lives
global variable stores how many lives they have left before they lose.
1. Open the left menu for our player again. Scroll down to the Private Variables group, and click on Add/Edit to get a window similar to the following screenshot:
2. Now click on the plus button and create a number named
Score
. Leave the value of it at0
and click on OK. Then click on Done in the private variable manager screen.3. To finish, make a global variable
Lives
. To do so, open the right menu, and in the project tab, right-click on the item Global variables and click on the context item Add global variable, as in the following screenshot, when it appears:Set the value to 3 and click on...