Velocity is a value added to an object's position each game-loop iteration. Separate X and Y velocity values move the ball horizontally and vertically. section 5.15
Set the ball's initial velocity to 1 on both axes, then reverse an axis when the ball reaches a screen boundary. A value of $FF supplies the opposite direction in the example. section 5.15
Bouncing ball
The game loop adds d_y to the ball's Y coordinate and d_x to its X coordinate. Reaching the top or left edge changes the relevant value to 1; reaching the bottom or right edge changes it to $FF.



