Workshop › Mario-style Platformer › Step 28 of 37
Getting hurt will cost a life and restart the level. Remember the blueprint? Restarting is now trivial: throw the live
objects away and build them again from the level text with loadLevel(). newGame() does the same, plus three lives.
```js
let lives
function newGame() {
lives = 3
loadLevel()
}
function die() {
lives -= 1
loadLevel()
}
newGame()
```newGame sets three lives and loads the level; it replaces the loadLevel() call at the bottom.die takes a life away and rebuilds everything from the level text.let collected write let lives.function jump() { write newGame; above function updatePlayer() { write die.loadLevel() with newGame().Skills: Game states
← Do not walk off ledges Falling into a pit →