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;
|
||||
|
||||
//bool shouldTick();
|
||||
|
||||
bool beginFrame();
|
||||
|
||||
bool shouldTick() const;
|
||||
|
||||
bool tick();
|
||||
|
||||
void reset();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue