From 59a7d5c58f8b3af21b3e19d4e78f5653bf011bfb Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Tue, 1 Oct 2024 17:59:04 +0200 Subject: Added convenient and efficient Timer class The Timer is efficient because it does not depend on incrementing a counter to keep track of time, nor does it call SDL_GetTicks every time its state is checked (this happens once per frame instead). Along with global functions Time::absoluteTimeMs() and Time::deltaTimeMs(), this replaces previous globals tick_time, cur_time and get_elapsed_time(). For now, there is still a fixed 100 times per second logic call rate, but the new Time::deltaTimeMs() function should allow getting rid of this. --- src/being.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/being.h') diff --git a/src/being.h b/src/being.h index 3bd66b06..c8e8a87b 100644 --- a/src/being.h +++ b/src/being.h @@ -29,6 +29,8 @@ #include "position.h" #include "vector.h" +#include "utils/time.h" + #include #include @@ -484,7 +486,7 @@ class Being : public ActorSprite, public EventListener const BeingInfo *mInfo; - int mActionTime = 0; /**< Time spent in current action. TODO: Remove use of it */ + Timer mActionTimer; /**< Time spent in current action. TODO: Remove use of it */ /** Time until the last speech sentence disappears */ int mSpeechTime = 0; -- cgit v1.2.3-70-g09d2