Render Tweening Question

Blitz3D Forums/Blitz3D Programming/Render Tweening Question

Gabriel(Posted 2004) [#1]
I need to leave a game loop which uses render tweening for a while and go into another loop which doesn't use any render tweening. When I return, if the non-tweening loop has taken a while, it messes up the tweening as the tweening tries to catch up. I've a feeling I just need to reset a couple of variables. I'm using the same setup that Mark used in the Castle demo, so using that, can anyone point out what variables I need to set to what when returning from the non-tweening loop?

Thanks..

Mark's / BlitzSupport's Code :

; ------------------------------------------------------------------
; 	GameCore -- support@...
; ------------------------------------------------------------------
; The basics of a frame-limited Blitz 3D game, ready to rock
; ------------------------------------------------------------------
;             Adapted from Mark Sibly's code
; ------------------------------------------------------------------



; ------------------------------------------------------------------
;	Game's frames-per-second setting
; ------------------------------------------------------------------

Global gameFPS = 50

; ------------------------------------------------------------------
;	Open 3D display mode
; ------------------------------------------------------------------

Graphics3D 640, 480

; ------------------------------------------------------------------
; Single camera setup
; ------------------------------------------------------------------

cam = CreateCamera ()
CameraViewport cam, 0, 0, GraphicsWidth (), GraphicsHeight ()

; ------------------------------------------------------------------
; General setup
; ------------------------------------------------------------------

; Load and arrange objects, textures, etc here...

	; Quick example (just delete this)...
	
	Global box = CreateCube ()
	MoveEntity box, 0, 0, 5

; ------------------------------------------------------------------
;	Frame limiting code setup
; ------------------------------------------------------------------

framePeriod = 1000 / gameFPS
frameTime = MilliSecs () - framePeriod

Repeat

	; --------------------------------------------------------------
	; Frame limiting
	; --------------------------------------------------------------

	Repeat
		frameElapsed = MilliSecs () - frameTime
	Until frameElapsed

	frameTicks = frameElapsed / framePeriod
	
	frameTween# = Float (frameElapsed Mod framePeriod) / Float (framePeriod)

	; --------------------------------------------------------------
	; Update game and world state
	; --------------------------------------------------------------
	
	For frameLimit = 1 To frameTicks
	
		If frameLimit = frameTicks Then CaptureWorld
		frameTime = frameTime + framePeriod
		
		UpdateGame ()

		UpdateWorld
			
	Next

	; --------------------------------------------------------------
	; **** Wireframe for DEBUG only -- remove before release! ****
	; --------------------------------------------------------------
		
	If KeyHit (17): w = 1 - w: WireFrame w: EndIf ; Press 'W'
	
	; --------------------------------------------------------------
	; Draw 3D world
	; --------------------------------------------------------------

	RenderWorld frameTween

	; --------------------------------------------------------------
	; Show result
	; --------------------------------------------------------------

	Flip

Until KeyHit (1)

End

; ------------------------------------------------------------------
; Game update routine, called from frame limiting code
; ------------------------------------------------------------------

Function UpdateGame ()

	; Get keypresses, move entities, etc

	; EXAMPLE CODE -- REMOVE! Uses cursors...
	If KeyDown (203) TurnEntity box, 0, 0.5, 0
	If KeyDown (205) TurnEntity box, 0, -0.5, 0
	
End Function




Bouncer(Posted 2004) [#2]
Try captureworld() at the end of the loop you are returning from. This should correct the flashing of gfx, when you return. Didn't test it... just an idea.


John Blackledge(Posted 2004) [#3]
Try:
frameTime = MilliSecs ()
when you return from your other routine.