sortiva/include/TickSystem.hpp

26 lines
437 B
C++
Raw Permalink Normal View History

#pragma once
#include <chrono>
#include <functional>
class TickSystem {
private:
std::chrono::duration<float> timer{ 0 };
std::chrono::duration<float> tickRate;
public:
TickSystem(std::chrono::duration<float> tickRateSeconds)
: tickRate(tickRateSeconds) {
}
bool update(std::chrono::duration<float> deltaTime) {
timer += deltaTime;
if (timer >= tickRate) {
timer -= tickRate;
return true;
}
return false;
}
};