This topic is now archived and is closed to further replies.


Slow down, man!

Recommended Posts

How d'you keep a game playing at a constant speed, regardless of the computer it's running on? I saw some sort of explanation in the Allegro doc, but that doesn't communicate much to my gray load. I also thought of checking the CPU speed and then timing the rendering to get a consistent speed... Comments? Edited by - abe_bcs on 4/6/00 1:50:30 AM

Share this post

Link to post
Share on other sites the beginning of a frame/game loop start a timer/collect the system time:
start_time = getSystemtime()

At the end of the frame/game loop:
time_passed = (getSystemTime() - start_time)
while(time_passed < num_of_miliseconds_per_frame)

note: I made up those variables and functions, so don''t try to just type in getSystemTime().....unless I made a great guess.

you can figure out how many miliseconds by deciding on how many frames per second you want. For example, 30 fps would be 1,000,000 miliseconds / 30 = num_of_miliseconds_per_frame.

Of course, for this to work, you need a timer that is accurate in miliseconds.....

"Why am I the only one on the away team with a red shirt!?"


Share this post

Link to post
Share on other sites