Multiple animations for a single image

BlitzPlus Forums/BlitzPlus Beginners Area/Multiple animations for a single image

Ethan(Posted 2013) [#1]
Hello,
I want to do more than just 1 animation. So for example my character walks right and I only have its walk left animation. I also noticed that when you set up the LoadAnimImage that there is this zero here. gfxgrav=LoadAnimImage("gravity well.bmp",50,100,0,36)
The zero at ,50,100,0,36 what is for so I just leave it zero. Can anyone help?


GfK(Posted 2013) [#2]
The zero is the index of the first frame in the image you want to load (they start at 0, not 1).

I'm not sure if there is any way in BlitzPlus of procedurally flipping an image. Assuming not, you'd have to manually make right-facing copies in a paint program.


Ethan(Posted 2013) [#3]
No I mean that I only know how to do one animation for one sprite at a time.


_PJ_(Posted 2013) [#4]
I think I understand what you mean...
This should give you some help. Essentially, you need to know which frames (of which image if separate Images are loaded in for some anim sequences) are the starting points for the Animations, and how many frames per animation (Naturally, this can be made a lot simpler,. if you use the same number of frames per animation sequence but it's not necessary)
Const TOTAL_FRAMES=11
Const WALK_LEFT_FRAMES=5
Const WALK_RIGHT_FRAMES=5
Const JUMP_FRAMES=5
Const IDLE_FRAMES=1

Const WALK_LEFT_START=1
Const WALK_RIGHT_START=6
Const IDLE_START=0

Const FRAME_WIDTH=32
Const FRAME_HEIGHT=32

Graphics 800,600,32,2
SetBuffer(BackBuffer())

Global AnimImage=LoadAnimImage(CurrentDir()+"MyAnimImage.bmp",FRAME_WIDTH,FRAME_HEIGHT,0,TOTAL_FRAMES)

Global THIS_ANIM_FRAMES
Global THIS_ANIM_START
Global ANIM_TIME
While Not KeyDown(1)
	
	AnimTimer=(MilliSecs()-ANIM_TIME)*0.002
	AnimTimer=AnimTimer Mod THIS_ANIM_FRAMES
	Cls
	DrawImage AnimImage,0,0,THIS_ANIM_START+AnimTimer
	Flip
Wend

Function Movement() 
	Local MoveMent=KeyDown(KEY_RIGHT)-KeyDown(KEY_LEFT)		
	Local OldAnim=THIS_ANIM_START
	
	THIS_ANIM_FRAMES=((Movement=0)*IDLE_FRAMES)+(WALK_LEFT_FRAMES*(Movement<0))+(WALK_RIGHT_FRAMES*(Movement>0))
	THIS_ANIM_START=((Movement=0)*IDLE_START)+(WALK_LEFT_START*(Movement<0))+(WALK_RIGHT_START*(Movement>0))
	
	If (THIS_ANIM_START<>OldAnim)
		ANIM_TIME=MilliSecs()
	End If
	
End Function



Ethan(Posted 2013) [#5]
Thanks so much PJ! that's what i meant.