Workshop › Tower Defense › Step 29 of 42
When no enemy is left to come and none is on the road, the wave is over: back to building, with bonus gold.
```js
if (state === 'wave' && toSpawn === 0 && enemies.length === 0) {
state = 'building'
gold += 20 + wave * 5
}
```&&: we are in a wave, nothing left to spawn, nothing on the road.'building' and a bonus of 20 + wave * 5 gold (25 after wave 1, 30 after wave 2...).In update, under the last enemies = enemies.filter(...) line, leave an empty line and write the block.
Skills: Game states
← Space starts a wave Stronger every wave →