Package com.tenio.engine.physic.common
Class MoveableEntity
- java.lang.Object
-
- com.tenio.logger.AbstractLogger
-
- com.tenio.engine.fsm.entities.AbstractEntity
-
- com.tenio.engine.physic.common.BaseGameEntity
-
- com.tenio.engine.physic.common.MoveableEntity
-
public abstract class MoveableEntity extends BaseGameEntity
A base class defining an entity that moves. The entity has a local coordinate system root(0, 0) and members for defining its mass and velocity.- Author:
- kong
-
-
Field Summary
-
Fields inherited from class com.tenio.engine.physic.common.BaseGameEntity
DEFAULT_ENTITY_TYPE
-
-
Constructor Summary
Constructors Constructor Description MoveableEntity(Vector2 position, float radius, Vector2 velocity, float maxSpeed, Vector2 heading, float mass, Vector2 scale, float maxTurnRate, float maxForce)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Vector2
getHeading()
float
getHeadingX()
float
getHeadingY()
float
getMass()
float
getMaxForce()
float
getMaxSpeed()
float
getMaxTurnRate()
float
getRotation()
Vector2
getSide()
float
getSideX()
float
getSideY()
float
getSpeed()
float
getSpeedSqr()
Vector2
getVelocity()
float
getVelocityX()
float
getVelocityY()
boolean
isRotatedHeadingToFacePosition(Vector2 target)
Given a target position, this method rotates the entity's heading and side vectors by an amount not greater than m_dMaxTurnRate until it directly faces the target.boolean
isSpeedMaxedOut()
void
setHeading(float x, float y)
First checks that the given heading is not a vector of zero length.void
setHeading(Vector2 heading)
void
setMaxForce(float maxForce)
void
setMaxSpeed(float maxSpeed)
void
setMaxTurnRate(float maxTurnRate)
void
setVelocity(float x, float y)
void
setVelocity(Vector2 velocity)
-
Methods inherited from class com.tenio.engine.physic.common.BaseGameEntity
enableTag, getBoundingRadius, getPosition, getPositionX, getPositionY, getScale, getScaleX, getScaleY, getType, isTagged, setBoundingRadius, setPosition, setPosition, setScale, setScale, setScale, setType
-
Methods inherited from class com.tenio.engine.fsm.entities.AbstractEntity
getId, handleMessage, setId, update
-
-
-
-
Method Detail
-
getVelocityX
public float getVelocityX()
-
getVelocityY
public float getVelocityY()
-
getVelocity
public Vector2 getVelocity()
-
setVelocity
public void setVelocity(float x, float y)
-
setVelocity
public void setVelocity(Vector2 velocity)
-
getHeadingX
public float getHeadingX()
-
getHeadingY
public float getHeadingY()
-
getHeading
public Vector2 getHeading()
-
setHeading
public void setHeading(float x, float y)
First checks that the given heading is not a vector of zero length. If the new heading is valid this function sets the entity's heading and side vectors accordingly- Parameters:
x
- the new heading in Xy
- the new heading in Y
-
setHeading
public void setHeading(Vector2 heading)
-
getSideX
public float getSideX()
-
getSideY
public float getSideY()
-
getSide
public Vector2 getSide()
-
getRotation
public float getRotation()
-
getMass
public float getMass()
-
getMaxSpeed
public float getMaxSpeed()
-
setMaxSpeed
public void setMaxSpeed(float maxSpeed)
-
getMaxForce
public float getMaxForce()
-
setMaxForce
public void setMaxForce(float maxForce)
-
isSpeedMaxedOut
public boolean isSpeedMaxedOut()
-
getSpeed
public float getSpeed()
-
getSpeedSqr
public float getSpeedSqr()
-
getMaxTurnRate
public float getMaxTurnRate()
-
setMaxTurnRate
public void setMaxTurnRate(float maxTurnRate)
-
isRotatedHeadingToFacePosition
public boolean isRotatedHeadingToFacePosition(Vector2 target)
Given a target position, this method rotates the entity's heading and side vectors by an amount not greater than m_dMaxTurnRate until it directly faces the target.- Parameters:
target
- the new target vector- Returns:
- true when the heading is facing in the desired direction
-
-