I'm trying to make a game and I need the player(rectangle) to always be looking at the mouse, I have found some pages on this but I can't seem to understand the math. Main:
g2d.rotate(calculateRotation, x,y);
g2d.fill(player);
g2d.rotate(-calculateRotation, x,y);
Mouse Listener:
int mx = e.getX();
int mY = e.getY();
float rotation = Math.atan((mouseX-playerX)/(mouseY-playerY)); //<--- I don't know