Practical Tools for Simple Design
Loading...
Searching...
No Matches
Time.hpp
1#ifndef UTIL_TIME_H
2#define UTIL_TIME_H
3
4#include "pch.hpp" // IWYU pragma: export
5
6namespace Util {
7
8using sdl_count_t = Uint64;
9using second_t = float;
10using ms_t = float;
11
22class Time {
23public:
32 [[deprecated("Use GetDeltaTimeMs() instead.")]]
33 static second_t GetDeltaTime() {
34 return s_DeltaTime / 1000.0F;
35 }
36
45 static ms_t GetDeltaTimeMs() { return s_DeltaTime; }
46
56 static ms_t GetElapsedTimeMs();
57
65 static void Update();
66
67private:
68 static sdl_count_t s_Start;
69
75 static sdl_count_t s_Now;
76
82 static sdl_count_t s_Last;
83
90 static ms_t s_DeltaTime;
91};
92} // namespace Util
93
94#endif /* UTIL_TIME_H */
A singleton class that provides time-related functionalities.
Definition: Time.hpp:22
static void Update()
Update the time.
static ms_t GetElapsedTimeMs()
Get the elapsed time from the start of the program in milliseconds.
static ms_t GetDeltaTimeMs()
Get the delta time between frames in milliseconds.
Definition: Time.hpp:45
static second_t GetDeltaTime()
Get the delta time between frames in seconds.
Definition: Time.hpp:33
Useful tools for development.
Definition: Animation.hpp:12