Prev Up Next
Go backward to Setting the Ball's Initial Position
Go up to Top
Go forward to Moving the Ball

Drawing the Ball

The basic steps you will perform in the "animate" method are to:

At this level, "pong" is just like the bouncing ball applet. The difference between the two will be in the details of how the variables that describe the x and y coordinates of the ball are changed.

To get started, add to the body of "animate" a "clearRect" to clear the screen and a "fillOval" to draw the ball at the x and y coordinates determined by the coordinate variables. Once this is done, run your applet. If everything is correct, a small black circle should appear at the top of the applet's screen area.


Prev Up Next