Skip to content

Instantly share code, notes, and snippets.

@BobTheBuilderBot
Created September 24, 2012 10:01
Show Gist options
  • Select an option

  • Save BobTheBuilderBot/3775243 to your computer and use it in GitHub Desktop.

Select an option

Save BobTheBuilderBot/3775243 to your computer and use it in GitHub Desktop.
@Override
public void update(float tpf) {
camDirection = camera.getDirection().clone().multLocal((playerCharacter.getVelocity()));
camLeft = camera.getLeft().clone().multLocal((playerCharacter.getVelocity()));
camDirection.setY(0); camLeft.setY(0);
walkDirection.set(0, 0, 0);
for(Direction direction : inputDirection) {
switch(direction) {
case Left:
walkDirection.addLocal(camLeft);
break;
case Right:
walkDirection.addLocal(camLeft.negate());
break;
case Forward:
walkDirection.addLocal(camDirection);
break;
case Backward:
walkDirection.addLocal(camDirection.negate());
break;
}
playerCharacter.action(new MoveAction(characterControl.getPhysicsLocation()));
}
inputDirection.clear();
characterControl.setWalkDirection(walkDirection);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment