Spectre/Game/GameTime: add shouldTick()
This commit is contained in:
parent
ed876ca64d
commit
2a608805b5
2 changed files with 9 additions and 3 deletions
|
|
@ -18,10 +18,10 @@ public :
|
||||||
|
|
||||||
Time getElapsed() const;
|
Time getElapsed() const;
|
||||||
|
|
||||||
//bool shouldTick();
|
|
||||||
|
|
||||||
bool beginFrame();
|
bool beginFrame();
|
||||||
|
|
||||||
|
bool shouldTick() const;
|
||||||
|
|
||||||
bool tick();
|
bool tick();
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,18 @@ bool GameTime::beginFrame()
|
||||||
accumulateTime();
|
accumulateTime();
|
||||||
|
|
||||||
// Signal if we should tick
|
// 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;
|
return m_acc > m_slice;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameTime::tick()
|
bool GameTime::tick()
|
||||||
{
|
{
|
||||||
if (m_acc > m_slice) {
|
if (shouldTick()) {
|
||||||
m_acc -= m_slice;
|
m_acc -= m_slice;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue