migrat Game, Player i Item a time based

This commit is contained in:
2025-10-28 10:52:13 +01:00
parent 9e8c5e13df
commit 31c84f9676
8 changed files with 190 additions and 153 deletions

View File

@@ -24,15 +24,16 @@ class Item {
private:
// Constantes
static constexpr float ITEM_SIZE = 8;
static constexpr float COLOR_CHANGE_INTERVAL = 0.06F; // Intervalo de cambio de color en segundos (4 frames a 66.67fps)
// Objetos y punteros
std::shared_ptr<SurfaceSprite> sprite_; // SSprite del objeto
// Variables
std::vector<Uint8> color_; // Vector con los colores del objeto
int counter_; // Contador interno
SDL_FRect collider_; // Rectangulo de colisión
int change_color_speed_; // Cuanto mas alto, mas tarda en cambiar de color
std::vector<Uint8> color_; // Vector con los colores del objeto
float time_accumulator_; // Acumulador de tiempo para cambio de color
SDL_FRect collider_; // Rectangulo de colisión
bool is_paused_; // Indica si el item está pausado
public:
// Constructor
@@ -45,7 +46,10 @@ class Item {
void render() const;
// Actualiza las variables del objeto
void update() { counter_++; }
void update(float delta_time);
// Pausa/despausa el item
void setPaused(bool paused) { is_paused_ = paused; }
// Obtiene el rectangulo de colision del objeto
auto getCollider() -> SDL_FRect& { return collider_; }