Question: Add lives [ 2 marks ] - Your character should begin with three lives, and each time they fall down a canyon the game should

Add lives [2 marks]
- Your character should begin with three lives, and each time they fall down a canyon the game
should reset and their remaining lives decrement by one.
- Create a global variable `lives`, and initialise it to `3` within `setup`.
- Create a function called `checkPlayerDie`. Call this within draw.
- In this function define a conditional statement that tests if your character has fallen below
the bottom of the canvas. When this is `true`, decrement the `lives` counter by one
- Create a new function called `startGame()`.
- Move everything from `setup` except `createCanvas` and the initialisation of `floorPos_y` and
`lives` into this new function.
- At the end of your now very short `setup` function call `startGame()`.
- In `checkPlayerDie` create a conditional statement to test if the player has
used all of their lives. If there are lives remaining call `startGame`.
- Write some code using a `for` loop to draw life tokens onto the screen so that you
can keep track of how many lives you have remaining.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!