From 81e4f170d8ba4ccbcfa1e6c07bd0522dfc3b6e08 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Thu, 22 Feb 2024 13:02:26 +0100 Subject: General code cleanups * Use default member initializers * Use range-based loops * Don't use 'else' after 'return' * Removed some unused includes * Construct empty strings with std::string() instead of "" * Clear strings with .clear() instead of assigning "" * Check whether strings are empty with .empty() instead of comparing to "" * Removed redundant initializations --- src/animatedsprite.h | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'src/animatedsprite.h') diff --git a/src/animatedsprite.h b/src/animatedsprite.h index 67d3f300..f2e7a9ff 100644 --- a/src/animatedsprite.h +++ b/src/animatedsprite.h @@ -24,7 +24,6 @@ #include "sprite.h" -#include #include class Animation; @@ -60,7 +59,7 @@ class AnimatedSprite : public Sprite bool update(int time) override; - bool draw(Graphics* graphics, int posX, int posY) const override; + bool draw(Graphics *graphics, int posX, int posY) const override; int getWidth() const override; @@ -74,9 +73,6 @@ class AnimatedSprite : public Sprite bool setDirection(SpriteDirection direction) override; - int getNumberOfLayers() - { return 1; } - virtual bool drawnWhenBehind() const { return true; } @@ -85,16 +81,16 @@ class AnimatedSprite : public Sprite private: bool updateCurrentAnimation(unsigned int dt); - SpriteDirection mDirection; /**< The sprite direction. */ - int mLastTime; /**< The last time update was called. */ + SpriteDirection mDirection = DIRECTION_DOWN; /**< The sprite direction. */ + int mLastTime = 0; /**< The last time update was called. */ - int mFrameIndex; /**< The index of the current frame. */ - int mFrameTime; /**< The time since start of frame. */ + int mFrameIndex = 0; /**< The index of the current frame. */ + int mFrameTime = 0; /**< The time since start of frame. */ - SpriteDef *mSprite; /**< The sprite definition. */ - Action *mAction; /**< The currently active action. */ - Animation *mAnimation; /**< The currently active animation. */ - Frame *mFrame; /**< The currently active frame. */ + SpriteDef *mSprite; /**< The sprite definition. */ + Action *mAction = nullptr; /**< The currently active action. */ + Animation *mAnimation = nullptr; /**< The currently active animation. */ + Frame *mFrame = nullptr; /**< The currently active frame. */ }; #endif -- cgit v1.2.3-70-g09d2