FrameTimer Questions

Blitz3D Forums/Blitz3D Beginners Area/FrameTimer Questions

I just learned about frametimers (which probably explains my problem with the speed on other people's computers). Sometimes things that are moving will sort of "jump" and not be smooth. Is this because my frametimer is too low of a number (it's 200 right now)? And why does the game go faster when the number is higher? I though it was supposed to be counting up to that number?

A frametimer will control the execution speed of your program (frames per second) so higher will make it faster. 200 may be too fast as some slower computers will take longer to reach that "200" delay.

A better way to control the framerate is to use render tweening. Heres a basic example...

Const framerate = 50

Graphics3D 1024,768,16,1
SetBuffer BackBuffer()

period = 1000 / framerate
time = MilliSecs() - period

While Not KeyHit(1)

	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
		
		; main game loop goes here -------------------->
		
		
		
		UpdateWorld
	Next
	
	RenderWorld tween
	Flip
Wend
End


You will find that using render tweening will be much more reliable for keeping the game speed at a set rate and will keep the display smooth.

Another games code I was looking at used this method. I'll have to try some different ways and run it on my slow laptop to see what's best. I'll probably use this way though, since it seems the best. Thanks!

I prefer tweening also, but note that you can not 'teleport' objects because they will always 'slide' to the new location. If this is a consideration, consider using 'delta' timing (do a search, their are lots of posts about it).

Rhy :)