Frame limiting

BlitzMax Forums/BlitzMax Programming/Frame limiting

Example:

Set Your Globals
Global Delta1:DeltaTime = DeltaTime.Create(35.0) ' Normal 35 FPS
Global Delta:Double


Now Main Game Loop
While Not EXIT_FLAG

	DeltaTime.Update()
	Delta = DeltaTime.CurrDelta(Delta1)
	If Delta > 1 Then Delta = 1 ' Delta should never be bigger than 1.
	
	' -------------------------------GFX FUNCTIONS ---------------------------
	ScreenUpdate = ScreenUpdate + Delta
	
	ScreenX.Update(Delta)
	
	If ScreenUpdate > 0.30 Then
		RenderGFX()
		ScreenUpdate = 0
		Timer.UpdateAll()
	EndIf	
	' ------------------------------------------------------------------------
	
	UpdateGame(delta)
	ActiveChannel.UpdateAll()	
	FlushMem
	Delay(1)
	
Wend


Multiply all movements and animations etc by Delta.