summaryrefslogtreecommitdiff
path: root/src/KingSystem/System
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2020-11-08 21:58:52 +0100
committerLéo Lam <leo@leolam.fr>2020-11-08 22:04:33 +0100
commitff3421d4eb65caecac9465ce84a376dad6dd3a8d (patch)
treec2030126a473e1755856c342e44a5af1f68365cc /src/KingSystem/System
parentf7e6cce7a9c7c89afd1e013294ed427ace08d350 (diff)
ksys: Add Timer (header only for now)
Diffstat (limited to 'src/KingSystem/System')
-rw-r--r--src/KingSystem/System/CMakeLists.txt2
-rw-r--r--src/KingSystem/System/Timer.cpp1
-rw-r--r--src/KingSystem/System/Timer.h26
3 files changed, 29 insertions, 0 deletions
diff --git a/src/KingSystem/System/CMakeLists.txt b/src/KingSystem/System/CMakeLists.txt
index 5a161a2a..42f2dc44 100644
--- a/src/KingSystem/System/CMakeLists.txt
+++ b/src/KingSystem/System/CMakeLists.txt
@@ -15,4 +15,6 @@ target_sources(uking PRIVATE
StringBoard.h
SystemPauseMgr.cpp
SystemPauseMgr.h
+ Timer.cpp
+ Timer.h
)
diff --git a/src/KingSystem/System/Timer.cpp b/src/KingSystem/System/Timer.cpp
new file mode 100644
index 00000000..ad1d92e8
--- /dev/null
+++ b/src/KingSystem/System/Timer.cpp
@@ -0,0 +1 @@
+#include "KingSystem/System/Timer.h"
diff --git a/src/KingSystem/System/Timer.h b/src/KingSystem/System/Timer.h
new file mode 100644
index 00000000..fbd46ac6
--- /dev/null
+++ b/src/KingSystem/System/Timer.h
@@ -0,0 +1,26 @@
+#pragma once
+
+#include <basis/seadTypes.h>
+
+namespace ksys {
+
+struct Timer {
+ Timer() = default;
+ Timer(f32 value, f32 previous_value, f32 speed = -1.0)
+ : value(value), previous_value(previous_value), speed(speed) {}
+
+ void reset(f32 value_, f32 speed_ = -1.0) {
+ value = previous_value = value_;
+ speed = speed_;
+ }
+
+ void update();
+ static void update(f32& t);
+ bool hasEnded(f32 end_time) const;
+
+ f32 value{};
+ f32 previous_value{};
+ f32 speed{};
+};
+
+} // namespace ksys