Workshop › Breakout › Step 6 of 39
The ball needs a position and a velocity: how far it moves each frame. resetBall() puts it in the middle,
heading up and to the right.
```js
const BALL_R = 7
let ball
function resetBall() {
ball = { x: 240, y: 200, vx: 3, vy: -4 }
}
```BALL_R is the ball's radius. The ball is a circle, so x, y will be its center.let ball declares the variable without a value; resetBall() gives it one.vx: 3, vy: -4 means 3 pixels right and 4 pixels up per frame (y grows downward).const PADDLE_Y = 370 write const BALL_R = 7.let paddle = ... write let ball.clamp function and write resetBall.Skills: Velocity and gravity, Game states
← A canvas shown at another size Draw a round ball →