2007-07-15 16:36:04 +03:00
|
|
|
|
2011-04-05 20:38:24 +03:00
|
|
|
/*
|
|
|
|
* timeHandler.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
2007-07-15 16:36:04 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _SDL_framerate_h
|
|
|
|
#define _SDL_framerate_h
|
|
|
|
|
|
|
|
|
2011-04-05 20:38:24 +03:00
|
|
|
/// A fps manager which holds game updates at a constant rate
|
|
|
|
class FPSManager
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
double rateticks;
|
|
|
|
unsigned int lastticks;
|
|
|
|
int rate;
|
2007-07-15 16:36:04 +03:00
|
|
|
|
2011-04-05 20:38:24 +03:00
|
|
|
public:
|
|
|
|
int fps; // the actual fps value
|
2007-07-15 16:36:04 +03:00
|
|
|
|
2011-04-05 20:38:24 +03:00
|
|
|
FPSManager(int rate); // initializes the manager with a given fps rate
|
2011-04-07 05:16:32 +03:00
|
|
|
void init(); // needs to be called directly before the main game loop to reset the internal timer
|
2011-04-05 20:38:24 +03:00
|
|
|
void framerateDelay(); // needs to be called every game update cycle
|
|
|
|
};
|
2007-07-15 16:36:04 +03:00
|
|
|
|
|
|
|
|
|
|
|
#endif
|