if (collide(mouse,button1))//mouse is over button1
{
//thats easy....
cursor.y=button1.y-button1.h/2
cursor.x=button1.x-button1.w-cursor.w/2
//Here , some how , i have to rotate the cursor to point button1!
cursor.rotate(blah?)
}
[OpenGL]-GLROTATE
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:
So ,how can i rotate the object with GLROTATE, so that it will point the selected button?
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.
float atan2(float x, float y);
You pass relative position as x and y and you get angle.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement