Workshop › Endless Runner › Step 12 of 19
After a crash, Space (or a tap) should bring back a fresh run. All the starting values move into a reset function,
which runs at the start and again after every game over.
```js
let runner
let state // 'ready', 'running' or 'over'
let obstacles
let speed
let nextIn // frames until the next obstacle
function reset() {
runner = { x: 50, y: GROUND - STAND_H, w: 40, h: STAND_H, vy: 0 }
state = 'ready'
obstacles = []
speed = 6
nextIn = 60
}
if (state === 'over') {
reset()
return
}
reset()
```reset gives them their starting values.reset() at the bottom sets up the first run.reset function.jump, write the game-over block.reset() right above requestAnimationFrame(loop) at the bottom.Skills: Game states, Functions