Jump to content
  • Advertisement
Sign in to follow this  


This topic is 4096 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

Hi! I'm trying to make my main menu look more professional ,and i have some ideas that i can't compete them without some help. What im trying to do is , to make an object follow the mouse. Thats easy..right? Well,the truth is that im having problem with the rotation. How can i make the object to point at a given coordinates(x,y) ? example: Button1 is at (x)300,(y)450 Button2 is at (x)300,(y)500 Button3 is at (x)300,(y)550 Mouse is at 10,10 Our object(lets name it cursor) is at (x)300,(y)450 The user moves the mouse at button1. Some pseudo-code:

if (collide(mouse,button1))//mouse is over button1
//thats easy....

//Here , some how , i have to rotate the cursor to point button1!

So ,how can i rotate the object with GLROTATE, so that it will point the selected button?

Share this post

Link to post
Share on other sites
Standard library cmath has a function called "atan2"

float atan2(float x, float y);
You pass relative position as x and y and you get angle.

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!