Hey all,
I've been staring at a Timer Based Movement snippet for a few minutes now. Although I've tested it months back, it works great, but rehashing over my code today, I suddenly find myself curious as to how part of it works...
From a previous thread;
http://forum.thegamecreators.com/?m=forum_view&t=171247&b=1
Quote: "The loop for smoothing basically just takes the values from the last 30 loops and averages them, so you don't end up with a sudden compensation if the framerate drops and then comes back up. It averages that over a very short amount of time, thus making the movement appear smoother."
With the code below;
function tm_Update()
Diff# = timer() - Flast#
Flast# = timer()
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
So what I'm not understanding, is this part;
for tx = 1 to 29
factors(tx) = factors(tx+1)
factor# = factor# + factors(tx)
next tx
The OP talks about this loop "smoothing" out things and reducing jerkiness. But I thought such a loop would have to take place over 30 sync cycles, not 30 For-Next cycles?
What am I missing here...