SDL_framerate.h 698 B

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