Explaining TopNumbingly boringActive Objects

Active Objects

We talked about several examples involving animation, including the pong game (below in both "pathetic" and "real" versions).

These examples involve creating classes extending ActiveObject.

To create an ActiveObject one must:

  1. define a class that "extends ActiveObject"

  2. define its constructor and say "start()" at the end.

  3. define a "public void run()" method.

  4. Include a pause statement inside any while loops in the run method. This is necessary both to slow the animation and to allow the processor to take care of other pending tasks.

Our first simple example is of a falling ball in a window with a Pong paddle. The Pong paddle can move at the same time that the ball falls. There is always one thread which handles the mouse motion methods (e.g., onMouseMove), so this program will have two threads operating concurrently: one which moves the paddle and the other which moves the ball.

Actually, we will consider a definition of a moving Pong ball that just falls rather than bouncing off the walls or paddle. This makes for a pretty boring pong game, but it does demonstrate the basics of ActiveObjects.


Explaining TopNumbingly boringActive Objects