• Welcome to Dark Bit Factory & Gravity.
 

Delta Timing Test.

Started by Shockwave, August 20, 2006

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Shockwave

Yip, easy as that.

I did an example program instead, you can find it here;

http://dbfinteractive.com/index.php?topic=587.0
Shockwave ^ Codigos
Challenge Trophies Won:

relsoft

Challenge Trophies Won:

Ghost^BHT

I'm going to sound a bit dim here. I thought delta timeing was to have the prog run at the same speed on all capable machines?
So if you are having a variance (on the faster machines) of fps doesn't that mean that the timing routine is not working on those faster machines? Or does it mean that the display(movement etc.) will be the same no matter what the fps?  Hit me with the stick of knowledge please  :whack:

Jim

Say your game ran at 60fps and you moved everything 1 pixel across every frame, then it's speed would be 60 pixels per second.
If your code only runs at 30fps, then it'll only move 30 pixels in a second, half the speed.
And if your code is jumping about all over the place, like it tends to do on Windows, then the speed is erratic.

What you need to do is compensate.   If you were running at 30fps, you could simply double the number of pixels moved per frame, so 30x2 = 60x1.   But more generally, assume the framerate you are running at is based on how long it took to draw the previous frame.  If the last frame took 1/60th then add 1 pixel, if it took 1/30th then add 2 pixels.  1/15 is 4 pixels etc.   So you automatically compensate.

Taking it to it's conclusion, if the last frame took 1/n seconds to draw, then the amount to move would be
(1/n)/(1/60) = 60/n pixels per frame

It means on slow machines, even though you compute the physics less often, it moves just as far across the screen.  You can do it with positions, rotations, colour changes, anything really.

Jim
Challenge Trophies Won:

Shockwave

Jim has explained it much better than I could. It's more or less the same as what I am doing, only I am taking an average of more frames, I don't know why but the movement just didn't look quite right to me when I was taking the time in millisecs to draw the last frame, I need to experiment with it more.
Shockwave ^ Codigos
Challenge Trophies Won:

Ghost^BHT

Thanks Jim and Shockwave for the explanation.  :cheers:

Voltage

Silky smooth Shockwave.  Looks retro and very cool too BTW.

145 FPS here
Challenge Trophies Won:

Shockwave

Thanks Voltage :) I actually completed an intro using this technique but unfortunately I couldn't release it here because I would have technically been breaking the rules of the forum, but it's on the Intro Inferno site released under the group name Rituel.
Shockwave ^ Codigos
Challenge Trophies Won:

DrewPee

@Shockwave - What do you mean about technically breaking the forum rules?
Obviously after my first demo its plain to see that i need some delta timing in my code to at least slow the scroller down! lol!

Drew
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Shockwave

Rituel are a piracy group and since this forum is 100% legal only I could not really justify releasing the Rituel intros here :) Still, they are on Intro Inferno if you feel like looking :-X
Shockwave ^ Codigos
Challenge Trophies Won:

Shockwave

Btw. I want to say for the record that I do not possess *any* pirated stuff. I even paid to register my copy of Winzip. I think that if you use a product then you should always support the people who made it, having said that, I do love the art form of coding cracktros, it's where the demo scene came from and if it wasn't for them, this place  would not exist.
Shockwave ^ Codigos
Challenge Trophies Won:

DrewPee

Thanks for clearing that up Shockwave. I see where you are coming from now!

Drew
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk