문제

So I have a Java2D game when I have to rotate a cannon to the mouse's direction and save the angle. It works but I have the real issue. I can't calculate correct X and Y velocity from this answer i got from this equation:

double angle = Math.atan2(centerY - c.mouseY, centerX - c.mouseX) - Math.PI / 2;

then i use this equation:

int x = (int) Math.acos(c.rotation*Math.PI/180);
int y = (int) Math.sin(c.rotation*Math.PI/180);

I don't get the right velocity for y. can you guys help me?

도움이 되었습니까?

해결책

Maybe because your using cosine when calculating y value. Shouldn't it be sine?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top