Getting angle of joypad controller using Atan2?
Posted: Wed Sep 26, 2007 3:50 pm
Hi. I can't seem to get it working. I remember it being something like atan2(joyx, joyy) but it gives negative values sometimes 
(I know it returns radians and I need a value between 0..360)
Anyone here that can shed some light on the subject?
Thanks in advance
Update: Ahh, just forgot to add 360 if below zero
(I know it returns radians and I need a value between 0..360)
Anyone here that can shed some light on the subject?
Thanks in advance
Update: Ahh, just forgot to add 360 if below zero
Code: Select all
; Get angle of joypad controller
*ControllerData\Angle = atan2f(bbJoyX(ControllerID-1), bbJoyY(ControllerID-1)) * (180.0 / 3.14)
If (*ControllerData\Angle < 0)
*ControllerData\Angle = *ControllerData\Angle + 360
EndIf