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.

Hum, thats odd. Are you sure your loading your image correctly? This works fine on my computer....

Test.png should be a 32x32 image with 3 frames.

Type TAnimation
	Field Image:TImage, X:Int, Y:Int
	Field Frames:Int[] = [0,1,2,2,1,0]
	Field CurrFrame:Int
	Field AnimTimer:Int = MilliSecs()
	Field AnimSpeed:Int = 250

	Method Update()
		If MilliSecs() - AnimTimer > AnimSpeed Then AnimTimer = MilliSecs() ; CurrFrame:+1
		If CurrFrame > Frames.Length - 1 Then CurrFrame = 0
	End Method

	Method Render()
		DrawImage Image,X,Y,Frames[CurrFrame]
	End Method
End Type

Graphics 800,600,0,60

Local Anim:TAnimation = New TAnimation
Anim.Image = LoadAnimImage("Test.png",32,32,0,3)

Repeat
	Anim.Update()
	Anim.Render()
	Flip;Cls
Forever