Stumbled Upon this Timing Method

Blitz3D Forums/Blitz3D Programming/Stumbled Upon this Timing Method

Chroma(Posted 2007) [#1]
I was messing around with trying to come up with another way to do fixed rate logic with render tweening in Blitz3D and came up with this. Please tell me if it sucks or if it's a hit. It seems to run freaking awesome and smooth as hell here. I can't find any flaws in it. It's based on Gaffer's fixed rate logic stuff and the tweening example in the archives.

Const dt# = 1.0 / 50.0	;(50 FPS Logic)
Local newTime% = MilliSecs()
Local oldTime = newTime - 1
Local accumulator#, deltaTime#, alpha#, t#

While Not KeyHit(1)
Cls

	newTime = MilliSecs()
	deltaTime = (newTime - oldTime) * 0.001
	oldTime = newTime
	
	accumulator = accumulator + deltaTime

	While accumulator >= dt
		CaptureWorld
		Update_GameLogic(dt)
		accumulator = accumulator - dt
		t = t + dt
	Wend
	
	alpha = accumulator / dt
    
	RenderWorld alpha

	Flip False
Wend
EndGraphics
End




Chroma(Posted 2007) [#2]
I think the final problem is that I have a particle engine that reuses sprites from a pool. The CaptureWorld and RenderWorld are tween the sprites and causing them to appear at odd places.

Is there a way to not tween an entity while using CaptureWorld?


Vorderman(Posted 2007) [#3]
Yes, very easily - just update its position/orientation right before the Captureworld, which will make it appear to jump straight to the new position and ignore the tweening.