|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--vehicle.AbstractVehicle
An AbstractVehicle has the current World and a MovementTracker.
Any subclass must implement the createShapes(), update(), and draw() methods.
The createShapes() method is called from this constructor. It should instantiate
all necessary geometrical shapes associated with this vehicle and register it with the
MovementTracker of this object.
The draw() method is called whenever it's time to paint/repaint the screen. This can happen at any time.
State changes should not occur in this method. Presumably, this method should just set the color of the different
shapes created in createShapes() and call the necessary methods in the graphics module.
The update() method is called by the world whenever it's time to update the state of the world.
This occurs onces World.FPS times per second. Any changes to the state of this vehicle such as moving
should occur in this method.
Field Summary | |
protected MovementTracker |
mvTrack
|
protected World |
theWorld
|
Constructor Summary | |
AbstractVehicle(World ourWorld)
Initialize variables for the vehicle. |
Method Summary | |
abstract void |
draw(java.awt.Graphics2D g)
Use the graphics system to actually paint the shapes we have created. |
double |
getOrientation()
Gets the orientation changed from the inital drawing |
MovementTracker |
getTracker()
Retrieves the MovementTracker. |
double |
getX()
Returns the current x position of the center point of all the shapes contained in this tracker. |
double |
getY()
Returns the current y position of the center point of all the shapes contained in this tracker. |
void |
handleCollision(AbstractVehicle av)
Handles a collision with another vehicle. |
void |
moveBy(double xoffset,
double yoffset)
Move by xoffset and yoffset pixels. |
void |
moveTo(double x,
double y)
Move to (x, y) in the world. |
void |
rotateBy(double theta)
Rotate shapes by theta with postive sign meaning clockwise |
void |
setOrientation(double theta)
Set the current orientation with postive sign meaning clockwise. |
abstract void |
update()
Called by World when it's time to update. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected World theWorld
protected MovementTracker mvTrack
Constructor Detail |
public AbstractVehicle(World ourWorld)
Method Detail |
public double getX()
public double getY()
public double getOrientation()
public void setOrientation(double theta)
theta
- the angle in radianspublic void rotateBy(double theta)
theta
- the angle in radianspublic void moveTo(double x, double y)
x
- the x-coordinate to move toy
- the y-coordinate to move topublic void moveBy(double xoffset, double yoffset)
xoffset
- the number of pixels to move in the x-axis directionyoffset
- the number of pixelse to move in the y-axis directionpublic MovementTracker getTracker()
public void handleCollision(AbstractVehicle av)
av
- the other vehiclepublic abstract void update()
public abstract void draw(java.awt.Graphics2D g)
g
- the graphics system to use
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |