Jump to content

View more

Image of the Day

The beast has a mighty searchlight of evil! #screenshotsaturday https://t.co/bzKepOojDL
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Finding angle between 2 objects * SDL_RenderCopyEx

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
No replies to this topic

#1 ChainedHollow   Members   

158
Like
0Likes
Like

Posted 05 December 2013 - 05:12 AM

Nvm I fixed my issue with finding the angle between 2 objects and using it with SDL_RenderCopyEx();

 

Here is my function:

 

double find_angle(float x1, float x2, float y1, float y2)
{
double degrees;
 
// Get the angle between point (x1,y1) and (x2,y2)
degrees = atan2(y2 - y1, x2 - x1) * 180/PI;
 
return degrees;
}
 
and the call:
 
angle = find_angle(target.y, y, x, target. x);
 
Im not sure why its working since the variables are mixed up where they are supposed to be, but I kept trying them in different positions and its working,

Edited by ChainedHollow, 05 December 2013 - 05:28 AM.





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.