From c0556f76fc5c8271c2eaa7ca91ad1c92c691d8bc Mon Sep 17 00:00:00 2001 From: Mel Date: Wed, 12 Jul 2023 22:57:53 +0200 Subject: Δt calculation and usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Time.hpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/Time.hpp (limited to 'src/Time.hpp') 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; +}; + +} -- cgit 1.4.1