Quote: "Try this instead. You still had the resulting factor in both functions multiplied by 60, which throws everything off as I've mentioned before."
Finally some true interaction.
A very good demonstration. Here's what you did except I left the timers in place. And I sped up the squares to better show the motion.
global Flast# as float
global Diff# as float
global Ideal# as float
global Factor# as float
global mysync as integer
Dim factors(30) as float
global movetimer as integer
global thisMove as float
global moveTotal as float
global moved as float
Global FrameX#
Global FrameLast
Global DelayPeriod#
Global MoreAcurateFPS#
Global mTurnStartTime#
GLobal mTurnTimeTaken#
Global kTurnStartTime#
GLobal kTurnTimeTaken#
sync on :sync rate 120
Set Display Mode 1024, 768, 32
make object cube 1, 10
position object 1, 0, 0, 0
make object cube 2, 10
position object 2, 15, 0, 0
position camera 0, 0, 100, -100
point camera 0, 0, 0, 0
TurnStartTime# = Timer()
Do
StartTime# = Timer()
`Run Frame Timing Corrections
Handle_FrameTiming()
`Insert An Erratic Delay Into Frame
Handle_Delay()
`Rotate Object with timing corrections
YRotate Object 1, WrapValue(Object Angle Y(1) + 50.0 * FrameX#)
YRotate Object 2, WrapValue(Object Angle Y(2) + 50.0 * Factor#)
`Reset
If ReturnKey() = 1
YRotate Object 1, 0
YRotate Object 2, 0
EndIf
`Display Data On Screen
Handle_Hud()
`Draw Frame
Sync
`Update Time Taken for full rotation when it occurs.
If Object Angle Y(1) < mPreviousAngle#
mTurnTimeTaken# = Abs(mTurnStartTime# - Timer())
mTurnStartTime# = Timer()
EndIf
mPreviousAngle# = Object Angle Y(1)
If Object Angle Y(2) < kPreviousAngle#
kTurnTimeTaken# = Abs(kTurnStartTime# - Timer())
kTurnStartTime# = Timer()
EndIf
kPreviousAngle# = Object Angle Y(2)
`Calc more acurate frame rate.
MoreAcurateFPS# = 1000 / Abs(Timer() - StartTime#)
Loop
`Mage's Frame Timing Function
Function FrameTimer()
Diff# = (Timer() - FrameLast)
Ideal# = 1000.0 / 60.0
FrameX# = Diff# / Ideal#
If Diff# > 1000 then FrameX# = 0
FrameLast = Timer()
EndFunction
Function Handle_Hud()
Text 10,10, "Object Angle:" + Str$(Object Angle Y(1) + 1.0 * FrameX#)
Text 10,40, "Last Full Rotation Length:"
Text 10,50, "Mage:" + Str$(mTurnTimeTaken# / 1000) + "s"
Text 10,60, "KISTech:" + Str$(kTurnTimeTaken# / 1000) + "s"
Text 10,80, "FPS: " + Str$(Screen FPS())
Text 10,90, "Per Frame FPS:" + str$(MoreAcurateFPS#)
Text 10,110, "Delay added in this frame:"
Text 10,120, Str$(DelayPeriod#) + "ms"
Text 10,140, "Press Control Button for delay."
Text 10,150, "Press Enter Button to reset positions."
Text 500,500, "Mage - KISTech"
EndFunction
`ControlKey Based Delay - Delay 50ms
Function Handle_Delay()
If ControlKey() = 1
DelayPeriod# = Rnd(50)
Start# = Timer()
While Abs(Start# - Timer()) < DelayPeriod#
EndWhile
Else
DelayPeriod# = 0
EndIf
EndFunction
Function Handle_FrameTiming()
tm_Update()
EndFunction
`KISTech's Timing Solution
function tm_Update()
Diff# as float
Diff# = timer() - Flast#
If Diff# > 1000 then Diff# = 0
Flast# = timer()
FrameX# = Diff# / 1000.0
factor# = 0.0
for tx = 1 to 29
factors(tx) = factors(tx+1)
factor# = factor# + factors(tx)
next tx
factors(30) = Diff# / 1000.0
factor# = factor# + factors(30)
factor# = factor# / 30.0
endfunction
Just hold down the ctrl button on this version for a couple seconds and release. The sudden change in FPS will be visible.
Quote: "
We're talking about half a second of smoothing if you are running at 60 FPS. It's NOT a big deal.
"
60fps isn't a problem it's when a car explodes or a player spawns or bullets start flying and every couple of frames FPS is dancing between 10-60fps.