|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.util.Observable | +--Body
A (possibly) moving object living on the xy-plane. Serializable for pass by value over rmi. Notes on the calls at different points in the life of a body:
Inner Class Summary | |
protected class |
Body.CollisionCheck
A scheduled collision check. |
class |
Body.CreatedLaterException
Attempted to project the body to a time before its creation. |
class |
Body.DisabledException
Exception thrown when trying to use a disabled body. |
class |
Body.Projection
An extrapolated projection of the body along its current known trajectory. |
Field Summary | |
protected double |
angle
|
protected long |
creation
|
protected int |
id
|
protected double |
movementX
|
protected double |
movementY
|
protected int |
player
|
protected double |
positionX
|
protected double |
positionY
|
protected double |
radius
|
protected long |
time
|
protected int |
type
|
Constructor Summary | |
Body(long when)
Create a new body, starting at given time. |
Method Summary | |
protected void |
activate()
Called from enable, right after body has been put to world and given master reference. |
void |
collision(Body threat,
long when)
Override this to do what is needed on actual collision. |
long |
collisionCheck(Body threat,
long when,
Body.Projection own)
Check one threat for collision, project soonest possible collision. |
void |
collisionCheck(long when)
The collision check inspects the situation at the time it was scheduled for, instead of when it occurs, to minimize the chance of missed collisions even if the check is badly delayed. |
protected void |
deactivate()
Deactivation is called from disable before master goes null. |
protected void |
destroy(long when)
If a body such as a ship of laser beam wants to die a violent and spectacular death, this is the method to call. |
void |
disable()
Disable kills master reference after calling deactivate to remove anything that depends on master. |
void |
enable(MasterEngine m,
int i)
Called by master engine to set master reference and id when body is put into the engine. |
double |
getAcceleration()
|
double |
getAngle()
|
int |
getId()
|
MasterEngine |
getMaster()
|
int |
getPlayer()
|
double |
getRadius()
|
long |
getTime()
|
int |
getType()
|
double |
getX()
|
double |
getY()
|
boolean |
isAccelerating()
|
Body.Projection |
project(long when)
Project this body along its current known trajectory to the given time. |
protected void |
setAcceleration(double a,
long when)
|
protected void |
setAngleRate(double rate,
long when)
|
void |
update(long newTime)
Update position, movement and other time-dependent attributes to given moment (ms since epoch). |
protected void |
updateComponents(long timeDelta)
Do the practical work of updating position, movement, and angle. |
Methods inherited from class java.util.Observable |
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected int id
protected int player
protected int type
protected long time
protected double radius
protected double positionX
protected double positionY
protected double movementX
protected double movementY
protected double angle
protected final long creation
Constructor Detail |
public Body(long when)
Method Detail |
public int getId()
public int getPlayer()
public int getType()
public long getTime()
public double getX()
public double getY()
public double getAngle()
public boolean isAccelerating()
public double getRadius()
public double getAcceleration()
public MasterEngine getMaster() throws Body.DisabledException
protected void setAngleRate(double rate, long when)
protected void setAcceleration(double a, long when)
public final void enable(MasterEngine m, int i)
protected void activate() throws Body.DisabledException
public final void update(long newTime)
protected void updateComponents(long timeDelta)
public void collision(Body threat, long when)
protected void destroy(long when)
protected void deactivate()
public final void disable()
public long collisionCheck(Body threat, long when, Body.Projection own) throws Body.CreatedLaterException
threat
- Another Body.when
- Absolute time in ms to consider in this check.own
- Projection of this body to when.Body.CreatedLaterException
- If threat was not yet created at when.public void collisionCheck(long when) throws Body.DisabledException
public Body.Projection project(long when) throws Body.CreatedLaterException
Body.CreatedLaterException
- if the body did not yet exist at the
requested time.
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |