Answered step by step
Verified Expert Solution
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 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 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 floorPosy 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started