Workshop › Space Invaders-style › Step 19 of 21
When every invader is down, the wave number goes up and a new formation arrives. The wave is shown in the middle of the top bar.
```js
if (alive().length === 0) {
wave += 1
spawnWave()
return
}
ctx.textAlign = 'center'
ctx.fillText('WAVE ' + wave, canvas.width / 2, 24)
```return ends this frame right after the new wave appears.textAlign = 'center' centers the text on the given x.update, under the second stop line, start a new wave when none are left.draw, write the wave between the score and the lives.Skills: Game states
← Play again Faster and faster →