Class MovementController<T extends IMobileEntity>

java.lang.Object
de.gurkenlabs.litiengine.physics.MovementController<T>
All Implemented Interfaces:
IEntityController, IUpdateable, IMovementController
Direct Known Subclasses:
GamepadEntityController, KeyboardEntityController, MousePathController

public class MovementController<T extends IMobileEntity> extends Object implements IMovementController
  • Constructor Details

    • MovementController

      public MovementController(T mobileEntity)
  • Method Details

    • attach

      public void attach()
      Specified by:
      attach in interface IEntityController
    • detach

      public void detach()
      Specified by:
      detach in interface IEntityController
    • apply

      public void apply(Force force)
      Description copied from interface: IMovementController
      Apply the force to the entity.
      Specified by:
      apply in interface IMovementController
      Parameters:
      force - the force being applied to the entity
    • getActiveForces

      public List<Force> getActiveForces()
      Description copied from interface: IMovementController
      Gets the active forces.
      Specified by:
      getActiveForces in interface IMovementController
      Returns:
      the active forces
    • getEntity

      public T getEntity()
      Specified by:
      getEntity in interface IEntityController
    • getDx

      public float getDx()
      Description copied from interface: IMovementController
      Gets the delta x for each horizontal movement.
      Specified by:
      getDx in interface IMovementController
      Returns:
      the dx
    • setDx

      public void setDx(float dx)
      Description copied from interface: IMovementController
      Gets the delta x for each horizontal movement.
      Specified by:
      setDx in interface IMovementController
      Parameters:
      dx - the new dx
    • getDy

      public float getDy()
      Description copied from interface: IMovementController
      Sets the delta y for each vertical movement.
      Specified by:
      getDy in interface IMovementController
      Returns:
      the dy
    • setDy

      public void setDy(float dy)
      Description copied from interface: IMovementController
      Sets the delta y for each vertical movement.
      Specified by:
      setDy in interface IMovementController
      Parameters:
      dy - the new dy
    • onMovementCheck

      public void onMovementCheck(Predicate<IMobileEntity> predicate)
      Description copied from interface: IMovementController
      Checks given conditions before moving.
      Specified by:
      onMovementCheck in interface IMovementController
      Parameters:
      predicate - the conditions that need to apply before moving. If they don't apply, the entity won't be moved.
    • update

      public void update()
      Description copied from interface: IUpdateable
      This method is called by the game loop on all objects that are attached to the loop. It's called on every tick of the loop and the frequency can be configured using the ClientConfiguration.
      Specified by:
      update in interface IUpdateable
      See Also:
    • handleMovement

      public void handleMovement()
      Handles the movement of the entity. This method calculates the new velocity and direction of the entity based on the current forces and movement predicates. It also updates the entity's position accordingly.
    • getForce

      public Force getForce(String identifier)
      Description copied from interface: IMovementController
      Gets the force with the specified identifier.
      Specified by:
      getForce in interface IMovementController
      Parameters:
      identifier - the identifier of the force to retrieve
      Returns:
      the force with the specified identifier
    • getMoveAngle

      public double getMoveAngle()
      Description copied from interface: IMovementController
      Gets the angle of movement.
      Specified by:
      getMoveAngle in interface IMovementController
      Returns:
      the angle of movement
    • setVelocity

      public void setVelocity(double velocity)
      Description copied from interface: IMovementController
      Sets the current velocity.
      Specified by:
      setVelocity in interface IMovementController
      Parameters:
      velocity - The velocity to set.
    • getVelocity

      public double getVelocity()
      Description copied from interface: IMovementController
      Get the current velocity.
      Specified by:
      getVelocity in interface IMovementController
      Returns:
      The current velocity.
    • moveEntity

      protected void moveEntity(double deltaX, double deltaY)
    • isMovementAllowed

      protected boolean isMovementAllowed()
      Checks if the movement is allowed based on the movement predicates.
      Returns:
      true if all movement predicates allow movement, false otherwise