Workshop › Missile Command-style Defense › Step 25 of 35

Waves

What we are doing

The game comes in waves. nextWave() starts the next one: a few more missiles each time, and a little more ammo. reset() starts from wave 0 and calls it.

```js
let wave

function nextWave() {
  wave += 1
  toLaunch = 8 + wave * 2
  launchIn = 30
  ammo = 12 + wave * 2
}

  wave = 0
  score = 0
  nextWave()
```

What it means

Your turn

  1. Above let toLaunch write let wave.
  2. Above the // A new enemy missile ... comment, write nextWave, followed by an empty line.
  3. In reset, replace the lines score = 0, toLaunch = 20, launchIn = 30, ammo = 14 with the three new lines.

Skills: Game states, Functions

All steps

  1. Six cities to protect
  2. Your missile base
  3. Draw again and again
  4. Cities that can fall
  5. Rubble
  6. Move towards a point
  7. Launch an enemy missile
  8. One missile a second
  9. Missiles on their way
  10. Smoke trails
  11. Impact
  12. Fire an interceptor
  13. Click the sky
  14. Interceptors fly
  15. An explosion that grows and shrinks
  16. Explode on arrival
  17. Draw the explosions
  18. Impacts explode too
  19. Caught in the blast
  20. Chain reactions
  21. Only your explosions count
  22. Points for every missile
  23. Show the score
  24. Limited ammo
  25. Waves
  26. Each wave is harder
  27. The end of a wave
  28. The end
  29. Play again
  30. Wave, ammo and messages
  31. Launch from anywhere
  32. Some missiles will split
  33. Split into three
  34. A high score
  35. Build it yourself: a crosshair