Workshop › Wolfenstein-style 3D Maze › Step 16 of 18

Best time

What we are doing

The fastest escape is kept in localStorage and shown next to the time. Here the best is the smallest number of frames.

```js
let best = Number(localStorage.getItem('ray-best')) || 0

    if (best === 0 || frames < best) {
      best = frames
      localStorage.setItem('ray-best', best)
    }

  ctx.fillText('Time ' + seconds(frames) + (best ? '  Best ' + seconds(best) : ''), canvas.width - 10, 22)
```

What it means

Your turn

  1. Under frames, write best.
  2. In the winning block, save a new record.
  3. Add the best time to the time text.

Skills: Game states

All steps

  1. The map
  2. The player
  3. Ceiling, floor and a loop
  4. Turn around
  5. Walk
  6. Is it a wall?
  7. Stop at walls, slide along them
  8. A ray: where it starts
  9. A ray: the grid lines
  10. A ray: walk to the wall
  11. The 3D view
  12. No fish-eye
  13. Light and shade
  14. A timer
  15. Escape!
  16. Best time
  17. Touch controls
  18. Build it yourself: run