Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 [Snippit] FPS Limiter
Index -> Programming, Turing -> Turing Tutorials
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
TheZsterBunny




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
AsianSensation




PostPosted: Sun Jan 16, 2005 2:00 pm   Post subject: (No 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)
Martin




PostPosted: Mon Jan 17, 2005 11:02 am   Post subject: (No 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.
TheZsterBunny




PostPosted: Mon Jan 17, 2005 11:39 am   Post subject: (No 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
Display posts from previous:   
   Index -> Programming, Turing -> Turing Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: