Workshop › Space Invaders-style › Step 20 of 21

Faster and faster

What we are doing

The fewer invaders are left, the faster they march — the famous tension of the game. Later waves are quicker too.

```js
// Fewer invaders march faster: from 588 ms with all 45 alive down to 60 ms for the last one, quicker in later waves.
function stepInterval() {
  return Math.max(40, 60 + (alive().length - 1) * 12 - (wave - 1) * 40)
}
```

What it means

Your turn

Replace the body of stepInterval with the formula, and write the comment above it.

Skills: Game states, Functions

All steps

  1. The ship
  2. The game loop
  3. Move the ship
  4. Stay on screen
  5. Fire
  6. Bullets fly
  7. A short reload
  8. The invaders
  9. The march
  10. Hit!
  11. Score
  12. They shoot back
  13. Bombs fall
  14. Lives
  15. Game over
  16. Best score
  17. A wave in a function
  18. Play again
  19. Waves
  20. Faster and faster
  21. Build it yourself: an extra life