Balls and Blocks
These applets are my first experiment with OOP in Java. A fairly simple animation loop runs a collection of Actor objects. Different types of actor are
derived from this base abstract class. Since all of these classes are derived from Actor, an iterator can run through all of the objects and call the move()
and draw() methods on every object.
In the top right corner of each of the demonstrations is a counter showing how many actors are in the collection. When an actor dies it flags itself as
capable of being removed from the collection. When an actor wants to add more objects to the collection, it can pass the list of objects out to the iterator
which will then add them to the Actor collection.
There are two types of balls - filled and hollow. Both types of ball inflate at a random rate.
When they reach a certain size they pop and disappear. When a filled ball pops, it spits out a filled ball and between 5 and 10 hollow balls.
Blocks move randomly in one of four directions, releasing smoke as they go.
When a block is going to move it picks a direction, speed and distance at random. It also picks a random amount of time to sleep once it finishes moving.
- Balls And Blocks
This runs balls and blocks together. This has four types of actors - two types of balls,
blocks and smoke particles.