Page 1 of 1

Sync game speed using frame rate ratio ?

PostPosted: Sep 26, 2003 @ 4:25am
by denthorq

PostPosted: Sep 26, 2003 @ 5:49am
by fast_rx

PostPosted: Sep 26, 2003 @ 8:14pm
by mlepage
Round by adding 0.5 before casting to int. (Only works on positive numbers and won't round 0.5 to even as statisticians prefer.)

PostPosted: Sep 26, 2003 @ 9:49pm
by denthorq
fast_rx: here's the thread

Pls make the formula clear to me. Thanks.

PostPosted: Sep 26, 2003 @ 10:44pm
by fast_rx

PostPosted: Sep 27, 2003 @ 2:22am
by fast_rx
Some other things I just thought about. They may interest you or anyone else reading...

IF you use integers for your iterated values, you'll be thowing out small (less than 1, obviously) parts of your movement... And since it's iterated dozens of times (hopefully) per second, the errors can really add up. I'd suggest either using floats or at least fixed point floats in order to minimize the error.

Another important thing to consider is that we really don't know what devices will be out in a couple of years... so, ensure you code so that really, really fast devices don't cause a problem. In the previous message, I suggest taking the ratio of the delta time to the desired delta. On a super fast machine, that will approach zero. And if you add in the round off errors of int's or even floats for that matter, you may end up with things not moving at all...

A good way to check to see if your code is working is to compile it in debug (runs slow) and then check it with a full optimized build. They should be almost identical in the timing of things happening, right?

And lastly, I mentioned that this works fine for linearly tweaked values (i.e. constant speed for instance). But in my game Lejjo (), I am iterating a mass-spring system. This caused a problem because there was a point where if my iterations were too large, the spring-mass system equations would go crazy. The fix was to check to see if I was below a minimum update rate, and if not, use multiple smaller iteration time slices.

If any of you made it through all that, I congratulate you.

PostPosted: Sep 27, 2003 @ 2:29am
by warmi

PostPosted: Sep 27, 2003 @ 2:37am
by denthorq

PostPosted: Sep 27, 2003 @ 2:42am
by warmi

PostPosted: Sep 27, 2003 @ 2:45am
by denthorq

PostPosted: Sep 27, 2003 @ 2:57am
by warmi

PostPosted: Sep 27, 2003 @ 3:11am
by mlepage