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:
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.
Active Objects |