Atan2 can output the angle between two points on the screen if you supply the difference between them - this angle can be seen as 'how much object A has to rotate to face object B' (the Blitz3D documentation on this command is a bit more thorough than the BlitzMax one):
'At the initialization part of your code.
MidHandleImage Image 'Handle your image by the center.
'[...]
'At render time:
SetRotation( Atan2( MouseY() - ImageY, MouseX() - ImageX) )
DrawImage Image,ImageX,ImageY 'ImageX and ImageY are the coordinates you use to center your image on the screen.
Tell me if that works. You might need to add a certain offset to the value returned by Atan2 (like -90 or something like that), if your image spins with the cursor but is facing the wrong way.
Last edited 2011
|