exiting animation loop

Blitz3D Forums/Blitz3D Programming/exiting animation loop

Something like this should show you how it would work.
Graphics3D 640,480,0,2
SetBuffer BackBuffer()

camera=CreateCamera()
PositionEntity camera,0,20,-100 ; position camera so that robot will be in view when loaded

AmbientLight 132,132,132
light=CreateLight()
LightRange light,20
RotateEntity light,90,0,0

; Load anim mesh
robot = LoadAnimMesh("media\makbot\mak_running.3ds")
anim0 = 0
anim1 = LoadAnimSeq(robot,"media\makbot\mak_robotic.3ds")

Animate robot,1,1,anim1,10.0

While Not KeyDown(1)
	TurnEntity robot,0,1,0
	UpdateWorld 
	RenderWorld 

	If KeyHit(57) ; If space is hit
		IWantToRun = True
	End If

	; Show which frame of total we are showing
	Text 0,0,AnimTime(robot)+" of "+AnimLength(robot)
	
	; If this is the last frame
	If AnimTime(robot) => AnimLength(robot)-1
		Text 0,10,"Animation Re-Started"
		
		; Switch to running
		If IWantToRun = True
			Animate robot,1,1,anim0,10.0
			IWantToRun = False
		End If
	End If

	; If we should switch to running
	If IWantToRun = True
		Text 0,20,"I Want To Run, but I can't until this animation sequence is done!"
	End If
	
	Flip
Wend