Workshop › Breakout › Step 8 of 39
Every frame the ball moves by its velocity. That goes in update, and the loop calls update before draw.
```js
function update() {
ball.x += ball.vx
ball.y += ball.vy
}
function loop() {
update()
draw()
requestAnimationFrame(loop)
}
```ball.x += ball.vx adds the velocity to the position: 240 becomes 243, then 246...update() first, so every picture shows the newest position.update just above function draw() {, with an empty line between them.loop, add update() above draw().Skills: Velocity and gravity, The game loop
← Draw a round ball Bounce off the side walls →