42 lines
2.2 KiB
C++
42 lines
2.2 KiB
C++
#pragma once
|
|
|
|
#include <SDL3/SDL.h>
|
|
|
|
#include "core/rendering/animatedsprite.h" // for AnimatedSprite
|
|
class Texture;
|
|
|
|
// Clase SmartSprite
|
|
class SmartSprite : public AnimatedSprite {
|
|
public:
|
|
SmartSprite(Texture *texture, SDL_Renderer *renderer); // Constructor
|
|
|
|
void init(); // Inicializa el objeto
|
|
void update() override; // Actualiza la posicion (frame-based)
|
|
void update(float dt_s) override; // Actualiza la posicion (time-based)
|
|
void render() override; // Pinta el objeto en pantalla
|
|
|
|
[[nodiscard]] auto getEnabledCounter() const -> int; // Obtiene el valor de la variable
|
|
void setEnabledCounter(int value); // Establece el valor de la variable
|
|
void setRemainingTime(float seconds); // Time-based: temps que es queda visible despres d'arribar al desti
|
|
[[nodiscard]] auto getRemainingTime() const -> float; // Time-based: temps restant
|
|
void setDestX(int x); // Establece el valor de la variable
|
|
void setDestY(int y); // Establece el valor de la variable
|
|
[[nodiscard]] auto getDestX() const -> int; // Obtiene el valor de la variable
|
|
[[nodiscard]] auto getDestY() const -> int; // Obtiene el valor de la variable
|
|
[[nodiscard]] auto isOnDestination() const -> bool; // Obtiene el valor de la variable
|
|
[[nodiscard]] auto hasFinished() const -> bool; // Obtiene el valor de la variable
|
|
|
|
private:
|
|
// Variables
|
|
bool on_destination_; // Indica si está en el destino
|
|
int dest_x_; // Posicion de destino en el eje X
|
|
int dest_y_; // Posicion de destino en el eje Y
|
|
int enabled_counter_; // Contador per a deshabilitar-lo (frame-based)
|
|
float remaining_time_s_{0.0F}; // Temps restant per a deshabilitar-lo (time-based)
|
|
bool finished_; // Indica si ya ha terminado
|
|
|
|
void checkMove(); // Comprueba el movimiento
|
|
void checkFinished(); // Comprueba si ha terminado (frame-based)
|
|
void checkFinishedTimeBased(float dt_s); // Comprueba si ha terminado (time-based)
|
|
};
|