revisat intro.cpp, path_sprite i writer.cpp
This commit is contained in:
@@ -29,8 +29,8 @@ struct Path { // Define un re
|
||||
float end_pos; // Posición final
|
||||
PathType type; // Tipo de movimiento (horizontal/vertical)
|
||||
float fixed_pos; // Posición fija en el eje contrario
|
||||
float duration_ms; // Duración de la animación en milisegundos
|
||||
float waiting_time_ms; // Tiempo de espera una vez en el destino
|
||||
float duration_s; // Duración de la animación en segundos
|
||||
float waiting_time_s; // Tiempo de espera una vez en el destino
|
||||
std::function<double(double)> easing_function; // Función de easing
|
||||
float elapsed_time = 0.0f; // Tiempo transcurrido
|
||||
float waiting_elapsed = 0.0f; // Tiempo de espera transcurrido
|
||||
@@ -40,10 +40,10 @@ struct Path { // Define un re
|
||||
// Constructor para paths generados
|
||||
Path(float start, float end, PathType path_type, float fixed, float duration, float waiting, std::function<double(double)> easing)
|
||||
: start_pos(start), end_pos(end), type(path_type), fixed_pos(fixed),
|
||||
duration_ms(duration), waiting_time_ms(waiting), easing_function(std::move(easing)) {}
|
||||
duration_s(duration), waiting_time_s(waiting), easing_function(std::move(easing)) {}
|
||||
|
||||
// Constructor para paths por puntos (mantenemos compatibilidad)
|
||||
Path(const std::vector<SDL_FPoint> &spots_init, int waiting_counter_init);
|
||||
// Constructor para paths por puntos (convertido a segundos)
|
||||
Path(const std::vector<SDL_FPoint> &spots_init, float waiting_time_s_init);
|
||||
|
||||
// Variables para paths por puntos
|
||||
std::vector<SDL_FPoint> spots; // Solo para paths por puntos
|
||||
@@ -63,14 +63,13 @@ class PathSprite : public Sprite {
|
||||
~PathSprite() override = default;
|
||||
|
||||
// --- Métodos principales ---
|
||||
void update(); // Actualiza la posición del sprite según el recorrido (compatibilidad)
|
||||
void update(float delta_time); // Actualiza la posición del sprite según el recorrido
|
||||
void update(float delta_time); // Actualiza la posición del sprite según el recorrido (delta_time en segundos)
|
||||
void render() override; // Muestra el sprite por pantalla
|
||||
|
||||
// --- Gestión de recorridos ---
|
||||
void addPath(Path path, bool centered = false); // Añade un recorrido (Path)
|
||||
void addPath(const std::vector<SDL_FPoint> &spots, int waiting_counter = 0); // Añade un recorrido a partir de puntos
|
||||
void addPath(int start, int end, PathType type, int fixed_pos, int steps, const std::function<double(double)> &easing_function, int waiting_counter = 0); // Añade un recorrido generado
|
||||
void addPath(const std::vector<SDL_FPoint> &spots, float waiting_time_s = 0.0f); // Añade un recorrido a partir de puntos
|
||||
void addPath(float start, float end, PathType type, float fixed_pos, float duration_s, const std::function<double(double)> &easing_function, float waiting_time_s = 0.0f); // Añade un recorrido generado
|
||||
|
||||
// --- Estado y control ---
|
||||
void enable(); // Habilita el objeto
|
||||
|
||||
Reference in New Issue
Block a user