Exemplos de Temporização

Tempo baseado no loop do jogo

#define TICK_INTERVAL    30

Uint32 TimeLeft(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);
}

/* loop principal do jogo

    while ( game_running ) {
        UpdateGameState();
        SDL_Delay(TimeLeft());
    }

SDLDoc-ptBR/Exemplos_Tempo (last edited 2008-04-17 08:18:54 by localhost)