Workshop › Space Invaders-style › Step 20 of 21
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)
}
```Math.max(40, ...) never lets the step be quicker than 40 ms.Replace the body of stepInterval with the formula, and write the comment above it.
Skills: Game states, Functions
← Waves Build it yourself: an extra life →