Workshop › Bomberman-style Arena › Step 40 of 42
The game gets a clock. The loop runs 60 times a second, so counting the frames while playing gives the time:
frames / 60 seconds, shown at the top right.
```js
let frames
frames = 0
if (state !== 'playing') return
frames += 1
ctx.textAlign = 'right'
ctx.fillText('Time ' + Math.floor(frames / 60), canvas.width - 8, 22)
```frames counts the frames played; Math.floor rounds down, so 150 frames is 2 seconds.textAlign = 'right' makes x the right end of the text, 8 pixels from the right edge.let state write let frames; in reset, under state = 'playing', write frames = 0.update, under the first line, write frames += 1.draw, under the top line of text, write the two Time lines.Skills: The game loop, Game states
← Play with a finger The fastest win →