Workshop › Chess › Step 8 of 48
Soon the pieces will move, and the picture must follow the data. A game loop redraws the board before every screen
refresh, about 60 times a second, with requestAnimationFrame.
```js
function loop() {
draw()
requestAnimationFrame(loop)
}
reset()
requestAnimationFrame(loop)
```requestAnimationFrame(loop) asks the browser to run loop before the next screen refresh.loop draws and asks for itself again, so it never stops.draw() call.Replace the draw() call at the bottom with loop and requestAnimationFrame(loop); keep reset() above it.
Skills: The game loop
← An outline for white The knight's jumps as data →