fix: bug en el editor al crear habitacions noves
This commit is contained in:
@@ -691,16 +691,24 @@ void Player::updateVelocity(float delta_time) {
|
||||
if (target > 0.0F) { sprite_->setFlip(Flip::RIGHT); }
|
||||
else if (target < 0.0F) { sprite_->setFlip(Flip::LEFT); }
|
||||
|
||||
// En el aire: inercia (interpolación gradual). En suelo/rampa: respuesta inmediata.
|
||||
// Inercia:
|
||||
// - En el aire: inercia completa (arranque y frenada graduales)
|
||||
// - En suelo/rampa: arranque instantáneo, frenada gradual
|
||||
const float STEP = HORIZONTAL_ACCEL * delta_time;
|
||||
if (state_ == State::ON_AIR) {
|
||||
const float STEP = HORIZONTAL_ACCEL * delta_time;
|
||||
if (vx_ < target) {
|
||||
vx_ = std::min(vx_ + STEP, target);
|
||||
} else if (vx_ > target) {
|
||||
vx_ = std::max(vx_ - STEP, target);
|
||||
}
|
||||
} else {
|
||||
vx_ = target;
|
||||
if (target != 0.0F) {
|
||||
vx_ = target; // Arranque instantáneo
|
||||
} else if (vx_ > 0.0F) {
|
||||
vx_ = std::max(vx_ - STEP, 0.0F); // Frenada gradual
|
||||
} else if (vx_ < 0.0F) {
|
||||
vx_ = std::min(vx_ + STEP, 0.0F); // Frenada gradual
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user