SDL_framerate.h 731 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * timeHandler.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #ifndef _SDL_framerate_h
  11. #define _SDL_framerate_h
  12. /// A fps manager which holds game updates at a constant rate
  13. class FPSManager
  14. {
  15. private:
  16. double rateticks;
  17. unsigned int lastticks;
  18. int rate;
  19. public:
  20. int fps; // the actual fps value
  21. FPSManager(int rate); // initializes the manager with a given fps rate
  22. void init(); // needs to be called directly before the main game loop to reset the internal timer
  23. void framerateDelay(); // needs to be called every game update cycle
  24. };
  25. #endif