Thank you BatVink and Markus,
so if I understand correctly, the timer is inaccurate at 60fps because the delay I set is simply to short and I'm calculating the new target-time at at the wrong moment, after the 'endif' in my example.
I re-wrote the function so it works like this:
BaseTime# = timer()
Delay# = 0.016
function DoStuff()
if timer() => BaseTime#
` do some stuff
` do more stuff
BaseTime# = timer() + Delay#
endif
endfunction()
Sure enough, the routine now works at both 700fps and 60fps. The log displays the following delta:
22:56:33: Oldskool RPG_Engine version 0.01, build 0016
22:56:33: debug log date: 2015-07-27
22:56:33: --------------------------------------------
22:56:33:
22:56:33: Resolution set at : 1680.000000, 1050.000000
22:56:36: Time to fade out : 0.694074, UseVSync = 0
22:56:39: Time to fade in : 0.691072, UseVSync = 0
22:56:43: Time to fade out : 0.691966, UseVSync = 1
22:56:44: Time to fade in : 0.700054, UseVSync = 1
I was wondering though, how I would be able to pause for smaller, but consistent amounts of time at different framerates. For instance, if I try a interval of 0.008, the 700fps-version of the game fades twice as fast as the previous example (as it should), but the 60fps-version 'misses' the check because of the 16ms minimum. Is there a way I can achieve this or work around it?
23:03:37: Oldskool RPG_Engine version 0.01, build 0016
23:03:37: debug log date: 2015-07-27
23:03:37: --------------------------------------------
23:03:37:
23:03:37: Resolution set at : 1680.000000, 1050.000000
23:03:39: Time to fade out : 0.379371, UseVSync = 0
23:03:40: Time to fade in : 0.375786, UseVSync = 0
23:03:44: Time to fade out : 0.621338, UseVSync = 1
23:03:45: Time to fade in : 0.662517, UseVSync = 1