12-09-2023, 03:14 PM
(12-09-2023, 09:26 AM)RhoSigma Wrote: When reading that Wiki page correctly, then its almost the same thing I do here:The option I showed helps in that if the timing of the main cycle is changed (with _limit or _timer, this is irrelevant now), then the movement and speed of the animations will remain unchanged. What you have shown is a possible solution to a fixed timing.
Measuring time myself in that way is what I do to keep approx. 25FPS, you find those kind of constructs a lot in my GuiTools Framework eg. to avoid flicker when moving slider/scroller knobs etc..
Code: (Select All)_DISPLAY 'stop _AUTODISPLAY
stim# = TIMER(0.001) 'get start time
DO
'---------------------
'do drawing stuff here
'---------------------
etim# = TIMER(0.001) - stim# 'time needed for drawing (delta time)
IF etim# < 0 THEN etim# = etim# + 86400 'midnight fix
IF etim# >= 0.04 THEN 'desired FPS 1/25 = 0.04
_DISPLAY
stim# = TIMER(0.001) 'restart timer
END IF
LOOP UNTIL done%
_AUTODISPLAY 'back to normal