Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 0.36 KB  |  views: 193  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public void update(GameContainer container, StateBasedGame game, int delta) {
  2.         float mouseX = container.getInput().getMouseX();
  3.         float mouseY = container.getInput().getMouseY();
  4.         float xDistance = mouseX - position.x;
  5.         float yDistance = mouseY - position.y;
  6.         double angle = Math.toDegrees(Math.atan2(yDistance, xDistance));
  7.         gun.setRotation((float) angle);
  8. }
clone this paste RAW Paste Data