Platformer
Platformer
TimeManager.hpp
1 #ifndef TIME_MANAGER_HPP
2 #define TIME_MANAGER_HPP
3 
5 class TimeManager {
6  public:
8  static TimeManager& instance();
9 
11  void StablizeFramerate();
12 
13  /*
14  * Gets the most recent change in time since the last update tick
15  * @return The change in time based on the last update tick
16  */
17  static unsigned int DeltaTime();
18 
20  TimeManager(const TimeManager&) = delete;
21 
23  TimeManager& operator=(const TimeManager&) = delete;
24 
25  private:
27  TimeManager();
28 
30  ~TimeManager();
31 
33  unsigned int lastTick_ = 0;
34 
36  unsigned int lastDelta_ = 0;
37 
39  unsigned int TICKS_PER_FRAME = 16; // 16.667
40 };
41 
42 #endif
unsigned int lastDelta_
The change in time based on the last update tick.
Definition: TimeManager.hpp:36
TimeManager & operator=(const TimeManager &)=delete
Stop the compiler from generating methods to copy the object.
unsigned int lastTick_
The last update tick for stabilizing the framerate.
Definition: TimeManager.hpp:33
Manages the time and framerate for our game.
Definition: TimeManager.hpp:5
~TimeManager()
Destructs a TimeManager.
Definition: TimeManager.cpp:7
unsigned int TICKS_PER_FRAME
The ticks per frame for stabilizing the framerate.
Definition: TimeManager.hpp:39
static TimeManager & instance()
The singleton instance of the TimeManager.
Definition: TimeManager.cpp:9
void StablizeFramerate()
Stabilizes the framerate of the game by calling SDL_Delay.
Definition: TimeManager.cpp:19
TimeManager()
Constructs a TimeManager.
Definition: TimeManager.cpp:6