summary refs log tree commit diff
path: root/src/Time.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Time.hpp')
-rw-r--r--src/Time.hpp31
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;
+};
+
+}