Mercurial > sdl-ios-xcode
diff docs/html/guidetimeexamples.html @ 181:e5bc29de3f0a
Updated from the SDL Documentation Project
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 14 Sep 2001 02:41:09 +0000 |
parents | 55f1f1b3e27d |
children | 355632dca928 |
line wrap: on
line diff
--- a/docs/html/guidetimeexamples.html Thu Sep 13 16:41:03 2001 +0000 +++ b/docs/html/guidetimeexamples.html Fri Sep 14 02:41:09 2001 +0000 @@ -88,25 +88,27 @@ CLASS="PROGRAMLISTING" >#define TICK_INTERVAL 30 -Uint32 TimeLeft(void) +static Uint32 next_time; + +Uint32 time_left(void) { - static Uint32 next_time = 0; Uint32 now; now = SDL_GetTicks(); - if ( next_time <= now ) { - next_time = now+TICK_INTERVAL; - return(0); - } - return(next_time-now); + if(next_time <= now) + return 0; + else + return next_time - now; } -/* main game loop +/* main game loop */ + next_time = SDL_GetTicks() + TICK_INTERVAL; while ( game_running ) { - UpdateGameState(); - SDL_Delay(TimeLeft()); + update_game_state(); + SDL_Delay(time_left()); + next_time += TICK_INTERVAL; } </PRE ></P ></DIV