Workshop › Pong › Step 7 of 26
A game loop runs again and again: draw, then ask the browser to run it again before the next screen refresh
(requestAnimationFrame, about 60 times a second). Soon it will also move things.
```js
function loop() {
draw()
requestAnimationFrame(loop)
}
requestAnimationFrame(loop)
```loop draws, then books the next turn with requestAnimationFrame(loop).draw() call.loop has no parentheses there: we hand over the function, the browser calls it later.Replace the draw() call at the bottom with the loop function and requestAnimationFrame(loop).
Skills: The game loop
← A function that draws Remember held keys →