Timing / Framerate help needed.
I''m working on an old school 2-d side scrolling game in Win98 (usin VC++6.0 and DDraw) and I''ve got serious framerate problems, namely it runs too fast on high end systems. I came up witha fairly simple algorithm to solidify the FPS (frames per second) at whatever I desire on all machines that goes something like this:
main_game_loop
{
//Character, interface, and other crap class updates
//Blit everything to the screen
//wait (1000 / desired_FPS) milliseconds before looping
}
. . . thus making it so it so the game updates desired_FPS times in a second.
Which makes perfect sense on paper, and worked flawlessly in my code except none of the standard Visual C++ time functions I''ve tried return an accurate count of milliseconds. They only update their respective values every 50 or 60 milliseconds which means that no matter what desired_FPS is I can only get 20 - 16 FPS results at max. Which sucks, a great deal. I''ve tried using _ftime, and one other (that I forgot), but I haven''t tried TickCount yet tho. I figured I''d get a second opinion before I try tho.
If anyone''s got any insight (a function I should use, or a freeware time library), or even a more effective way of managing framerate. I would be much obliged, because in whats supposed to be a fast paced game, 20 frames per second sucks. Well, thanks in advance for ya help.
-F.
"People who chew with their mouths open make me . . . FURIOUS!"
Like fighting games? You'll love FAB:http://www.fenixware.net/fab/index.asp
- Best do the waiting before calling your procs. This way time lost by operating system is handled better.
- Best use GetTickCount!
- Use static var and save previous time.Get difference between previous and current time. Wait if delta time is too small.
- Best use GetTickCount!
- Use static var and save previous time.Get difference between previous and current time. Wait if delta time is too small.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement