/*
   fpstimer - Functions to deal with timing
   Copyright (C) 2002 John Ericson
*/

#include "fpstimer.h"


/* Default value for frames per second */
unsigned int frames_per_sec = 25;

void setframespersecond(const unsigned int fps) {
   frames_per_sec = fps;
}

void waitframe(void) {

   static Uint32 next_tick = 0;
   Uint32 this_tick;

   /* Wait for the next frame */
   this_tick = SDL_GetTicks();
   if (this_tick < next_tick) {
      SDL_Delay(next_tick - this_tick);
   }
   next_tick = this_tick + (1000 / frames_per_sec);
}