Elegant system for doing sprite animations?

BlitzMax Forums/BlitzMax Programming/Elegant system for doing sprite animations?

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.

something like this should do it.

type foo
field image:TImage =...
field animspeed:long = 60
field lasttime:long = 0
field curframe:int = 0
field frameorder:int[] = [0,1,0,2,2,3,4,5,0,2];

method update(curtime:long)
 if curtime-lasttime>=animspeed then curframe:+1
 if curframe>frameorder.length then curframe=0
 lasttime = curtime
endmethod

method display()
 drawimage image,x,y,frameorder[curframe]
endmethod
end type