Class 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
    • Constructor Detail

      • MoveableEntity

        public MoveableEntity​(Vector2 position,
                              float radius,
                              Vector2 velocity,
                              float maxSpeed,
                              Vector2 heading,
                              float mass,
                              Vector2 scale,
                              float maxTurnRate,
                              float maxForce)
    • 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 X
        y - 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