|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object hermes.HObject hermes.Being
public abstract class Being
General game object class.
Represents "beings", defined as (H)Objects that have:
Being
s can be:
Being
sBeing
should be game entities that have at least one of these properties.
Subclass HObject
directly only if the entity has none of these properties.
If you want a Being
to draw itself to screen, override the draw() method.
If you want a Being
to update itself, override the update() method.
If you want a Being
to receive input messages from the PostOffice
,
override the message handler method specific to the type of message you want.
Field Summary | |
---|---|
protected PVector |
_position
|
protected HShape |
_shape
|
protected long |
_time
|
protected PVector |
_velocity
|
Constructor Summary | |
---|---|
Being(HShape collisionShape)
Alternate constructor that defaults to 0 velocity. |
|
Being(HShape collisionShape,
PVector velocity)
Creates a Being . |
Method Summary | |
---|---|
void |
draw()
Override in subclass if you want to draw the Being to the screen. |
protected void |
EulerIntegratePosition(double dt)
Moves the Being by its velocity * the elapsed time dt . |
HRectangle |
getBoundingBox()
Gets the bounding box enclosing the Being 's shape. |
PVector |
getPosition()
|
HShape |
getShape()
|
PVector |
getVelocity()
|
float |
getVelocityX()
|
float |
getVelocityY()
|
float |
getX()
|
float |
getY()
|
boolean |
needsMoreSamples()
Used for multisampling -- if true the object needs to be sampled more on the current update. |
protected boolean |
processUpdate()
Used internally (needed for multi-sampling). |
protected void |
setDone(boolean done)
|
void |
setPosition(float x,
float y)
Sets the Being 's position to given x,y values. |
void |
setPosition(float x,
float y,
float z)
Sets the Being 's position to given x,y,z values. |
void |
setPosition(PVector position)
Sets the Being's new position. |
void |
setVelocity(PVector velocity)
Sets the Being 's velocity to a given vector. |
void |
setVelocityX(float x)
|
void |
setVelocityY(float y)
|
void |
setX(float x)
|
void |
setY(float y)
|
protected void |
step()
Updates the Being 's position, called for on each update, if multisampling is enabled will be for each sample. |
java.lang.String |
toString()
|
protected void |
update()
Override if Being should update itself on every game step |
protected long |
updateTime()
Updates the internal recorded time of the Being using the current system time. |
Methods inherited from class hermes.HObject |
---|
addToGroup, delete, getGroups, receive, receive, receive, receive, removeFromGroup |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected PVector _position
protected PVector _velocity
protected HShape _shape
protected long _time
Constructor Detail |
---|
public Being(HShape collisionShape, PVector velocity)
Being
. Should be called by a class that extends Being
.
collisionShape
- Shape used to determine Being
's position and collision detectionvelocity
- The Being
's initial velocity. Velocity gets updated automatically every timestep.public Being(HShape collisionShape)
Being
's velocity in 0, the World that it is in won't update the Being
's position automatically.
Thus, all motion must be handled through setX, setY, or setPosition.
Being
's velocity is later set to something other than 0,
it will then have its position updated automatically.
collisionShape
- Shape used to determine Being's position and collision detectionMethod Detail |
---|
protected long updateTime()
Being
using the current system time.
public void draw()
public HShape getShape()
Being
's shapepublic PVector getPosition()
Being
's positionpublic void setPosition(PVector position)
Note: this is a deep copy so the Being's position and its Shape's position will always be in sync.
position
- public void setPosition(float x, float y)
Being
's position to given x,y values.
x
- x positiony
- y positionpublic void setPosition(float x, float y, float z)
Being
's position to given x,y,z values.
x
- x positiony
- y positionz
- z position (at the currrent time a nonzero z may result in unexpected behavior)public float getX()
Being
's x positionpublic float getY()
Being
's y positionpublic void setX(float x)
x
- Being
's new x positionpublic void setY(float y)
y
- Being
's new y positionpublic PVector getVelocity()
Being
's velocitypublic float getVelocityX()
Being
's x velocitypublic float getVelocityY()
Being
's y velocitypublic void setVelocity(PVector velocity)
Being
's velocity to a given vector.
NOTE: this is a deep copy; changing velocity vector passed in after this call will have no effect on the Being.
velocity
- public void setVelocityX(float x)
x
- Being
's new x velocitypublic void setVelocityY(float y)
y
- Being
's new y velocitypublic HRectangle getBoundingBox()
Being
's shape.
Being
's shapeprotected void setDone(boolean done)
protected boolean processUpdate()
public boolean needsMoreSamples()
HObject
needsMoreSamples
in class HObject
protected void update()
Being
should update itself on every game step
protected void step()
Being
's position, called for on each update, if multisampling is enabled will be for each sample.
protected void EulerIntegratePosition(double dt)
Being
by its velocity * the elapsed time dt
.
dt
- the elapsed time to use for Euler integrationpublic java.lang.String toString()
toString
in class java.lang.Object
Being
, use for debugging
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |