Workshop › Frogger-style Crossing › Step 20 of 22

Next level

What we are doing

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)
```

What it means

Your turn

  1. Under let state, write let level; in reset, set it to 1.
  2. In reachHome, write the full-house block before newFrog().
  3. In update, write the comment and pace, and use * pace in both places.
  4. In draw, show the level with the lives.

Skills: Game states, The game loop

All steps

  1. Road and river
  2. The frog
  3. Keep drawing
  4. Hop
  5. Swipe to hop
  6. Lanes of traffic
  7. Cars
  8. Traffic moves
  9. Hit by a car
  10. Three lives
  11. Play again
  12. Tap to play again
  13. Logs on the river
  14. Stay on the logs
  15. Ride the log
  16. Back in line
  17. Home slots
  18. Get home
  19. Points for progress
  20. Next level
  21. Best score
  22. Build it yourself: a time limit