eliminat param.game.item_size
This commit is contained in:
@@ -27,8 +27,10 @@ enum class ItemType : int {
|
||||
class Item {
|
||||
public:
|
||||
// --- Constantes ---
|
||||
static constexpr int COFFEE_MACHINE_WIDTH = 30; // Anchura de la máquina de café
|
||||
static constexpr int COFFEE_MACHINE_HEIGHT = 39; // Altura de la máquina de café
|
||||
static constexpr float WIDTH = 20.0F; // Anchura del item
|
||||
static constexpr float HEIGHT = 20.0F; // ALtura del item
|
||||
static constexpr int COFFEE_MACHINE_WIDTH = 30; // Anchura de la máquina de café
|
||||
static constexpr int COFFEE_MACHINE_HEIGHT = 39; // Altura de la máquina de café
|
||||
static constexpr float LIFETIME_DURATION_S = 10.0f; // Duración de vida del ítem en segundos
|
||||
|
||||
// Velocidades base (pixels/segundo) - Coffee Machine
|
||||
@@ -37,10 +39,10 @@ class Item {
|
||||
static constexpr float COFFEE_MACHINE_ACCEL_Y = 360.0F; // Aceleración Y de máquina de café (0.1*60²fps = 360 pixels/segundo²)
|
||||
|
||||
// Velocidades base (pixels/segundo) - Items normales
|
||||
static constexpr float ITEM_VEL_X_BASE = 60.0F; // Velocidad X base para items (1.0F*60fps)
|
||||
static constexpr float ITEM_VEL_X_STEP = 20.0F; // Incremento de velocidad X (0.33F*60fps)
|
||||
static constexpr float ITEM_VEL_Y = -240.0F; // Velocidad Y inicial de items (-4.0F*60fps)
|
||||
static constexpr float ITEM_ACCEL_Y = 720.0F; // Aceleración Y de items (0.2*60²fps = 720 pixels/segundo²)
|
||||
static constexpr float ITEM_VEL_X_BASE = 60.0F; // Velocidad X base para items (1.0F*60fps)
|
||||
static constexpr float ITEM_VEL_X_STEP = 20.0F; // Incremento de velocidad X (0.33F*60fps)
|
||||
static constexpr float ITEM_VEL_Y = -240.0F; // Velocidad Y inicial de items (-4.0F*60fps)
|
||||
static constexpr float ITEM_ACCEL_Y = 720.0F; // Aceleración Y de items (0.2*60²fps = 720 pixels/segundo²)
|
||||
|
||||
// Constantes de física de rebote
|
||||
static constexpr float BOUNCE_VEL_THRESHOLD = 60.0F; // Umbral de velocidad para parar (1.0F*60fps)
|
||||
@@ -49,14 +51,14 @@ class Item {
|
||||
static constexpr float HORIZONTAL_DAMPING = 0.75F; // Factor de amortiguación horizontal
|
||||
|
||||
// --- Constructor y destructor ---
|
||||
Item(ItemType type, float x, float y, SDL_FRect &play_area, const std::shared_ptr<Texture> &texture, const std::vector<std::string> &animation); // Constructor principal
|
||||
Item(ItemType type, float x, float y, SDL_FRect& play_area, const std::shared_ptr<Texture>& texture, const std::vector<std::string>& animation); // Constructor principal
|
||||
~Item() = default; // Destructor
|
||||
|
||||
// --- Métodos principales ---
|
||||
void alignTo(int x); // Centra el objeto en la posición X indicada
|
||||
void render(); // Renderiza el objeto en pantalla
|
||||
void disable(); // Desactiva el objeto
|
||||
void update(float deltaTime); // Actualiza la posición, animación y contadores (time-based)
|
||||
void alignTo(int x); // Centra el objeto en la posición X indicada
|
||||
void render(); // Renderiza el objeto en pantalla
|
||||
void disable(); // Desactiva el objeto
|
||||
void update(float deltaTime); // Actualiza la posición, animación y contadores (time-based)
|
||||
|
||||
// --- Getters ---
|
||||
[[nodiscard]] auto getPosX() const -> float { return pos_x_; } // Obtiene la posición X
|
||||
@@ -66,7 +68,7 @@ class Item {
|
||||
[[nodiscard]] auto getType() const -> ItemType { return type_; } // Obtiene el tipo
|
||||
[[nodiscard]] auto isEnabled() const -> bool { return enabled_; } // Verifica si está habilitado
|
||||
[[nodiscard]] auto isOnFloor() const -> bool { return floor_collision_; } // Verifica si está en el suelo
|
||||
auto getCollider() -> Circle & { return collider_; } // Obtiene el colisionador
|
||||
auto getCollider() -> Circle& { return collider_; } // Obtiene el colisionador
|
||||
|
||||
private:
|
||||
// --- Objetos y punteros ---
|
||||
@@ -82,9 +84,9 @@ class Item {
|
||||
float vel_y_; // Velocidad en el eje Y
|
||||
float accel_x_ = 0.0F; // Aceleración en el eje X
|
||||
float accel_y_; // Aceleración en el eje Y
|
||||
int width_; // Ancho del objeto
|
||||
int height_; // Alto del objeto
|
||||
float lifetime_timer_ = 0.0f; // Acumulador de tiempo de vida del ítem (segundos)
|
||||
float width_ = WIDTH; // Ancho del objeto
|
||||
float height_ = HEIGHT; // Alto del objeto
|
||||
float lifetime_timer_ = 0.0f; // Acumulador de tiempo de vida del ítem (segundos)
|
||||
bool floor_collision_ = false; // Indica si el objeto colisiona con el suelo
|
||||
bool enabled_ = true; // Indica si el objeto está habilitado
|
||||
|
||||
@@ -92,6 +94,6 @@ class Item {
|
||||
void shiftColliders(); // Alinea el círculo de colisión con la posición del objeto
|
||||
void shiftSprite(); // Coloca el sprite en la posición del objeto
|
||||
void move(float deltaTime); // Actualiza la posición y estados del objeto (time-based)
|
||||
void updateTimeToLive(float deltaTime); // Actualiza el contador de tiempo de vida (time-based)
|
||||
void updateTimeToLive(float deltaTime); // Actualiza el contador de tiempo de vida (time-based)
|
||||
static auto getCoffeeMachineSpawn(int player_x, int item_width, int area_width, int margin = 2) -> int; // Calcula la zona de aparición de la máquina de café
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user