diff options
-rw-r--r-- | src/actorsprite.cpp | 13 | ||||
-rw-r--r-- | src/actorsprite.h | 2 | ||||
-rw-r--r-- | src/animatedsprite.cpp | 17 | ||||
-rw-r--r-- | src/animatedsprite.h | 3 | ||||
-rw-r--r-- | src/animationparticle.cpp | 4 | ||||
-rw-r--r-- | src/being.cpp | 34 | ||||
-rw-r--r-- | src/being.h | 11 | ||||
-rw-r--r-- | src/client.cpp | 18 | ||||
-rw-r--r-- | src/game.cpp | 14 | ||||
-rw-r--r-- | src/game.h | 4 | ||||
-rw-r--r-- | src/gui/widgets/progressindicator.cpp | 2 | ||||
-rw-r--r-- | src/localplayer.cpp | 5 | ||||
-rw-r--r-- | src/localplayer.h | 4 | ||||
-rw-r--r-- | src/map.cpp | 8 | ||||
-rw-r--r-- | src/map.h | 4 | ||||
-rw-r--r-- | src/net/manaserv/playerhandler.cpp | 16 | ||||
-rw-r--r-- | src/net/manaserv/playerhandler.h | 2 | ||||
-rw-r--r-- | src/net/playerhandler.h | 4 | ||||
-rw-r--r-- | src/net/tmwa/playerhandler.cpp | 13 | ||||
-rw-r--r-- | src/net/tmwa/playerhandler.h | 2 | ||||
-rw-r--r-- | src/playerinfo.cpp | 10 | ||||
-rw-r--r-- | src/playerrelations.cpp | 2 | ||||
-rw-r--r-- | src/position.h | 1 | ||||
-rw-r--r-- | src/resources/mapreader.cpp | 2 | ||||
-rw-r--r-- | src/simpleanimation.cpp | 4 | ||||
-rw-r--r-- | src/simpleanimation.h | 6 |
26 files changed, 92 insertions, 113 deletions
diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp index 20e724f5..989de8d9 100644 --- a/src/actorsprite.cpp +++ b/src/actorsprite.cpp @@ -79,11 +79,7 @@ bool ActorSprite::draw(Graphics *graphics, int offsetX, int offsetY) const int py = getPixelY() + offsetY; if (mUsedTargetCursor) - { - mUsedTargetCursor->reset(); - mUsedTargetCursor->update(Time::absoluteTimeMs()); mUsedTargetCursor->draw(graphics, px, py); - } // This is makes sure that actors positioned on the center of a tile have // their sprite aligned to the bottom of that tile, mainly to maintain @@ -102,7 +98,10 @@ bool ActorSprite::drawSpriteAt(Graphics *graphics, int x, int y) const void ActorSprite::logic() { // Update sprite animations - update(Time::absoluteTimeMs()); + update(Time::deltaTimeMs()); + + if (mUsedTargetCursor) + mUsedTargetCursor->update(Time::deltaTimeMs()); // Restart status/particle effects, if needed if (mMustResetParticles) @@ -125,10 +124,6 @@ void ActorSprite::logic() mChildParticleEffects.moveTo(mPos.x, py); } -void ActorSprite::actorLogic() -{ -} - void ActorSprite::setMap(Map* map) { Actor::setMap(map); diff --git a/src/actorsprite.h b/src/actorsprite.h index 883934aa..8c20f81f 100644 --- a/src/actorsprite.h +++ b/src/actorsprite.h @@ -82,8 +82,6 @@ public: virtual void logic(); - static void actorLogic(); - void setMap(Map* map) override; /** diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp index 7aa475d9..ec7aa1e3 100644 --- a/src/animatedsprite.cpp +++ b/src/animatedsprite.cpp @@ -54,11 +54,10 @@ AnimatedSprite::~AnimatedSprite() = default; bool AnimatedSprite::reset() { - bool ret = mFrameIndex !=0 || mFrameTime != 0 || mLastTime != 0; + bool ret = mFrameIndex !=0 || mFrameTime != 0; mFrameIndex = 0; mFrameTime = 0; - mLastTime = 0; return ret; } @@ -87,21 +86,13 @@ bool AnimatedSprite::play(const std::string &spriteAction) bool AnimatedSprite::update(int time) { - // Avoid freaking out at first frame or when tick_time overflows - if (time < mLastTime || mLastTime == 0) - mLastTime = time; - - // If not enough time has passed yet, do nothing - if (time <= mLastTime || !mAnimation) + if (!mAnimation) return false; - unsigned int dt = time - mLastTime; - mLastTime = time; - Animation *animation = mAnimation; Frame *frame = mFrame; - if (!updateCurrentAnimation(dt)) + if (!updateCurrentAnimation(time)) { // Animation finished, reset to default play(SpriteAction::STAND); @@ -111,7 +102,7 @@ bool AnimatedSprite::update(int time) return animation != mAnimation || frame != mFrame; } -bool AnimatedSprite::updateCurrentAnimation(unsigned int time) +bool AnimatedSprite::updateCurrentAnimation(int time) { if (!mFrame || Animation::isTerminator(*mFrame)) return false; diff --git a/src/animatedsprite.h b/src/animatedsprite.h index 05c73ddd..51544a48 100644 --- a/src/animatedsprite.h +++ b/src/animatedsprite.h @@ -79,10 +79,9 @@ class AnimatedSprite final : public Sprite int getDuration() const override; private: - bool updateCurrentAnimation(unsigned int dt); + bool updateCurrentAnimation(int dt); SpriteDirection mDirection = DIRECTION_DOWN; /**< The sprite direction. */ - int mLastTime = 0; /**< The last time update was called. */ int mFrameIndex = 0; /**< The index of the current frame. */ int mFrameTime = 0; /**< The time since start of frame. */ diff --git a/src/animationparticle.cpp b/src/animationparticle.cpp index db38b526..85f66a78 100644 --- a/src/animationparticle.cpp +++ b/src/animationparticle.cpp @@ -23,6 +23,8 @@ #include "simpleanimation.h" +#include "utils/time.h" + AnimationParticle::AnimationParticle(Map *map, Animation animation): ImageParticle(map, nullptr), mAnimation(std::move(animation)) @@ -44,7 +46,7 @@ AnimationParticle::~AnimationParticle() bool AnimationParticle::update() { - mAnimation.update(10); // particle engine is updated every 10ms + mAnimation.update(MILLISECONDS_IN_A_TICK); mImage = mAnimation.getCurrentImage(); return Particle::update(); diff --git a/src/being.cpp b/src/being.cpp index 88104d74..b622143a 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -158,8 +158,8 @@ void Being::setMoveSpeed(const Vector &speed) mMoveSpeed = speed; // If we already can, recalculate the system speed right away. if (mMap) - mSpeedPixelsPerTick = - Net::getPlayerHandler()->getPixelsPerTickMoveSpeed(speed); + mSpeedPixelsPerSecond = + Net::getPlayerHandler()->getPixelsPerSecondMoveSpeed(speed); } int Being::getSpeechTextYPosition() const @@ -284,7 +284,7 @@ void Being::setSpeech(const std::string &text, int time) } if (!mSpeech.empty()) - mSpeechTime = time <= SPEECH_MAX_TIME ? time : SPEECH_MAX_TIME; + mSpeechTimer.set(std::min(time, SPEECH_MAX_TIME)); const int speech = config.getIntValue("speech"); if (speech == TEXT_OVERHEAD) @@ -755,12 +755,8 @@ int Being::getCollisionRadius() const void Being::logic() { - // Reduce the time that speech is still displayed - if (mSpeechTime > 0) - mSpeechTime--; - // Remove text and speechbubbles if speech boxes aren't being used - if (mSpeechTime == 0 && mText) + if (mText && mSpeechTimer.passed()) { delete mText; mText = nullptr; @@ -772,7 +768,7 @@ void Being::logic() restoreAllSpriteParticles(); } - if ((mAction != DEAD) && !mSpeedPixelsPerTick.isNull()) + if ((mAction != DEAD) && !mSpeedPixelsPerSecond.isNull()) { const Vector dest = (mPath.empty()) ? mDest : Vector(mPath.front().x, @@ -803,13 +799,14 @@ void Being::logic() // รข = a / ||a|| (||a|| is the a length.) // Then, diff = (dir/||dir||) * speed. const Vector normalizedDir = dir.normalized(); - Vector diff(normalizedDir.x * mSpeedPixelsPerTick.x, - normalizedDir.y * mSpeedPixelsPerTick.y); + const int ms = Time::deltaTimeMs(); + Vector diff(normalizedDir.x * mSpeedPixelsPerSecond.x * ms / 1000.0f, + normalizedDir.y * mSpeedPixelsPerSecond.y * ms / 1000.0f); // Test if we don't miss the destination by a move too far: if (diff.length() > distance) { - setPosition(mPos + dir); + setPosition(dest); // Also, if the destination is reached, try to get the next // path point, if existing. @@ -876,13 +873,12 @@ void Being::drawSpeech(int offsetX, int offsetY) const int speech = config.getIntValue("speech"); // Draw speech above this being - if (mSpeechTime == 0) + if (mSpeechTimer.passed()) { if (mSpeechBubble->isVisible()) mSpeechBubble->setVisible(false); } - else if (mSpeechTime > 0 && (speech == NAME_IN_BUBBLE || - speech == NO_NAME_IN_BUBBLE)) + else if (speech == NAME_IN_BUBBLE || speech == NO_NAME_IN_BUBBLE) { const bool showName = (speech == NAME_IN_BUBBLE); @@ -897,11 +893,11 @@ void Being::drawSpeech(int offsetX, int offsetY) - mSpeechBubble->getHeight() - offsetY); mSpeechBubble->setVisible(true); } - else if (mSpeechTime > 0 && speech == TEXT_OVERHEAD) + else if (speech == TEXT_OVERHEAD) { mSpeechBubble->setVisible(false); - if (! mText) + if (!mText) { mText = new Text(mSpeech, getPixelX(), getPixelY() - getHeight(), @@ -1216,7 +1212,7 @@ void Being::setMap(Map *map) // Recalculate pixel/tick speed if (map && !mMoveSpeed.isNull()) { - mSpeedPixelsPerTick = - Net::getPlayerHandler()->getPixelsPerTickMoveSpeed(mMoveSpeed, map); + mSpeedPixelsPerSecond = + Net::getPlayerHandler()->getPixelsPerSecondMoveSpeed(mMoveSpeed, map); } } diff --git a/src/being.h b/src/being.h index c8e8a87b..5c939fcc 100644 --- a/src/being.h +++ b/src/being.h @@ -40,7 +40,7 @@ #define STATUS_EFFECTS 32 #define SPEECH_TIME 500 -#define SPEECH_MAX_TIME 1000 +#define SPEECH_MAX_TIME 10000 class BeingInfo; class FlashText; @@ -155,7 +155,7 @@ class Being : public ActorSprite, public EventListener * @param text The text that should appear. * @param time The amount of time the text should stay in milliseconds. */ - void setSpeech(const std::string &text, int time = 500); + void setSpeech(const std::string &text, int time = 5000); /** * Puts a damage bubble above this being. @@ -489,7 +489,7 @@ class Being : public ActorSprite, public EventListener Timer mActionTimer; /**< Time spent in current action. TODO: Remove use of it */ /** Time until the last speech sentence disappears */ - int mSpeechTime = 0; + Timer mSpeechTimer; int mAttackSpeed = 350; /**< Attack speed */ @@ -544,10 +544,9 @@ class Being : public ActorSprite, public EventListener Vector mMoveSpeed; /** - * Being speed in pixel per ticks. Used internally for the being logic. - * @see MILLISECONDS_IN_A_TICK + * Being speed in pixel per second. Used internally for the being logic. */ - Vector mSpeedPixelsPerTick; + Vector mSpeedPixelsPerSecond; int mDamageTaken = 0; diff --git a/src/client.cpp b/src/client.cpp index 6137a88a..f428aaec 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -442,12 +442,6 @@ int Client::exec() { Time::beginFrame(); // Prevent startup lag influencing the first frame - // Tick timer, used until logic has been updated to use Time::deltaTimeMs - Timer tickTimer; - tickTimer.set(); - - SDL_Event event; - while (mState != STATE_EXIT) { Time::beginFrame(); @@ -460,6 +454,7 @@ int Client::exec() else { // Handle SDL events + SDL_Event event; while (SDL_PollEvent(&event)) { switch (event.type) @@ -485,14 +480,9 @@ int Client::exec() if (Net::getGeneralHandler()) Net::getGeneralHandler()->flushNetwork(); - while (tickTimer.passed()) - { - gui->logic(); - if (mGame) - mGame->logic(); - - tickTimer.extend(MILLISECONDS_IN_A_TICK); - } + gui->logic(); + if (mGame) + mGame->logic(); sound.logic(); diff --git a/src/game.cpp b/src/game.cpp index 13928036..0bf2e48a 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -211,6 +211,8 @@ Game::Game(): assert(!mInstance); mInstance = this; + mParticleEngineTimer.set(); + // Create the viewport viewport = new Viewport; viewport->setSize(graphics->getWidth(), graphics->getHeight()); @@ -337,11 +339,17 @@ static bool saveScreenshot() void Game::logic() { // Handle all necessary game logic - ActorSprite::actorLogic(); actorSpriteManager->logic(); - particleEngine->update(); + + // todo: make Particle::update work with variable time steps + while (mParticleEngineTimer.passed()) + { + particleEngine->update(); + mParticleEngineTimer.extend(MILLISECONDS_IN_A_TICK); + } + if (mCurrentMap) - mCurrentMap->update(); + mCurrentMap->update(Time::deltaTimeMs()); // Handle network stuff if (!Net::getGameHandler()->isConnected() && !mDisconnected) @@ -26,6 +26,8 @@ #include "gui/windowmenu.h" +#include "utils/time.h" + class Map; /** @@ -91,6 +93,8 @@ class Game Map *mCurrentMap = nullptr; std::string mMapName; + Timer mParticleEngineTimer; + static Game *mInstance; }; diff --git a/src/gui/widgets/progressindicator.cpp b/src/gui/widgets/progressindicator.cpp index 37aaab62..496bd8a1 100644 --- a/src/gui/widgets/progressindicator.cpp +++ b/src/gui/widgets/progressindicator.cpp @@ -48,7 +48,7 @@ ProgressIndicator::~ProgressIndicator() = default; void ProgressIndicator::logic() { - mIndicator->update(10); + mIndicator->update(Time::deltaTimeMs()); } void ProgressIndicator::draw(gcn::Graphics *graphics) diff --git a/src/localplayer.cpp b/src/localplayer.cpp index a7969fc3..1a91ffb7 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -80,7 +80,7 @@ void LocalPlayer::logic() // Show XP messages if (!mMessages.empty()) { - if (mMessageTime == 0) + if (mMessageTimer.passed()) { const auto &[message, color] = mMessages.front(); @@ -92,9 +92,8 @@ void LocalPlayer::logic() gui->getInfoParticleFont(), true); mMessages.pop_front(); - mMessageTime = 30; + mMessageTimer.set(300); } - mMessageTime--; } PlayerInfo::logic(); diff --git a/src/localplayer.h b/src/localplayer.h index 9d844339..43453498 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -233,9 +233,9 @@ class LocalPlayer final : public Being int mWalkingDir = 0; /**< The direction the player is walking in. */ bool mPathSetByMouse = false; /**< Tells if the path was set using mouse */ - /** Queued messages*/ + /** Queued messages */ std::list<std::pair<std::string, int>> mMessages; - int mMessageTime = 0; + Timer mMessageTimer; bool mShowIp = false; diff --git a/src/map.cpp b/src/map.cpp index c4e4c3be..e38149d3 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -69,9 +69,9 @@ TileAnimation::TileAnimation(Animation animation) { } -void TileAnimation::update(int ticks) +void TileAnimation::update(int dt) { - mAnimation.update(ticks); + mAnimation.update(dt); // exchange images Image *img = mAnimation.getCurrentImage(); @@ -301,12 +301,12 @@ bool actorCompare(const Actor *a, const Actor *b) return a->getDrawOrder() < b->getDrawOrder(); } -void Map::update(int ticks) +void Map::update(int dt) { // Update animated tiles for (auto &[_, tileAnimation] : mTileAnimations) { - tileAnimation.update(ticks); + tileAnimation.update(dt); } } @@ -63,7 +63,7 @@ class TileAnimation public: TileAnimation(Animation animation); - void update(int ticks = 1); + void update(int dt); void addAffectedTile(MapLayer *layer, int index) { mAffected.emplace_back(layer, index); } @@ -195,7 +195,7 @@ class Map : public Properties /** * Updates animations. Called as needed. */ - void update(int ticks = 1); + void update(int dt); /** * Draws the map to the given graphics output. This method draws all diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp index 0b098ea8..bf5694c6 100644 --- a/src/net/manaserv/playerhandler.cpp +++ b/src/net/manaserv/playerhandler.cpp @@ -416,9 +416,9 @@ Vector PlayerHandler::getDefaultMoveSpeed() const return Vector(6.0f, 6.0f, 0.0f); } -Vector PlayerHandler::getPixelsPerTickMoveSpeed(const Vector &speed, Map *map) +Vector PlayerHandler::getPixelsPerSecondMoveSpeed(const Vector &speed, Map *map) { - Vector speedInTicks; + Vector speedInPixels; Game *game = Game::instance(); if (game && !map) @@ -428,17 +428,13 @@ Vector PlayerHandler::getPixelsPerTickMoveSpeed(const Vector &speed, Map *map) { logger->log("Manaserv::PlayerHandler: Speed wasn't given back" " because Map not initialized."); - return speedInTicks; + return speedInPixels; } - speedInTicks.x = speed.x - * (float)map->getTileWidth() - / 1000 * (float) MILLISECONDS_IN_A_TICK; - speedInTicks.y = speed.y - * (float)map->getTileHeight() - / 1000 * (float) MILLISECONDS_IN_A_TICK; + speedInPixels.x = speed.x * map->getTileWidth(); + speedInPixels.y = speed.y * map->getTileHeight(); - return speedInTicks; + return speedInPixels; } } // namespace ManaServ diff --git a/src/net/manaserv/playerhandler.h b/src/net/manaserv/playerhandler.h index a14e3ed5..a6839112 100644 --- a/src/net/manaserv/playerhandler.h +++ b/src/net/manaserv/playerhandler.h @@ -67,7 +67,7 @@ class PlayerHandler final : public MessageHandler, public Net::PlayerHandler Vector getDefaultMoveSpeed() const override; - Vector getPixelsPerTickMoveSpeed(const Vector &speed, Map *map = nullptr) override; + Vector getPixelsPerSecondMoveSpeed(const Vector &speed, Map *map = nullptr) override; bool usePixelPrecision() override { return true; } diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h index de7bf827..6187da2a 100644 --- a/src/net/playerhandler.h +++ b/src/net/playerhandler.h @@ -73,8 +73,8 @@ class PlayerHandler /** * Convert the original server-dependant speed for internal use. */ - virtual Vector getPixelsPerTickMoveSpeed(const Vector &speed, - Map *map = nullptr) = 0; + virtual Vector getPixelsPerSecondMoveSpeed(const Vector &speed, + Map *map = nullptr) = 0; /** * Tells whether the client has to use pixel paths. diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index c9baf27b..4f417dc8 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -648,7 +648,7 @@ Vector PlayerHandler::getDefaultMoveSpeed() const return Vector(15.0f, 15.0f, 0.0f); } -Vector PlayerHandler::getPixelsPerTickMoveSpeed(const Vector &speed, Map *map) +Vector PlayerHandler::getPixelsPerSecondMoveSpeed(const Vector &speed, Map *map) { Game *game = Game::instance(); @@ -662,13 +662,14 @@ Vector PlayerHandler::getPixelsPerTickMoveSpeed(const Vector &speed, Map *map) return getDefaultMoveSpeed(); } - Vector speedInTicks; + Vector pixelsPerSecond; - // speedInTicks.z = 0; // We don't use z for now. - speedInTicks.x = 1 / speed.x * (float)map->getTileWidth(); - speedInTicks.y = 1 / speed.y * (float)map->getTileHeight(); + constexpr float ticksPerSecond = 1000.0 / MILLISECONDS_IN_A_TICK; - return speedInTicks; + pixelsPerSecond.x = map->getTileWidth() / speed.x * ticksPerSecond; + pixelsPerSecond.y = map->getTileHeight() / speed.y * ticksPerSecond; + + return pixelsPerSecond; } } // namespace TmwAthena diff --git a/src/net/tmwa/playerhandler.h b/src/net/tmwa/playerhandler.h index f2a1b40e..1a90532e 100644 --- a/src/net/tmwa/playerhandler.h +++ b/src/net/tmwa/playerhandler.h @@ -60,7 +60,7 @@ class PlayerHandler final : public MessageHandler, public Net::PlayerHandler Vector getDefaultMoveSpeed() const override; - Vector getPixelsPerTickMoveSpeed(const Vector &speed, Map *map = nullptr) override; + Vector getPixelsPerSecondMoveSpeed(const Vector &speed, Map *map = nullptr) override; bool usePixelPrecision() override { return false; } diff --git a/src/playerinfo.cpp b/src/playerinfo.cpp index 4d5074ee..aacff3a1 100644 --- a/src/playerinfo.cpp +++ b/src/playerinfo.cpp @@ -30,6 +30,8 @@ #include "net/inventoryhandler.h" #include "net/net.h" +#include "utils/time.h" + namespace PlayerInfo { class PlayerLogic; @@ -49,7 +51,7 @@ static bool mNPCPostCount = false; static BuySellState mBuySellState = BUYSELL_NONE; static std::map<int, Special> mSpecials; -static char mSpecialRechargeUpdateNeeded = 0; +static Timer mSpecialRechargeUpdateTimer; // --- Triggers --------------------------------------------------------------- @@ -312,9 +314,10 @@ bool isTalking() void logic() { - if ((mSpecialRechargeUpdateNeeded%11) == 0) + if (mSpecialRechargeUpdateTimer.passed()) { - mSpecialRechargeUpdateNeeded = 0; + mSpecialRechargeUpdateTimer.set(100); + for (auto &special : mSpecials) { special.second.currentMana += special.second.recharge; @@ -324,7 +327,6 @@ void logic() } } } - mSpecialRechargeUpdateNeeded++; } class PlayerLogic : EventListener diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp index d0e4a195..47577f9e 100644 --- a/src/playerrelations.cpp +++ b/src/playerrelations.cpp @@ -333,7 +333,7 @@ public: void ignore(Being *being, unsigned int flags) override { - being->setSpeech("...", 500); + being->setSpeech("...", 2000); } }; diff --git a/src/position.h b/src/position.h index 4622b8ed..c9c8e6f2 100644 --- a/src/position.h +++ b/src/position.h @@ -39,7 +39,6 @@ struct Position }; using Path = std::list<Position>; -using PathIterator = Path::iterator; /** * Appends a string representation of a position to the output stream. diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index 395024d5..1b507eab 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -571,7 +571,7 @@ static void readTileAnimation(xmlNodePtr tileNode, if (xmlStrEqual(frameNode->name, BAD_CAST "frame")) { const int tileId = XML::getProperty(frameNode, "tileid", 0); - const int duration = XML::getProperty(frameNode, "duration", 0) / 10; + const int duration = XML::getProperty(frameNode, "duration", 0); ani.addFrame(set->get(tileId), duration, 0, 0); } } diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp index 2d3634bb..161b50c9 100644 --- a/src/simpleanimation.cpp +++ b/src/simpleanimation.cpp @@ -71,11 +71,11 @@ void SimpleAnimation::setFrame(int frame) mCurrentFrame = mAnimation.getFrame(mAnimationPhase); } -void SimpleAnimation::update(int timePassed) +void SimpleAnimation::update(int dt) { if (mInitialized) { - mAnimationTime += timePassed; + mAnimationTime += dt; while (mAnimationTime > mCurrentFrame->delay && mCurrentFrame->delay > 0) { diff --git a/src/simpleanimation.h b/src/simpleanimation.h index a8fb4cba..6a7f899e 100644 --- a/src/simpleanimation.h +++ b/src/simpleanimation.h @@ -51,7 +51,7 @@ class SimpleAnimation final int getLength() const; - void update(int timePassed); + void update(int dt); bool draw(Graphics *graphics, int posX, int posY) const; @@ -64,12 +64,12 @@ class SimpleAnimation final private: void initializeAnimation(xmlNodePtr animationNode, - const std::string& dyePalettes = std::string()); + const std::string& dyePalettes = std::string()); /** The hosted animation. */ Animation mAnimation; - /** Time in game ticks the current frame is shown. */ + /** Time in milliseconds the current frame is shown. */ int mAnimationTime = 0; /** Index of current animation phase. */ |