Workshop › Frogger-style Crossing › Step 20 of 22
When all four homes are full, that is a new level: 100 bonus points, empty homes, and everything moves a quarter faster, up to twice the starting speed.
```js
let level
level = 1
if (filled.every(Boolean)) {
level += 1
score += 100
filled = HOMES.map(() => false)
}
// Each level is a quarter faster, up to twice the starting speed.
const pace = Math.min(2, 1 + (level - 1) * 0.25)
for (const lane of LANES) lane.offset += lane.speed * pace
frog.x += lane.speed * pace
ctx.fillText('Level ' + level + ' Lives: ' + lives, canvas.width - 10, 27)
```filled.every(Boolean) is true when every home is filled.pace is 1 on level 1, 1.25 on level 2, and stops at 2; every lane and the frog on a log move speed * pace.let state, write let level; in reset, set it to 1.reachHome, write the full-house block before newFrog().update, write the comment and pace, and use * pace in both places.draw, show the level with the lives.Skills: Game states, The game loop
← Points for progress Best score →