diff options
| author | Mel <einebeere@gmail.com> | 2024-02-15 11:33:11 +0100 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2024-02-15 11:34:28 +0100 |
| commit | 92f63bbdbfc214849c203511bbcb1be0a4865588 (patch) | |
| tree | d82e1b31e583b5cc9538f61cad696dab5dbd84dc /src/Time.cpp | |
| parent | 87ef308220addbe4406006ceb802a7364e6f1a05 (diff) | |
| download | meowcraft-92f63bbdbfc214849c203511bbcb1be0a4865588.tar.zst meowcraft-92f63bbdbfc214849c203511bbcb1be0a4865588.zip | |
Proper input system
Diffstat (limited to 'src/Time.cpp')
| -rw-r--r-- | src/Time.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/Time.cpp b/src/Time.cpp index e459374..1953fed 100644 --- a/src/Time.cpp +++ b/src/Time.cpp @@ -1,4 +1,5 @@ #include "Time.hpp" +#include "Common/Casts.hpp" #include <chrono> #include <algorithm> @@ -10,7 +11,7 @@ void Time::start_frame() { void Time::end_frame() { auto frame_end = now(); - m_delta = (frame_end - m_current_frame_start) / 1000.0; + m_delta = TO(Real, frame_end - m_current_frame_start) / 1000.0; m_delta = std::clamp(m_delta, delta_min, delta_max); m_total_frames++; @@ -28,6 +29,10 @@ Real Time::delta() const { return m_delta; } +Time::Timestamp Time::frame_start() const { + return m_current_frame_start; +} + Time::Timestamp Time::now() { auto time = std::chrono::system_clock::now().time_since_epoch(); auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(time); |
