
Learning Java by Building Android Games
By :

As we have done so much theory and preparation work in the previous two chapters, we can quickly make some progress on this one. We already have our bare-bones game engine coded and ready to update, draw, and track time down to the nearest millisecond.
Now we can add code to the Bat
and the Ball
classes. By the end of the chapter, we will have a moving ball and a player-moveable bat. Although we will need to wait until the next chapter before the ball bounces off the walls and the bat, we will also code the necessary methods in the Ball
class so that this last step will be easy to achieve.
In this chapter, we are going to do the following:
Ball
classBall
in the game engineBat
classBat
instance in the game engineLet's start by adding our first object to the game to bring the ball to life.