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

Function update

JS - Chrome Dino Game Clone/script.js:20–37  ·  view source on GitHub ↗
(time)

Source from the content-addressed store, hash-verified

18let speedScale
19let score
20function update(time) {
21 if (lastTime == null) {
22 lastTime = time
23 window.requestAnimationFrame(update)
24 return
25 }
26 const delta = time - lastTime
27
28 updateGround(delta, speedScale)
29 updateDino(delta, speedScale)
30 updateCactus(delta, speedScale)
31 updateSpeedScale(delta)
32 updateScore(delta)
33 if (checkLose()) return handleLose()
34
35 lastTime = time
36 window.requestAnimationFrame(update)
37}
38
39function checkLose() {
40 const dinoRect = getDinoRect()

Callers

nothing calls this directly

Calls 7

updateGroundFunction · 0.90
updateDinoFunction · 0.90
updateCactusFunction · 0.90
updateSpeedScaleFunction · 0.85
checkLoseFunction · 0.85
handleLoseFunction · 0.85
updateScoreFunction · 0.70

Tested by

no test coverage detected