Hi, I’m currently learning to use opengl and I am trying to get my sprite to rotate around it’s center, at the moment it seems to be rotating around the top left corner doing a huge circle in(and out) of the screen.
Question1: How can I get the sprite to rotate around it’s center?
Also, I’m trying to get the sprite to rotate to face where the mouse is positioned. I did a bit of searching and found a solution to get the angle of 2 points, but It doesnt seem to be working very well…
Question2: How can I get a sprite to follow(by rotating) the mouse position?
Current code to get the angle between mouse and sprite:
x1 = ship.x+50;
y1 = ship.y+50;
x2 = Mouse.getX();
y2 = Mouse.getY();
angle = Math.atan2(y1 - y2, x1 - x2) * 360/ Math.PI*-1;