From 2a608805b50663355e23f3837d93b4c13d7ed6d9 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Wed, 16 Dec 2020 16:47:13 +0100 Subject: [PATCH] Spectre/Game/GameTime: add shouldTick() --- include/Spectre/Game/GameTime.h | 4 ++-- source/Game/GameTime.cpp | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/Spectre/Game/GameTime.h b/include/Spectre/Game/GameTime.h index 39cfcea..37aa167 100644 --- a/include/Spectre/Game/GameTime.h +++ b/include/Spectre/Game/GameTime.h @@ -18,10 +18,10 @@ public : Time getElapsed() const; - //bool shouldTick(); - bool beginFrame(); + bool shouldTick() const; + bool tick(); void reset(); diff --git a/source/Game/GameTime.cpp b/source/Game/GameTime.cpp index c6d8061..f8e2b64 100644 --- a/source/Game/GameTime.cpp +++ b/source/Game/GameTime.cpp @@ -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; }