int FPS() { // ==== VARIABLES static int curFrames = 0; // number of frames for this second static int last = 0; // last time we completed a full second static int fps = 0; // fps for last second // ==== CALCULATIONS int current = SDL_GetTicks(); // current time curFrames++; // increase frame for this second if( current - last > 1000 ) // if a second has elapsed { last = current; // we completed a new full second fps = curFrames; // we have a new frames for last second curFrames = 0; // reset counter } // ==== RETURN return fps; }