## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

# Time for action — moving the ball

Moving the ball is as simple as moving the paddles, as you will see.

1. For updating the ball's position, you need to create a new method called` UpdateBall`. At first, we will update the ball's X and Y position:
```Method UpdateBall:Int()
bX += bdX 'Add the X speed of the ball to its X position
bY += bdY 'Add the Y speed of the ball to its Y position
```

We could end here, but then the ball would not bounce of the walls and would just disappear in nowhere land.

2. Add a check if the ball hits the top wall and reacts to it.
```If bY < 10.0 then
bY = 10.0 'Set the Y position back to 10.0
bdY *= -1 'Inverse the balls Y speed
Endif
```
3. Next, check if the ball hits the bottom wall and, again, reacts to it.
`If bY > 470.0 then bY = 470.0 'Set ...`

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required