Adding a jump variable to the player sprite and updating the gravity part of the game loop will simulate the power to jump up and over hazards or between platforms.
The jump variable will remember how much force against gravity the player sprite currently has. When the sprite is not jumping, the force will be zero and gravity will be in charge.
In the game loop, when the player hits the chosen jump key, the force will be set to the maximum. This will make the player sprite go up. Over time, the force will be reduced to bring the player back to earth.
In Part 1, we made the player sprite sense when it was touching ground colours. This allowed us to turn off gravity. In the same way, we will detect a hazard colour (blue for water) that will move the player back.
Later on, we can also use these hazards to count down the number of lives.
All successful gamers need a rewards. What better than another, more difficult level. We show how to put in a target sprite and change levels when we touch it.
See the finished version of this step in Scratch.