Workshop › Doodle Jump-style Climber › Step 16 of 24
After a fall, Space starts a new climb. All the starting values move into reset, which runs at the start and after
every game over.
```js
let player
let platforms
let cameraY // the world y shown at the top of the screen: the camera
let highest // world y of the highest platform so far
let state // 'playing' or 'over'
function reset() {
player = { x: 180, y: START_Y - 40, w: 40, h: 40, vy: 0 }
platforms = [{ x: 170, y: START_Y, w: 60, h: 12 }]
cameraY = 0
highest = START_Y
state = 'playing'
fillPlatforms()
}
if (event.key === ' ' && state === 'over') reset()
reset()
```reset sets them, and fills the screen with platforms.START_Y - 40).reset under const keys = {}.keydown, add the Space line.fillPlatforms() at the bottom with reset().Skills: Game states, Functions
← Miss and fall Tap to play again →