rotation/direction

BlitzPlus Forums/BlitzPlus Beginners Area/rotation/direction

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.

Your English is fine. When you call CreateTank you don't need .Tank after the function name. .Tank is only needed in the function declaration. So you can do this:

Global tTank1.Tank = CreateTank(True,200,200)
It saves typing.

Anyway, to get frame 0 for angle -5 to 5 (where 0 is at the top, like a clock), we need to add on half of the number of "degrees per frame". 360/ANIM_FRAMES = degrees per frame. Then if the number is greater than 360, we have to keep it in the range 0 to 360, so we need to subtract 360 from it e.g. 362 changes to 362-360=2 degrees i.e. the first frame!

Adjusting my original code looks like this:

Const ANIM_FRAMES = 36
angle# = ATan2(my-y,mx-x) + 180 ;makes it in the range >0 to 360
;add on half the degrees per frame for accuracy
angle = angle + (360/ANIMFRAMES)/2
;Is angle too large now?
If angle > 360 then angle=angle-360
unit# = angle#/360 ;get in the range >0 to 1 as a float
finalframe% = Ceil(unit*ANIM_FRAMES)-1 ;round up and subtract 1 to get in range 0 to ANIM_FRAMES-1

And that's it I think. This is untested so I hope it works. Good luck.