View Single Post
02-06-10, 08:08 AM   #22
Hati-EK
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 20
Originally Posted by nightcracker View Post
Nope, because THIS time if you run at 120 fps then the function would run a lot more then when at 10 fps.
this is right - at 120fps the function is more fluently ... as the frequency is another - 1/120 vs. 1/10 - but the sampling frequency is 0.25 - so at 120fps it would take 30frames to match the sampling frequency - with 10fps it would take 2.5frames (3frames as there are NO floating frames)


120 fps:
approx. elapsed = 1/120 = 0.0083333333333333s per OnUpdate ( called frequence g in rest of text )
sampling frequency f = 0.25 Hz (or 4fps = 1/4Hz)
f = 30*g
so every 30-frame((n*30)%120, n<-N{0,1,2,..) the SinusFunction() is called - at this point it works fine

now think of ppl having an average fps of not 120fps - like you said 10fps
drawing frequency h = 1/10 Hz
sampling frequency f = 0.25 Hz
resulting that point of collide = frame2.5, as there is no frame 2.5, it will take frame 3 (>=)
time between frame2.5 and frame3 is t=((frame3-frame2)/2);
frame2 is drawn after 0.2s, frame3 after second 0.3 (on time graph) - would result in a 0.05s delay

so with last_update=0, it will result in:
frame1 drawn - frame2 drawn - frame3 drawn - function fires, last_update is now 0 again - frame4 drawn - frame5 drawn (NOW it should fire again - but it doesn't as this is again 0.2 not 0.25) - frame6 drawn - function fires and again 3 frames required


with last_update=last_update-sampling_frequency:
frame1 drawn - frame2 drawn - frame3 drawn - function fires, last_update now is 0.05 - frame4 drawn (last_update 0.15) - frame5 drawn(last_update 0.25) - function fires correctly at (50% of fps as it should with sampling frequency 0.25 - and not at 60%) - frame 6 drawn - etc...


and ppl have not an average fps of continuously 120fps (atleast not the most have)

Last edited by Hati-EK : 02-06-10 at 08:19 AM. Reason: replaced 1 s by Hz
  Reply With Quote