
Adding Jumping
This piece of code will let the user control the player to make them jump. You will need to use an eventListener to record when a key is pressed, and set downwardForce to allow the player to jump. To make the player fall back down again, you will need to use an if statement so that when the player reaches the maximum jump height, they fall back to the ground.
Click in the Result preview below to control the player.
See the Pen GB8 M4 by Walker Books UK (@walkerbooks) on CodePen.