public void update(GameContainer container, StateBasedGame game, int delta) {
float mouseX = container.getInput().getMouseX();
float mouseY = container.getInput().getMouseY();
float xDistance = mouseX - position.x;
float yDistance = mouseY - position.y;
double angle = Math.toDegrees(Math.atan2(yDistance, xDistance));
image.setRotation((float) angle);
}

The gun does rotate, but only at half the speed of me moving the mouse, and when I move the mouse to the other side of the gun it starts rotating the other way. Does someone know what could of gone wrong? Thanks…