Now that we got the ball to appear, let’s work on getting it to move!
Open up the “Ball” file once more, and code the “move” function as shown, under the “paint” function.
In here, we first set the xa and ya variables to be the speed that the game wants the ball to be.
We then update the x and y variables by adding the speeds to both of them. This “Ball” class will then use these updated values inside its “paint” function to make the ball appear to move! However, we still need to call/use this function.
Now that the “move” function has been coded, let’s go back to the “Main” file.
Inside here, “Main” also has a “move” function. Add the code as shown here to get the Ball to move.
After completing this code, run it and the ball should now move! However, the ball will eventually disappear off screen, let’s fix that next!