Workshop › Tower Defense › Step 36 of 42
Play again
What we are doing
After game over, Space or a click starts a new game with reset(), which we already have.
```js
if (state === 'over') {
reset()
return
}
else if (state === 'over') reset()
```
What it means
- In
pointerdown, a click after game over starts a new game and return stops it from also building a tower.
else if in the Space handler: start a wave while building, otherwise start a new game if it is over.
Your turn
- In the
pointerdown listener, under const p = tileAt(event), write the if (state === 'over') block.
- In the
keydown listener, under if (state === 'building') startWave(), write the else if line.
Skills: Keyboard and mouse input, Game states
← The game over screen The bottom bar →
All steps
- Measure the map
- A map of tiles
- Draw it every frame
- The road as corners
- Fill in the road
- Draw the road
- Walking by distance
- Enemies on the road
- Walk
- Off the end of the road
- Here they come
- Towers
- From a click to a tile
- Click to build
- Where can you build?
- Show the gold
- Show before you click
- Show the range
- Pick a target
- Fire!
- A hit hurts
- Homing bullets
- Fizzle out
- Gold for every kill
- Lives
- Health bars
- Build, then defend
- Space starts a wave
- The wave is over
- Stronger every wave
- Closer together
- Out of lives
- No building after the end
- The most waves survived
- The game over screen
- Play again
- The bottom bar
- Click to start
- A second tower: the cannon
- Tower buttons
- Splash damage
- Build it yourself: sell a tower