diff options
| author | Léo Lam <leo@leolam.fr> | 2021-01-25 15:53:03 +0100 |
|---|---|---|
| committer | Léo Lam <leo@leolam.fr> | 2021-01-25 15:56:53 +0100 |
| commit | 51755635aa148f951f7c5ddb5047d0768c98d3b6 (patch) | |
| tree | 9cc10310e5676319a5169675a521009da663f500 /src/KingSystem/System/Timer.cpp | |
| parent | 053c20074118e10b08bdf9a62fd4535deecb2c4f (diff) | |
ksys: Implement Timer
Diffstat (limited to 'src/KingSystem/System/Timer.cpp')
| -rw-r--r-- | src/KingSystem/System/Timer.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/KingSystem/System/Timer.cpp b/src/KingSystem/System/Timer.cpp index ad1d92e8..00749b9f 100644 --- a/src/KingSystem/System/Timer.cpp +++ b/src/KingSystem/System/Timer.cpp @@ -1 +1,22 @@ #include "KingSystem/System/Timer.h" +#include "KingSystem/System/VFR.h" + +namespace ksys { + +void Timer::update(f32* t, f32 rate) { + *t += VFR::instance()->getDeltaTime() * rate; +} + +void Timer::update() { + previous_value = value; + update(&value, rate); +} + +bool Timer::hasEnded(f32 end_time) const { + if (value == end_time) + return true; + + return (previous_value - end_time) * (value - end_time) < 0.0; +} + +} // namespace ksys |
