#include "Timer.h" // set delay so to have a constant Frame Rate void Timer::Delay() { _game_time += _frame_time; int delay = _game_time - SDL_GetTicks(); if(delay > 0) SDL_Delay(delay); } // compute time elapsed on each loop void Timer::GoOn() { _t2 = SDL_GetTicks(); _t_diff = _t2 - _t1; _t1 = _t2; _t_sec +=_t_diff; _num_frames++; // a second has elapsed if(_t_sec >= MS_X_SEC) { // store FPS _fps = _num_frames; // reset counters _num_frames = 0; _t_sec = 0; } }