Workshop › Minesweeper › Step 22 of 26
A game this short is about speed, so we will add a timer. First, the time itself: requestAnimationFrame passes the
loop a timestamp in milliseconds, and we keep it in now.
```js
let now = 0
function loop(time) {
now = time
draw()
requestAnimationFrame(loop)
}
```loop(time) receives the timestamp; now = time keeps it for everyone else.now starts at 0 until the first frame.let state ..., write let now = 0.loop a time parameter, and write now = time as its first line. Press Run.Skills: The game loop
← The end and a new game The clock →