summaryrefslogtreecommitdiff
path: root/src/KingSystem/System/Timer.cpp
blob: 64aef3917ccc7a37286e9258b1bf817490e4f913 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "KingSystem/System/Timer.h"
#include "KingSystem/System/VFR.h"

namespace ksys {

void Timer::update(f32* t, f32 rate) {
    *t += VFR::instance()->getDeltaFrame() * 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