No, I still can't figure how to do this using this method.
At the moment I'm doing it using some found code:
Code:
Local nDir:Float=ATan2(Player.Y+5-Y,Player.X+5-X)
nDir=(nDir+360-Dir) mod 360;
If nDir<=180
nDir:*0.05
Else
nDir=(nDir-360)*0.05
EndIf
dir:+nDir
But I'd like something faster (If something faster exists).
As I said I tried to write the code you mentioned, but hell, I really can't figure out anything to do with it. You say I have to make it range from -360 to 360, so I need two variables:
Code:
'dir is current Direction
'Sgn is of course Sign function
dir2=360*Sgn(-dir)+dir 'Ignore the situation when dir=0
ndir=ATan2(MouseY-Y,MouseX-X) 'range is -180 to 180
Now I tried to work a bit on it. I have two directions variables, so I wrote this code:
Code:
If ndir-dir>ndir-dir2
DrawText(Sgn(ndir-dir),100,100)
Else
DrawText(Sgn(ndir-dir2),100,100)
EndIf
So it should draw 1 when I have to turn clockwise, -1 if counter clockwise.
But it doesn't work. I'm pretty sure the code should look more or less like this, but I can't figure out what's wrong

.