Workshop › Doodle Jump-style Climber › Step 2 of 24
The picture will change every moment, so the drawing goes into draw and a loop runs it about 60 times a second.
```js
function draw() {
ctx.fillStyle = '#f8fafc'
ctx.fillRect(0, 0, canvas.width, canvas.height)
ctx.fillStyle = '#f59e0b'
ctx.fillRect(player.x, player.y, player.w, player.h)
}
function loop() {
draw()
requestAnimationFrame(loop)
}
requestAnimationFrame(loop)
```draw paints the whole picture, background first, which wipes the old one.requestAnimationFrame(loop) asks the browser to run loop again before the next screen refresh.Wrap the four drawing lines in draw, then write loop and start it.
Skills: The game loop