Please could someone check this timing code. It's driving me mad.
It should of course be limited to 30 fps, but when I'm looking out to sea (no entiites) it rises up as high as 54 even on my dog-slow machine.
On a ninja machine it can rise up to 60 fps causing my characters to speed-walk, and other silly frame dependant effects.
[CODE]
Const FPS=30
Global framePeriod = 1000/FPS
Global frameTime = MilliSecs() - framePeriod
Global frameElapsed
Global frameLimit
;-------------------
Function MainRedraw()
;-------------------
Local frameTicks, frameTween#
Local z
Repeat
frameElapsed = MilliSecs()-frameTime
Until frameElapsed
frameTicks = Int(Float(frameElapsed) / Float(framePeriod) )
frameTween# = Float(frameElapsed Mod framePeriod) / Float(framePeriod)
For frameLimit = 1 To frameTicks
frameTime = frameTime + framePeriod
If frameLimit = frameTicks Then CaptureWorld
; PlayerFunctions(mousemode)
; CharServices()
; UpdateScene()
UpdateWorld()
Next
RenderWorld frameTween#
; 2D Overlays
VWait
Flip False
; Wav_Services()
; Music_Services()
End Function
[/CODE]
Would really appreciate some feedback on this. Thanks.
It should of course be limited to 30 fps, but when I'm looking out to sea (no entiites) it rises up as high as 54 even on my dog-slow machine.
On a ninja machine it can rise up to 60 fps causing my characters to speed-walk, and other silly frame dependant effects.
[CODE]
Const FPS=30
Global framePeriod = 1000/FPS
Global frameTime = MilliSecs() - framePeriod
Global frameElapsed
Global frameLimit
;-------------------
Function MainRedraw()
;-------------------
Local frameTicks, frameTween#
Local z
Repeat
frameElapsed = MilliSecs()-frameTime
Until frameElapsed
frameTicks = Int(Float(frameElapsed) / Float(framePeriod) )
frameTween# = Float(frameElapsed Mod framePeriod) / Float(framePeriod)
For frameLimit = 1 To frameTicks
frameTime = frameTime + framePeriod
If frameLimit = frameTicks Then CaptureWorld
; PlayerFunctions(mousemode)
; CharServices()
; UpdateScene()
UpdateWorld()
Next
RenderWorld frameTween#
; 2D Overlays
VWait
Flip False
; Wav_Services()
; Music_Services()
End Function
[/CODE]
Would really appreciate some feedback on this. Thanks.