Workshop › Typing Rain › Step 9 of 33
A spawn timer counts down every frame; at zero a new word appears and the timer starts again from SPAWN_EVERY
(138 frames, a bit over two seconds). The game starts with no words and the timer at 0, so the first word comes at
once.
```js
const SPAWN_EVERY = 138
let spawnTimer
words = []
spawnTimer = 0
function update() {
spawnTimer -= 1
if (spawnTimer <= 0) {
spawn()
spawnTimer = SPAWN_EVERY
}
```spawnTimer counts down by 1 each frame (-=).if (spawnTimer <= 0) is true when it runs out: spawn a word and wind the timer up again.reset starts with an empty list and the timer at 0.SPEED write SPAWN_EVERY; under let words write let spawnTimer.reset, replace the hand-written list with words = [] and spawnTimer = 0.update, write the timer lines.Skills: The game loop, Game states
← A new word from the list Gone past the ground →