Converting vector to angle

BlitzPlus Forums/BlitzPlus Programming/Converting vector to angle

schilcote(Posted 2011) [#1]
I have a little spaceship that flies around, and I want its sprite to rotate to face its direction of movement. I know the answer lies in the Atan2() function, but that's about it. I've tried writing the code to do it, but it didn't work at all (it just made my ship graphic into a blurry little circle).

The ships velocity is stored in an xvel variable and a yvel variable. I need to convert this vector into an angle which I can feed into RotateImage().


Serpent(Posted 2011) [#2]
Atan2(yvel, xvel) should work perfectly, but you can't hope to use RotateImage() in realtime...


schilcote(Posted 2011) [#3]
I've always found that it works just fine in realtime. Hmm. I guess I just have a fast computer.