Workshop › Snake › Step 8 of 28
A game loop runs again and again: update, draw, and ask the browser to run it again before the next screen
refresh (requestAnimationFrame, about 60 times a second).
```js
function loop() {
update()
draw()
requestAnimationFrame(loop)
}
requestAnimationFrame(loop)
```loop runs one turn: move, then draw.requestAnimationFrame(loop) inside it books the next turn, so it keeps going.draw() call.Replace the draw() call at the bottom with the loop function and requestAnimationFrame(loop).
Skills: The game loop
← A function that moves Slow it down →