summaryrefslogtreecommitdiff
path: root/src/being.h
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-10-01 17:59:04 +0200
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-10-08 21:01:45 +0200
commit59a7d5c58f8b3af21b3e19d4e78f5653bf011bfb (patch)
tree536f6b80e359922172e671fbbbeb2b7bc5d3f165 /src/being.h
parente115390f18734d9e3e0e2fc5e1ed05f44c9fdb60 (diff)
downloadmana-59a7d5c58f8b3af21b3e19d4e78f5653bf011bfb.tar.gz
mana-59a7d5c58f8b3af21b3e19d4e78f5653bf011bfb.tar.bz2
mana-59a7d5c58f8b3af21b3e19d4e78f5653bf011bfb.tar.xz
mana-59a7d5c58f8b3af21b3e19d4e78f5653bf011bfb.zip
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.
Diffstat (limited to 'src/being.h')
-rw-r--r--src/being.h4
1 files changed, 3 insertions, 1 deletions
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 <guichan/color.hpp>
#include <map>
@@ -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;