diff options
| author | Mel <einebeere@gmail.com> | 2023-07-12 22:57:53 +0200 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2023-07-12 22:58:34 +0200 |
| commit | c0556f76fc5c8271c2eaa7ca91ad1c92c691d8bc (patch) | |
| tree | a7c10af8e912ae0fa4aec58b15d8a6496a288e4d /src/Time.hpp | |
| parent | f09e5791837bb003f7c5db8c0e3162636bc9a9c2 (diff) | |
| download | meowcraft-c0556f76fc5c8271c2eaa7ca91ad1c92c691d8bc.tar.zst meowcraft-c0556f76fc5c8271c2eaa7ca91ad1c92c691d8bc.zip | |
Δt calculation and usage
Diffstat (limited to 'src/Time.hpp')
| -rw-r--r-- | src/Time.hpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/Time.hpp b/src/Time.hpp new file mode 100644 index 0000000..83c41c0 --- /dev/null +++ b/src/Time.hpp @@ -0,0 +1,31 @@ +#pragma once + +#include "Common/Sizes.hpp" + +namespace MC { + +class Time { +public: + using Timestamp = U64; + + Time() = default; + + void start_frame(); + void end_frame(); + + U64 total_frames() const; + Real delta() const; + + static Timestamp now(); + +private: + static constexpr Real delta_max = 1.0 / 10.0; + static constexpr Real delta_min = 1.0 / 1000.0; + + U64 m_total_frames = 0; + + Timestamp m_current_frame_start = 0; + Real m_delta = 0; +}; + +} |
