Workshop › Typing Rain › Step 24 of 33
A higher level should also be harder: words fall faster and come more often. The constants SPEED and SPAWN_EVERY
become two small functions of the level.
```js
// Faster and more often as the level goes up.
const speed = () => 0.25 + level * 0.1
const spawnEvery = () => Math.max(40, 150 - level * 12)
spawnTimer = spawnEvery()
for (const w of words) w.y += speed()
```speed() is 0.35 and spawnEvery() 138: the same as before. Each level adds 0.1 to the speed and
takes 12 frames off the gap.Math.max(40, ...) picks the bigger number: the gap never goes under 40 frames. Without it, by level 13 the gap
would be negative and words would pour out every frame.SPEED and SPAWN_EVERY lines.function spawn() { write the comment and the two functions, with an empty line after them.update, use spawnEvery() and speed().Skills: Functions, Game states