我正在尝试制作游戏,并且我需要玩家(矩形)始终看着鼠标,我已经找到了一些关于此的页面,但我似乎无法理解数学。主要的:
g2d.rotate(calculateRotation, x,y);
g2d.fill(player);
g2d.rotate(-calculateRotation, x,y);
鼠标监听器:
int mx = e.getX();
int mY = e.getY();
float rotation = Math.atan((mouseX-playerX)/(mouseY-playerY)); //<--- I don't know