#ifndef Sprite_h_ #define Sprite_h_ #include #include #include #include #include #include #include #include "Node.hpp" #include "Box.hpp" #include "Animation.hpp" #include "extension.hpp" struct Game; struct Frameset; struct Sprite : Node { std::vector frames; std::vector frame_paths; Box box; Animation frame_animation = Animation(&Sprite::advance_frame, this); Animation blink_animation = Animation(&Sprite::toggle_hidden, this, 500); bool hidden = false; glm::vec2 step = {0, 0}; Uint8 alpha_mod = 255; std::map framesets; std::string current_frameset_name; Sprite(); Sprite(Node*); Sprite(Node*, std::string); void set_frame_length(float); void associate(std::string); void load(); void load_file(fs::path); void add_frame(SDL_Texture*); Frameset& get_all_frames_frameset(); Frameset& add_frameset(std::string); void set_frameset(std::string); Frameset& get_current_frameset(); void update_size(); bool is_loaded() const; void unload(); void advance_frame(); void hide(); void unhide(); void toggle_hidden(); bool is_hidden() const; void set_step(glm::vec2); float get_w() const; float get_h() const; glm::vec2 get_size() const; float get_top() const; float get_right() const; float get_bottom() const; float get_left() const; glm::vec2 get_nw() const; glm::vec2 get_north() const; glm::vec2 get_west() const; void set_nw(const glm::vec2&); void move(glm::vec2, bool = true); void update(); std::string get_class_name() { return "Sprite"; } ~Sprite() { unload(); } }; struct Frameset { Sprite* sprite; std::vector order; int current_index = 0; float frame_length = 0; bool reversed = false; glm::vec2 size; Frameset(); Frameset(Sprite*); void add_frame_index(int); void add_frame_indicies(const std::vector&); void set_frame_length(float); float get_frame_length() const; void reset(); void clear(); int get_current_frame_index() const; glm::vec2 measure() const; void set_size(); void set_size(const glm::vec2&); const glm::vec2& get_size() const; void step(); void increment_index(); void increment_index(int); int get_frame_count() const; void reverse(); }; #include "Game.hpp" #endif