MovementState movementState = character.getMoveState();
switch (movementState) {
case MOVE_CHANGE_DIR:
MovePlayerAction movePlayerActionChangeDir = new MovePlayerAction(channel, channels);
this.actionQueue.addAction(movePlayerActionChangeDir);
character.setMoveState(MovementState.MOVE_KEEP_DIR);
break;
case MOVE_KEEP_DIR:
// Only move the player each 250ms (if the direction is kept)
if ((new Date().getTime() - character.getLastHeartBeat().getTime()) > 250) {
MovePlayerAction movePlayerActionKeepDir = new MovePlayerAction(channel, channels);
this.actionQueue.addAction(movePlayerActionKeepDir);
}
break;
case NOT_MOVING_UNHANDLED:
MovePlayerAction movePlayerActionUnhandled = new MovePlayerAction(channel, channels);
this.actionQueue.addAction(movePlayerActionUnhandled);
// Calculate the rotation
character.setRotation((float)Math.atan2(character.getDirection().getY(), character.getDirection().getX()));
RotatePlayerAction rotatePlayerAction = new RotatePlayerAction(channel, channels);