Jump to content
  • Advertisement
Sign in to follow this  

Finding angle between 2 objects * SDL_RenderCopyEx

This topic is 2142 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!