From be09120d1d044b476ef8b516efbdb526f20d9e2d Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Wed, 3 Feb 2021 01:35:58 -0500 Subject: Added animation system --- src/sprite.h | 46 +++++++++++++--------------------------------- 1 file changed, 13 insertions(+), 33 deletions(-) (limited to 'src/sprite.h') diff --git a/src/sprite.h b/src/sprite.h index dc26fad..e842192 100644 --- a/src/sprite.h +++ b/src/sprite.h @@ -17,39 +17,19 @@ struct SpriteFrame { class Sprite { public: - Sprite(std::string_view filename, Renderer& renderer); - - int getTextureId() const { - return textureId_; - } - - const vec2i& loc() const { return loc_; } - - vec2i& loc() { return loc_; } - - const SpriteFrame& getFrame() const { return frames_.at(animations_[curAnim_][curFrame_]); } - - void setDirection(Direction dir); - - Direction getDirection() const { return curDir_; } - - void setState(std::string state); - - void tickAnim(); - -private: - - void updateAnimation(); - - int textureId_; - vec2i loc_ { 0, 0 }; - Direction curDir_ = Direction::down; - std::string state_; - int curAnim_ = 0; - int curFrame_ = 0; - std::vector frames_; - std::vector> animations_; - std::map> stateDirToAnim_; + // Transform + vec2i loc { 0, 0 }; + + // Animation + bool isAnimated = false; + int textureId; + Direction dir = Direction::down; + std::string animationName; + int animationId = 0; + int animationFrame = 0; + std::vector frames; + std::vector> animations; + std::map> nameDirToAnim; }; #endif /* end of include guard: SPRITE_H_70503825 */ -- cgit 1.4.1