1
0
Fork 0

Spectre/Game/GameTime: add shouldTick()

This commit is contained in:
Henrik Hautakoski 2020-12-16 16:47:13 +01:00
parent ed876ca64d
commit 2a608805b5
2 changed files with 9 additions and 3 deletions

View file

@ -18,10 +18,10 @@ public :
Time getElapsed() const;
//bool shouldTick();
bool beginFrame();
bool shouldTick() const;
bool tick();
void reset();

View file

@ -32,12 +32,18 @@ bool GameTime::beginFrame()
accumulateTime();
// Signal if we should tick
return shouldTick();
}
bool GameTime::shouldTick() const
{
// if acc is larger than one slice, we have atleast one tick.
return m_acc > m_slice;
}
bool GameTime::tick()
{
if (m_acc > m_slice) {
if (shouldTick()) {
m_acc -= m_slice;
return true;
}