Player Movement help needed

Blitz3D Forums/Blitz3D Beginners Area/Player Movement help needed

well firstly create an animation strip with the left and right animation in it. say 3 frames from moving right and 3 frames for moving left.

move left frames: 0-2
move right frames:3-5

then have a direction variable

dir=0; character is moving left

dir=1; character is moving right

then have a variable to keep track of the frames

frame=0


Graphics 800,600 
SetBuffer BackBuffer() 

player=LoadAnimImage("player.png",24,24,0,6) 

dir=0; direction the player is going 
frame=0; what frame of animation the player is on 
speed=1; the walking speed of the player 

While Not KeyHit(1) 
	Cls
	
	If KeyDown(203) Then 
		If dir=3 Then; if player was moving right then change his direction 
			frame=0; set the frame back to zero 
			dir=0; set direction to left 
		Else 
			frame=frame+1 
			If frame=3 Then frame=0;if frame goes past 2 then reset to 0 
			x=x-speed 
		End If 
	ElseIf KeyDown(205) Then 
		If dir=0 Then; if player was moving left then change his direction 
			frame=0; set the frame back to zero 
			dir=3; set direction to right 
		Else 
			frame=frame+1 
			If frame=3 Then frame=0;if frame goes past 2 then reset to 0 
			x=x+speed 
		End If 
	Else 
		If dir=0 Then frame=0 
		If dir=3 Then frame=0 
	End If 
	
	DrawImage player,x,y,dir+frame 
	Delay 200
	
	Flip

Wend
End


the dir variable is used as a marker for which frame is in use and to determine which way the man is player is facing

hope this helps some. there's alot better ppl out there that could prob explain this better but i hope it helps none the less. if u wanna run this mind you need a png image with 6 frames, each at 24x24
:D