Updated from the SDL Documentation Project
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40182
This commit is contained in:
parent
627578c0d5
commit
8dd601989f
355 changed files with 2317 additions and 1398 deletions
|
@ -88,25 +88,27 @@ NAME="AEN412"
|
|||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue