Answer the question
In order to leave comments, you need to log in
Find the x and y coordinates of a corner?
In the game, by clicking left or right, I change the angle, along with this, the picture rotates in the right direction. But the problem arises when I want to move the sprite forward. Need coordinates for x and y. I need this to move the sprite to the next x and y coordinates
. Note that this method is not suitable.
pd.x = 180 * cos ( angle ) + pd.x + 64;
pd.y = 180 * sin ( angle ) + pd.y + 64;
Answer the question
In order to leave comments, you need to log in
pd.x += sin ( angle ) * 64;
pd.y += cos ( angle ) * 64;
Most likely so. If the angle is in degrees, then you need to convert to radians to calculate the sine and cosine:
pd.x += sin ( angle / 180. * pi ) * 64;
pd.y += cos ( angle / 180. * pi ) * 64;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question