|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--dualroids.SpatialObject | +--dualroids.Bullet
The representation of a bullet.
The implementation of Bullet
is thread-safe
in the sense that the one thread may call the setters
while another calls the getters. However, there may
not be multiple threads calling
getTransformedShape
. It is designed
to be used from a single thread only.
Also, that thread should not retain references to
objects returned by getTransformedShape
across the method calls. When the method is called
the object it returned previously will no longer be valid.
Field Summary | |
private static double |
BULLET_HALF_LENGTH
Constant for the length of a bullet divided by 2. |
private static long |
BULLET_TTL
The lifetime of a bullet in milliseconds. |
private static double |
BULLET_VELOCITY
Constant for the bullet velocity. |
private long |
expires
The moment in time when this bullet expires |
private double |
lineDeltaX
The x difference of the between the center of bullet the end of the bullet line |
private double |
lineDeltaY
The y difference of the between the center of bullet the end of the bullet line |
private Line2D |
translatableLine
The Line2D instance used for returning
the translated Shape representation of the bullet |
private Point2D |
translatableLocation
The Point2D instance used for returning
the translated location of the bullet |
Fields inherited from class dualroids.SpatialObject |
COLOR_TABLE, COLOR_TABLE_BLACK, COLOR_TABLE_GRAY_50, COLOR_TABLE_WHITE, geometry, locationX, locationY, timestamp, transform, velocityX, velocityY |
Constructor Summary | |
Bullet()
Contructs a new bullet. |
Method Summary | |
void |
fire(double locationX,
double locationY,
double shipVelocityX,
double shipVelocityY,
double angle,
long timestamp)
Fires this bullet. |
Point2D |
getLocation(long time)
Returns the location of the bullet at time . |
Shape |
getTransformedShape(long time)
Returns a properly transformed Shape representing
the spatial object at time |
void |
initFromRemote(double locationX,
double locationY,
double velocityX,
double velocityY,
double lineDeltaX,
double lineDeltaY,
long timestamp,
long expires)
Initializes the state of the bullet from external state data. |
void |
invalidate()
Marks the bullet non-flying (not visible) |
boolean |
readyToBeFired()
Returns a boolean indicating whether the bullet is ready to be fired. |
void |
writeToConnector(int thisIndex,
ClientModelConnector connector)
Writes the state of the bullet to a ClientModelConnector |
Methods inherited from class dualroids.SpatialObject |
moveToRangeX, moveToRangeY |
Methods inherited from class java.lang.Object |
|
Field Detail |
private static double BULLET_VELOCITY
private static double BULLET_HALF_LENGTH
private static long BULLET_TTL
private Point2D translatableLocation
Point2D
instance used for returning
the translated location of the bulletprivate double lineDeltaX
private double lineDeltaY
private Line2D translatableLine
Line2D
instance used for returning
the translated Shape
representation of the bulletprivate long expires
Constructor Detail |
public Bullet()
fire
method.Method Detail |
public final Point2D getLocation(long time)
time
.
There should be one thread at maximum per arena calling
this method. The returned Point2D shouldn't be retained
as it will become invalid when this method is called again.time
- the moment in game (server) time for which the
location is requestedPoint2D
public final void fire(double locationX, double locationY, double shipVelocityX, double shipVelocityY, double angle, long timestamp)
locationX
- the x coordinate of the shiplocationY
- the y coordinate of the shipshipVelocityX
- the x component of the velocity of the shipshipVelocityY
- the y component of the velocity of the shipangle
- the angle of the shiptimestamp
- the moment of firingpublic final Shape getTransformedShape(long time)
Shape
representing
the spatial object at time
getTransformedShape
in class SpatialObject
time
- the moment in game (server) time for which the
representation is requestedShape
representation at time
or null if the object isn't visiblepublic final void invalidate()
public final boolean readyToBeFired()
public final void writeToConnector(int thisIndex, ClientModelConnector connector)
ClientModelConnector
thisIndex
- the index of this bulletconnector
- the connector to which the state is to be writtenpublic final void initFromRemote(double locationX, double locationY, double velocityX, double velocityY, double lineDeltaX, double lineDeltaY, long timestamp, long expires)
locationX
- the x coordinate at which the bullet was firedlocationY
- the y coordinate at which the bullet was firedvelocityX
- the x component of the velocity of the bulletvelocityY
- the y component of the velocity of the bullettimestamp
- the moment at which the bullet was firedexpires
- the moment in time at which the bullet expires
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Dualroids was written by Oskar Ojala, Yrjö Kari-Koskinen and Henri Sivonen