Atan2 and aiming info.

Blitz3D Forums/Blitz3D Beginners Area/Atan2 and aiming info.

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I think that doesn't work because i get an "array index uot of bounds" because i store the frame anim in an array.
the function that i use to calculate the direction (based on your hints) is this:

a\angolo2=ATan2( a\cy - a\posizioney, a\cx - a\posizionex )
a\distanza=Sqr( (a\posizionex-a\cx)*(a\posizionex-a\cx)+(a\posizioney-a\cy)*(a\posizioney-a\cy) )
	a\posizionex=a\posizionex+(Cos(a\angolo2)/1)*(a\distanza / a\smoothness)
	a\posizioney=a\posizioney+(Sin(a\angolo2)/1)*(a\distanza / a\smoothness)
fotogramma = Floor(a\angolo2/iNumRotations)
DrawImage enemy,a\posizionex,a\posizioney,fotogramma


And the code for storing the anim is this:
Function LoadObject(ObjectName$,Rotations) 
 
  AutoMidHandle True


  imgTemp = LoadImage(ObjectName$)

  If imgTemp = 0
     Text 100,100,"Invalid Image!"    
  Else
     MaskImage imgTemp,0,0,0

     For iLoop=0 To Rotations-1
  ObjectFrames(iLoop)=CopyImage( imgTemp )

      
  RotateImage ObjectFrames(iLoop), iLoop*360/Rotations
     Next
  EndIf
End Function

I use 8 rotations so iNumRotations=8
The array is also 8 dephts....
I'm trying to do this because i have a path-finding function that find the various waypoints and also make a curve approximation (so the object don't follow blindly the waypoints but smoots them...).
And i don't know how to tell object what direction they are facing....
(non riesco a spiegarmi bene in inglese sorry...)