linter
This commit is contained in:
@@ -29,14 +29,14 @@ Item::Item(ItemType type, float x, float y, SDL_FRect& play_area, const std::sha
|
||||
pos_x_ = x;
|
||||
pos_y_ = y;
|
||||
// 6 velocidades: 3 negativas (-1.0, -0.66, -0.33) y 3 positivas (0.33, 0.66, 1.0)
|
||||
const int direction = rand() % 6;
|
||||
if (direction < 3) {
|
||||
const int DIRECTION = rand() % 6;
|
||||
if (DIRECTION < 3) {
|
||||
// Velocidades negativas: -1.0, -0.66, -0.33
|
||||
vel_x_ = -ITEM_VEL_X_BASE + (direction * ITEM_VEL_X_STEP);
|
||||
vel_x_ = -ITEM_VEL_X_BASE + (DIRECTION * ITEM_VEL_X_STEP);
|
||||
rotate_speed_ = -720.0F;
|
||||
} else {
|
||||
// Velocidades positivas: 0.33, 0.66, 1.0
|
||||
vel_x_ = ITEM_VEL_X_STEP + ((direction - 3) * ITEM_VEL_X_STEP);
|
||||
vel_x_ = ITEM_VEL_X_STEP + ((DIRECTION - 3) * ITEM_VEL_X_STEP);
|
||||
rotate_speed_ = 720.0F;
|
||||
}
|
||||
vel_y_ = ITEM_VEL_Y;
|
||||
@@ -71,33 +71,33 @@ void Item::alignTo(int x) {
|
||||
void Item::render() {
|
||||
if (enabled_) {
|
||||
// Muestra normalmente hasta los últimos ~3.3 segundos
|
||||
constexpr float BLINK_START_S = LIFETIME_DURATION_S - 3.33f;
|
||||
constexpr float BLINK_START_S = LIFETIME_DURATION_S - 3.33F;
|
||||
|
||||
if (lifetime_timer_ < BLINK_START_S) {
|
||||
sprite_->render();
|
||||
} else {
|
||||
// Efecto de parpadeo en los últimos segundos (cada ~0.33 segundos)
|
||||
constexpr float BLINK_INTERVAL_S = 0.33f;
|
||||
const float phase = fmod(lifetime_timer_, BLINK_INTERVAL_S);
|
||||
const float half_interval = BLINK_INTERVAL_S / 2.0f;
|
||||
constexpr float BLINK_INTERVAL_S = 0.33F;
|
||||
const float PHASE = std::fmod(lifetime_timer_, BLINK_INTERVAL_S);
|
||||
const float HALF_INTERVAL = BLINK_INTERVAL_S / 2.0F;
|
||||
|
||||
if (phase < half_interval) {
|
||||
if (PHASE < HALF_INTERVAL) {
|
||||
sprite_->render();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Item::move(float deltaTime) {
|
||||
void Item::move(float delta_time) {
|
||||
floor_collision_ = false;
|
||||
|
||||
// Calcula la nueva posición usando deltaTime (velocidad en pixels/segundo)
|
||||
pos_x_ += vel_x_ * deltaTime;
|
||||
pos_y_ += vel_y_ * deltaTime;
|
||||
pos_x_ += vel_x_ * delta_time;
|
||||
pos_y_ += vel_y_ * delta_time;
|
||||
|
||||
// Aplica las aceleraciones a la velocidad usando deltaTime (aceleración en pixels/segundo²)
|
||||
vel_x_ += accel_x_ * deltaTime;
|
||||
vel_y_ += accel_y_ * deltaTime;
|
||||
vel_x_ += accel_x_ * delta_time;
|
||||
vel_y_ += accel_y_ * delta_time;
|
||||
|
||||
// Comprueba los laterales de la zona de juego
|
||||
const float MIN_X = param.game.play_area.rect.x;
|
||||
@@ -160,14 +160,14 @@ void Item::move(float deltaTime) {
|
||||
|
||||
void Item::disable() { enabled_ = false; }
|
||||
|
||||
void Item::update(float deltaTime) {
|
||||
move(deltaTime);
|
||||
sprite_->update(deltaTime);
|
||||
updateTimeToLive(deltaTime);
|
||||
void Item::update(float delta_time) {
|
||||
move(delta_time);
|
||||
sprite_->update(delta_time);
|
||||
updateTimeToLive(delta_time);
|
||||
}
|
||||
|
||||
void Item::updateTimeToLive(float deltaTime) {
|
||||
lifetime_timer_ += deltaTime;
|
||||
void Item::updateTimeToLive(float delta_time) {
|
||||
lifetime_timer_ += delta_time;
|
||||
if (lifetime_timer_ >= LIFETIME_DURATION_S) {
|
||||
disable();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user