Workshop › Tower Defense › Step 32 of 42
When the last life is lost the game is over: the state becomes 'over' and nothing moves any more.
```js
function update() {
if (state === 'over') return
if (lives <= 0) {
lives = 0
state = 'over'
return
}
```update: when the game is over, return at once, so enemies, towers and bullets all stop.'over' and stop.if (state === 'over') return and an empty line the first lines of update.lives block between the last enemies = enemies.filter(...) line and the wave-end block.Skills: Game states
← Closer together No building after the end →