Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Python Programming MySQL MongoDB OOP And Tkinter

Authors: R. PANNEERSELVAM

1st Edition

9357011331, 978-9357011334

More Books

Students also viewed these Databases questions