New position X and Y depending on direction and distance?

Asked

Viewed 46 times

1

I’m doing a mini shooting game on XNA but I’m not able to imagine how to calculate the following:

Knowing the position of the center of the image, the direction in which it is pointing and the distance between the center and the "beak" of the gun, how to know the position X and Y of the beak of the gun?

1 answer

3

I found the answer:

newX = X + (raio) * cos⁡(ang);
newY = Y + (raio) * sin(ang);

Source: Click here

Browser other questions tagged

You are not signed in. Login or sign up in order to post.