Maybe because your using cosine when calculating y value. Shouldn't it be sine?
Calculate X and Y velocity from image rotation of mouse
Question
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?
La solution
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow