Skip to content

Instantly share code, notes, and snippets.

@md-5
Created July 19, 2012 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save md-5/3142861 to your computer and use it in GitHub Desktop.
Save md-5/3142861 to your computer and use it in GitHub Desktop.
REl move code
/**
* Moves the specified amount forwards and left in the current direction
* (calculated based on current yaw)
*
* @param forward, double sideways how far to move
* @param left how far to the left to move
*/
public void moveRelative(double forward, double left) {
final float yaw = getLocation().getYaw();
final double xToMove = forward * Math.cos(yaw) - left * Math.sin(yaw);
final double zTomove = forward * Math.sin(yaw) + left * Math.cos(yaw);
getLocation().setX(getLocation().getX() + xToMove);
getLocation().setZ(getLocation().getZ() + zTomove);
//
sendLocationUpdate();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment