- #1
Hypnos_16
- 153
- 1
Homework Statement
Create a class called, ThreeObjectAnimation, that creates a graphic animation with three animation object. The ThreeObjectAnimation class should move three objects around the frame, either randomly, or following a fixed pattern. The movements should occur every 250 milliseconds. The ThreeObjectAnimation class should use three classes, ObjectA, ObjectB, and ObjectC for these three movable objects. The object are allowed to intersect. Each of these classes is responsible for drawing a distinct graphics object with at least four shapes and two colours.
The size and colour of the shapes drawn by ObjectA, ObjectB, and ObjectC should be modified every 500 milliseconds. For example, if ObjectA draw a rectangle, then the size of the rectangle could change, a circle in ObjectB could changle colour.
The Car class, on page 106, can be used as an example for the implementation of ObjectA, ObjectB, and ObjectC. The ThreeObjectAnimation class implementation can be based on DrawingTemplate form the course notes.
Note, there are two kinds of animations, one for modify how a object is drawn, and on the modifies where the object is drawn. The movement occurs every 250 ms and the modification of the object is every 500 ms.
The ObjectA, ObjectB, and ObjectC should implement the Animate interface and the Drawable interface. Drawing is done the the Drawable.draw method. Moving the center of the object is done with Animate.move, and changing how the object will be drawn is done with Animate.changeConfiguration.
The interfaces are:
--- Animate ---
public interface Animate {
void move( double x, double y);
void changeConfiguration();
}
--- Drawable -----
import java.awt.Graphics2D;
public interface Drawable {
void draw(Graphics2D g2d);
}
The ThreeObjectAnimation class will invoked Animate.move and Animate.changeConfiguration in the timer callback. The Drawable.draw could be call in the paintComponent method.
Homework Equations
N/A
The Attempt at a Solution
I'm having a hard time figuring out really where to start here, i have a basic idea for the three objects, I'm just having a really hard time making them work! If someone could help me with animating just one of them i could figure out the others on my own!
please! i really need help here you guys.