#pragma once #include // para shared_ptr #include "animated_sprite.h" // para SpriteAnimated class Texture; // Clase PathSprite class PathSprite : public AnimatedSprite { private: // Estructuras struct Path { std::vector spots; // Puntos por los que se desplazará el sprite int waiting_counter; // Tiempo de espera una vez en el destino bool on_destination = false; // Indica si ha llegado al destino bool finished = false; // Indica si ha terminado de esperarse int counter = 0; // Contador interno // Constructor Path(const std::vector &spots_init, int waiting_counter_init) : spots(spots_init), waiting_counter(waiting_counter_init) {} }; // Variables bool finished_ = false; // Indica si ya ha terminado bool enabled_ = false; // Indica si el objeto está habilitado int current_path_ = 0; // Path que se está recorriendo actualmente std::vector paths_; // Caminos a recorrer por el sprite // Devuelve un vector con los puntos que conforman la ruta std::vector createVerticalPath(SDL_Point start, SDL_Point end, int steps); // Devuelve un vector con los puntos que conforman la ruta std::vector createHorizontalPath(SDL_Point start, SDL_Point end, int steps); void moveThroughCurrentPath(); void goToNextPathOrDie(); public: // Constructor explicit PathSprite(std::shared_ptr texture); // Destructor ~PathSprite() = default; // Actualiza la posición del sprite void update() override; // Añade un path vertical void addVerticalPath(SDL_Point start, SDL_Point end, int steps, int waiting_counter); // Añade un path horizontal void addHorizontalPath(SDL_Point start, SDL_Point end, int steps, int waiting_counter); // Habilita el objeto void enable(); // Indica si ha terminado todos los recorridos bool hasFinished(); };