Computer Science Canada

[Snippit] FPS Limiter

Author:  TheZsterBunny [ Sun Jan 16, 2005 12:32 am ]
Post subject:  [Snippit] FPS Limiter

Alright,

there have been many ways to create a FPS Limiter to stop your program from running far too fast.

I've stumbled across one that works very well and has very few lines.

Turing:

var fps := 36 % about 36 frames per second
var timerchk : int
loop
    timerchk := Time.Elapsed
% your code
    Time.DelaySinceLast (round (1000 / fps)) % wait however many milliseconds (about 28)
end loop


Here we have effectivly limited our code speed.

Enjoy.
-Z

Author:  AsianSensation [ Sun Jan 16, 2005 2:00 pm ]
Post subject: 

wtfomgbbq!

I remembered writing one that was alot longer, of course, that was before all this 4.0.5 business came along.

Turing:

bits += Rand.Int (1 .. 25)

Author:  Martin [ Mon Jan 17, 2005 11:02 am ]
Post subject: 

Awesome. Now, as a second challenge, how would you make it so that you weren't disadvantaged in say a multiplayer game if your frame rate was less than 36?

ie. Everyone has the same movement rate regardless of the frame rate.

Author:  TheZsterBunny [ Mon Jan 17, 2005 11:39 am ]
Post subject: 

If your computer can't handle 36 FPS multiplayer, you don't deserve to win.


besides, i haven't leaned the net module yet.

(typing on massey lib. computers at lunch)
but I suppose that it would be possiblleto send a number and wait fro a response from the other cimputer. Effectively 'pinging' the other player. But esp. on these computer, you may have to wait up to 5 seconds between frames ^_^

----Z

-Z


: