MCPcopy Create free account
hub / github.com/codemistic/Web-Development / main

Function main

Snake Game /game.js:9–27  ·  view source on GitHub ↗
(currentTime)

Source from the content-addressed store, hash-verified

7const gameBoard = document.getElementById('game-board')
8
9function main(currentTime) {
10 if (gameOver) {
11 if (confirm('You lost. Press ok to restart.')) {
12 window.location = '/'
13 }
14 return
15 }
16
17
18 window.requestAnimationFrame(main)
19 const secondsSinceLastRender = (currentTime - lastRenderTime) / 1000
20 if (secondsSinceLastRender < 1 / SNAKE_SPEED) return
21
22
23 lastRenderTime = currentTime
24
25 update()
26 draw()
27}
28
29window.requestAnimationFrame(main)
30

Callers

nothing calls this directly

Calls 2

updateFunction · 0.90
drawFunction · 0.90

Tested by

no test coverage detected