Package de.gurkenlabs.litiengine.physics
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 java.lang.Object
implements IMovementController
Constructor Summary
Constructors Constructor Description MovementController(T mobileEntity)
Method Summary
Modifier and Type Method Description void
apply(Force force)
Apply the force to the entity.void
attach()
void
detach()
java.util.List<Force>
getActiveForces()
Gets the active forces.float
getDx()
Gets the delta x for each horizontal movement.float
getDy()
Sets the delta y for each vertical movement.T
getEntity()
Force
getForce(java.lang.String identifier)
double
getMoveAngle()
double
getVelocity()
Get the current velocity.void
handleMovement()
protected boolean
isMovementAllowed()
protected void
moveEntity(double deltaX, double deltaY)
void
onMovementCheck(java.util.function.Predicate<IMobileEntity> predicate)
Checks given conditions before moving.void
setDx(float dx)
Gets the delta x for each horizontal movement.void
setDy(float dy)
Sets the delta y for each vertical movement.void
setVelocity(double velocity)
Sets the current velocity.void
update()
This method is called by the game loop on all objects that are attached to the loop.
Constructor Details
Method Details
attach
public void attach()- Specified by:
attach
in interfaceIEntityController
detach
public void detach()- Specified by:
detach
in interfaceIEntityController
apply
Description copied from interface:IMovementController
Apply the force to the entity.- Specified by:
apply
in interfaceIMovementController
- Parameters:
force
- the force being applied to the entity
getActiveForces
Description copied from interface:IMovementController
Gets the active forces.- Specified by:
getActiveForces
in interfaceIMovementController
- Returns:
- the active forces
getEntity
- Specified by:
getEntity
in interfaceIEntityController
getDx
public float getDx()Description copied from interface:IMovementController
Gets the delta x for each horizontal movement.- Specified by:
getDx
in interfaceIMovementController
- 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 interfaceIMovementController
- 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 interfaceIMovementController
- 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 interfaceIMovementController
- Parameters:
dy
- the new dy
onMovementCheck
Description copied from interface:IMovementController
Checks given conditions before moving.- Specified by:
onMovementCheck
in interfaceIMovementController
- 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 theClientConfiguration
.- Specified by:
update
in interfaceIUpdateable
- See Also:
ClientConfiguration.setMaxFps(int)
handleMovement
public void handleMovement()getForce
- Specified by:
getForce
in interfaceIMovementController
getMoveAngle
public double getMoveAngle()- Specified by:
getMoveAngle
in interfaceIMovementController
setVelocity
public void setVelocity(double velocity)Description copied from interface:IMovementController
Sets the current velocity.- Specified by:
setVelocity
in interfaceIMovementController
- Parameters:
velocity
- The velocity to set.
getVelocity
public double getVelocity()Description copied from interface:IMovementController
Get the current velocity.- Specified by:
getVelocity
in interfaceIMovementController
- Returns:
- The current velocity.
moveEntity
protected void moveEntity(double deltaX, double deltaY)isMovementAllowed
protected boolean isMovementAllowed()