fix: bug mileanri que deixava al jugador atascat en algunes rampes en certes condicions
This commit is contained in:
@@ -136,6 +136,10 @@ void Player::transitionToState(State state) {
|
||||
handleDeathByFalling();
|
||||
resetSoundControllersOnLanding();
|
||||
updateCurrentSlope();
|
||||
if (current_slope_ == nullptr) {
|
||||
// Los pies no coinciden con ninguna rampa: tratar como suelo plano
|
||||
state_ = State::ON_GROUND;
|
||||
}
|
||||
break;
|
||||
case State::JUMPING:
|
||||
// Puede saltar desde ON_GROUND o ON_SLOPE
|
||||
@@ -248,14 +252,15 @@ void Player::moveOnSlope(float delta_time) {
|
||||
// Determinama cuál debe ser la velocidad a partir de automovement o de wanna_go_
|
||||
updateVelocity();
|
||||
|
||||
if (vx_ == 0.0F) { return; }
|
||||
|
||||
// Verificar que tenemos una rampa válida
|
||||
// Verificar rampa válida antes de comprobar velocidad: si no hay rampa siempre caer,
|
||||
// independientemente de si hay o no input (evita bloqueo con vx_=0 y slope null)
|
||||
if (current_slope_ == nullptr) {
|
||||
transitionToState(State::FALLING);
|
||||
return;
|
||||
}
|
||||
|
||||
if (vx_ == 0.0F) { return; }
|
||||
|
||||
// Determinar el tipo de rampa
|
||||
const bool IS_LEFT_SLOPE = isLeftSlope();
|
||||
|
||||
@@ -588,6 +593,7 @@ void Player::updateCurrentSlope() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
if (current_slope_ != nullptr) {
|
||||
Debug::get()->set("sl.type", isLeftSlope() ? "L\\" : "R/");
|
||||
|
||||
@@ -262,7 +262,7 @@ auto checkCollision(const LineDiagonal& l1, const LineVertical& l2) -> SDL_Point
|
||||
const float X = X1 + (u_a * (X2 - X1));
|
||||
const float Y = Y1 + (u_a * (Y2 - Y1));
|
||||
|
||||
return {.x = static_cast<int>(X), .y = static_cast<int>(Y)};
|
||||
return {.x = static_cast<int>(std::round(X)), .y = static_cast<int>(std::round(Y))};
|
||||
}
|
||||
return {.x = -1, .y = -1};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user