heres my problem.
Im making a tank game in allegro, and i want the turret to always point towards the mouse pointer
i have a forumla to work out the angle, to rotate too, somthing like this:
a=pow(sin((y_dist / x_dist)/180),-1);
//Basically the same as
a=sin^-1(y_dist / x_dist)
unfortunatly, its not working.
dose anyone know the correct formula / another way to work out the angles (in c/c++ format)
thanks
edit: god damnit, you should really have an option to turn off smileys for a post
try atan2(abs(y1-y2),abs(x1-x2)) ... allegro should have its own function for this, but failing that just use the math.h one
I dunno how that formula is supposed to work but if you're sure its a real one then you're probably using the wrong type of angle measurement (sin() probably uses radians rather than degrees)
Edited by the Author.
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G
Inverse Sine/ArcSine doesn't mean Sine^-1. That formula is wrong anyway (assuming the variables are named appropriately), use what Kris wrote (without the abs though).
Kris: Don't use abs() that'll prevent it getting the correct angle.
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G
are you checking your angle measurements like i said?
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G
dunno what else it could be, could you show your code?
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G