Skip to main content
GameDev.net gamedev.net
🔒 Locked

Locking the framerate

Started by ols Apr 28, 2005 at 3:32 PM 1 replies 1.3k views
Original Post
ols
ols
OK, so people have been downloading my game (for which I am VERY grateful) and have had a lot of comments about locking the framerate. Was about to start work on this when realised - I have NO IDEA how to do it!! Any help? Cheers
Hikaru
Hikaru
Don't know if this is the best way to do this but just put a framebreak in your gameloop like this:

unsigned int framestart;
#define WAITTIME 20

at the start of your loop:
framestart = SDL_GetTicks(); (or whatever timer you're using)

at the end of your loop:
while((SDL_GetTicks()-framestart) < WAITTIME);

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.