
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:
- Clear the applet's screen region to remove the last "frame"
of the animation.
- Change the values of the variables that describe the ball's
position by adding to them the values of the variables that specify
the rates at which each coordinate is supposed to change, and
- Draw the ball in its new position.
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.
