Originally Posted By: GamerX
Time_step is used for maintaining the games speed at all frame rates what it is saying is that if you have a frame rate of 30 and a frame rate of 230 you can include time_step in your movement portions of the code and it will move at the same speed. It does this by measuring the time of the last frame and adjusts its self accordingly. Say you have a fps of 15 and ur using time_step.then your fps goes up too 100, time_step will decrease its value so the movement maintains the same speed. That's basically it without using all the math they show u in the tutorial.


Thanks for that smile

I think that's the part I *do* get, though. Like, I understand in concept what's going on... there's some math happening that does basically what you described. Making adjustments so that, as in the example, the plane completes a rotation in 11 seconds, whether it's 5fps or 200fps.

I understand where it's going.. I just don't get how it's getting there.

To be more specific of what's confusing me, here's the bit I'm trying to wrap my head around that's eluding me:

Quote:

The time_step variable gives us the duration of the last frame in ticks, with 1 tick = 1 / 16 seconds = 62.5 milliseconds. The relation between time_step and the frame rate (fps) is this:

time_step = 16 / fps

This means that time_step is 1 when the frame rate is 16 fps, time_step = 0.5 when the frame rate is double (32 fps) and so on; notice how time_step decreases its value as the frame rate increases. If we add or subtract a quantity that’s multiplied by time_step, we'll get a constant increase or decrease regardless of the current frame rate. Time to take a look at our time_step line of code once again:

my.pan = my.pan + 2 * time_step;

Let’s pretend that we have set fps_max to 200; this means that our loop, which takes care of the plane’s rotation, will be executed 200 times per second, and time_step will be 16 / 200 = 0.08

The plane starts its action with an initial pan angle of 0 degrees; one frame later, its pan angles has increased by 2 * 0.08 = 0.16 degrees. After another frame (the second frame), pan has grown to 0.16 + 0.16 = 0.32 degrees, and so on. After 200 frames (a full second if the project runs at 200 fps), the pan angle has grown to 0.16 * 200 = 32 degrees. Since a full rotation has 360 degrees, we can now compute the exact number of seconds that are needed for a full plane rotation: 360 / 32 = 11.25 seconds.

Now let’s assume that we have set fps_max to 5; this means that our loop will be executed 5 times per second and time_step will be 16 / 5 = 3.2

The plane starts its action (once again) with an initial pan angle of 0 degrees; one frame later, its pan has increased by 2 * 3.2 = 6.4 degrees. After another frame (the second frame), pan has grown to 6.4 + 6.4 = 12.8 degrees, and so on. After 5 frames (a full second if the project runs at 200 fps), the pan angle has grown to 6.4 * 5 = 32 degrees.


Even when he's explaining the math... I'm completely lost.

I don't know if there's an easier way to explain all that that would make more sense (to me). Maybe I'm just not cut out for this programming stuff... But I'm assuming there's gotta be some angle I can look at it from where it's just going to "click". I just need to find it.


Last edited by Preypacer; 12/31/08 19:32.