diff options
| author | Léo Lam <leo@leolam.fr> | 2020-11-08 21:58:52 +0100 |
|---|---|---|
| committer | Léo Lam <leo@leolam.fr> | 2020-11-08 22:04:33 +0100 |
| commit | ff3421d4eb65caecac9465ce84a376dad6dd3a8d (patch) | |
| tree | c2030126a473e1755856c342e44a5af1f68365cc /src/KingSystem/System | |
| parent | f7e6cce7a9c7c89afd1e013294ed427ace08d350 (diff) | |
ksys: Add Timer (header only for now)
Diffstat (limited to 'src/KingSystem/System')
| -rw-r--r-- | src/KingSystem/System/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/KingSystem/System/Timer.cpp | 1 | ||||
| -rw-r--r-- | src/KingSystem/System/Timer.h | 26 |
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 |
