newton physics time

BlitzMax Modules Forums/MiniB3D/newton physics time

it is a bit buggy

try this instead:

        Field accumulator:Float
	Field lastupdate:Int = MilliSecs()
	Field updates:Int

        Method Update(UpTime:Float = - 1.0) 
		
		Local Time:Int = MilliSecs()

		If  Uptime < 0 Then
			NewtonUpdate(World , GetDelta() ) 
		Else
			NewtonUpdate(World , Uptime ) 
		EndIf
	End Method
	
	Method AccuUpdate()
		GCSuspend()
		accumulator:+ Min(MilliSecs() - lastupdate,60)/1000.0
		lastupdate = MilliSecs() 
		
		updates:Int = 0
		While accumulator >= dt
			Update(dt) 
			accumulator:- dt
			updates:+1
		Wend
		GCResume()
	End Method