Frame Limiting?

Blitz3D Forums/Blitz3D Programming/Frame Limiting?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I was just wondering about this... I usually fall on the delta timing side of things. The method in mark's castle demo can have some very bad results for people with slow pcs (I have experience :P). However, there doesn't seem to be much of a difference between delta timing and render tweening. Render tweening is just automated. I guess the main difference is that using delta timing, you can move an entity, and then perform tests on the entities position and orientation, correcting collision errors, etc. Which leads me to a question - if render tweening is performed by renderworld, then wouldn't collisions be a bit wierd? If tween# was ever greater than 1 then objects would penetrate. This is all hypothetical of course, I'm to lazy to test it.

Okay - here's a method that might be pretty good. It's a modification of mark's castle demo timing system:(untested -oh and also this is from a visual blitz template so it might have a few other mods as well.)
Const LowestRenderRate=15
Const RenderPeriod=1000/LowestRenderRate
Const UPS=60
Const period=1000/UPS

Graphics3D 640,480,32,2

time=MilliSecs()-period

Repeat
	m=MilliSecs()
	Repeat
		elapsed=MilliSecs()-time
	Until elapsed

	ticks=elapsed/period
	tween#=Float(elapsed Mod period)/Float(period)
	
	For k=1 To ticks
		time=time+period

		If k=ticks Then CaptureWorld

		If KeyHit(1) End
		updategame
		UpdateWorld
		If (m-MilliSecs)>RenderPeriod Then time=MilliSecs():Exit
	Next

	RenderWorld tween
	Flip
Forever


Basically, this makes it render at least 15 frames per second. Which prevents a downward spiral on crap computers in which every frame is further apart.