#pragma once #include // Para SDL_Point #include // Para function #include // Para shared_ptr #include // Para vector #include "sprite.h" // Para Sprite class Texture; // lines 8-8 enum class PathType { VERTICAL, HORIZONTAL, }; enum class PathCentered { ON_X, ON_Y, NONE, }; // 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) {} }; // Devuelve un vector con los puntos que conforman la ruta std::vector createPath(int start, int end, PathType type, int fixed_pos, int steps, const std::function &easingFunction); // Clase PathSprite class PathSprite : public Sprite { private: // Variables bool enabled_ = false; // Indica si el objeto está habilitado bool has_finished_ = false; // Indica si el objeto ha finalizado el recorrido int current_path_ = 0; // Path que se está recorriendo actualmente std::vector paths_; // Caminos a recorrer por el sprite // Coloca el sprite en los diferentes puntos del recorrido void moveThroughCurrentPath(); // Cambia de recorrido o finaliza void goToNextPathOrDie(); public: // Constructor explicit PathSprite(std::shared_ptr texture) : Sprite(texture) {} // Destructor ~PathSprite() override = default; // Actualiza la posición del sprite void update(); // Muestra el sprite por pantalla void render() override; // Añade un recorrido void addPath(Path path, bool centered = false); void addPath(std::vector spots, int waiting_counter = 0); void addPath(int start, int end, PathType type, int fixed_pos, int steps, const std::function &easingFunction, int waiting_counter = 0); // Habilita el objeto void enable(); // Indica si ha terminado todos los recorridos bool hasFinished(); // Getters int getCurrentPath() const { return current_path_; } };