Catch game up to missed frames realtime?

Blitz3D Forums/Blitz3D Beginners Area/Catch game up to missed frames realtime?

Kippykip(Posted 2015) [#1]
I would like this program to rotate the cube the same speed with different frame-rates
It works but it's not realtime, it's measured in seconds and I don't know another way without lowering the "FPS_MilliCount >= 1000" part and lowering the "sync#=60/FPS_Current#" but that gets very inaccurate

;Catchup test
;Left click caps to 60
;Left click caps to 30
;Box should rotate at the same speed

Graphics3D(800,600,32,2)
camera=CreateCamera()
cube=CreateCube()
PositionEntity(cube, 0, 0, 4)
light=CreateLight(1)
;FPS counter
;FPS counter
Global FPS_FrameCount# = 0
Global FPS_MilliCount# = MilliSecs()
Global FPS_Current# = 60
Global sync#=1
Function FPS_Update()
	FPS_FrameCount = FPS_FrameCount + 1
	;DebugLog(MilliSecs() - FPS_MilliCount)
	If(MilliSecs() - FPS_MilliCount >= 1000)
		FPS_Current = FPS_FrameCount
		FPS_FrameCount = 0
		FPS_MilliCount = MilliSecs()
		sync#=60/FPS_Current#
		AppTitle DEF_Title + " FPS: " + FPS_Current# + " SYNC: " + sync
	EndIf
End Function
;~IDEal Editor Parameters:
;~C#Blitz3D


Global cap=CreateTimer(60)
Global cap2=CreateTimer(30)

ClearTextureFilters()
tex=LoadTexture("shiny.png"); Optional, this is a high res texture I was using
EntityTexture(cube,tex)
Global capper# = 1
While(Not KeyDown(1))

		FPS_Update()

	TurnEntity(cube, 1*sync, 1*sync, 1*sync)
	UpdateWorld()
	RenderWorld()
	
	;Text 0,0, Time#()


	If(MouseDown(1))
		WaitTimer(cap)
	EndIf
	If(MouseDown(2))
		WaitTimer(cap2)
	EndIf
	Flip False
Wend


Is there some complex way of using millisecs to measure skipped frames?


Matty(Posted 2015) [#2]
Personally my method has always been to aim to have a fixed (consistent frame rate) for a specific minimum hardware level - which may mean underutilising the hardware at times (with more powerful devices) - (usually I cap the logic and render rates to a particular set of values - usually with a bit of leeway for if the system does thigns) - and then you have a bit of confidence that the speeds and so on that you set for things are going to smooth.


RemiD(Posted 2015) [#3]
Take a look at this : http://www.blitzbasic.com/codearcs/codearcs.php?code=2916