forked from jaildesigner-jailgames/jaildoctors_dilemma
4 merdes fetes en la feina pr avorriment
This commit is contained in:
@@ -91,7 +91,7 @@ void Player::handleInput(float delta_time) {
|
||||
// Ya que se coloca el estado STANDING al cambiar de pantalla
|
||||
|
||||
if (isOnFloor() || isOnAutoSurface()) {
|
||||
setState(State::JUMPING);
|
||||
transitionToState(State::JUMPING);
|
||||
vy_ = JUMP_VELOCITY;
|
||||
last_grounded_position_ = static_cast<int>(y_);
|
||||
}
|
||||
@@ -136,7 +136,7 @@ void Player::handleState(float delta_time) {
|
||||
// Si no tiene suelo debajo y no está en rampa descendente -> FALLING
|
||||
if (!isOnFloor() && !isOnAutoSurface() && !isOnDownSlope()) {
|
||||
last_grounded_position_ = static_cast<int>(y_); // Guarda Y actual al SALIR de STANDING
|
||||
setState(State::FALLING); // setState() establece vx_=0, vy_=MAX_VY
|
||||
transitionToState(State::FALLING); // setState() establece vx_=0, vy_=MAX_VY
|
||||
playFallSound();
|
||||
}
|
||||
} else if (state_ == State::JUMPING) {
|
||||
@@ -149,12 +149,12 @@ void Player::switchBorders() {
|
||||
switch (border_) {
|
||||
case Room::Border::TOP:
|
||||
y_ = PLAY_AREA_BOTTOM - HEIGHT - TILE_SIZE;
|
||||
setState(State::STANDING);
|
||||
transitionToState(State::STANDING);
|
||||
break;
|
||||
|
||||
case Room::Border::BOTTOM:
|
||||
y_ = PLAY_AREA_TOP;
|
||||
setState(State::STANDING);
|
||||
transitionToState(State::STANDING);
|
||||
break;
|
||||
|
||||
case Room::Border::RIGHT:
|
||||
@@ -278,7 +278,7 @@ void Player::moveVerticalUp(float delta_time) {
|
||||
// Si hay colisión lo mueve hasta donde no colisiona
|
||||
// Regla: Si está JUMPING y tropieza contra el techo -> FALLING
|
||||
y_ = POS + 1;
|
||||
setState(State::FALLING);
|
||||
transitionToState(State::FALLING);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,7 +305,7 @@ void Player::moveVerticalDown(float delta_time) {
|
||||
is_alive_ = false; // Muere si cae más de 32 píxeles
|
||||
}
|
||||
|
||||
setState(State::STANDING);
|
||||
transitionToState(State::STANDING);
|
||||
last_grounded_position_ = static_cast<int>(y_); // Actualizar AL ENTRAR en STANDING
|
||||
// Deja de estar enganchado a la superficie automatica
|
||||
auto_movement_ = false;
|
||||
@@ -329,7 +329,7 @@ void Player::moveVerticalDown(float delta_time) {
|
||||
is_alive_ = false; // Muere si cae más de 32 píxeles
|
||||
}
|
||||
|
||||
setState(State::STANDING);
|
||||
transitionToState(State::STANDING);
|
||||
last_grounded_position_ = static_cast<int>(y_); // Actualizar AL ENTRAR en STANDING
|
||||
} else {
|
||||
// No está saltando y no hay colisón con una rampa
|
||||
@@ -358,7 +358,7 @@ void Player::move(float delta_time) {
|
||||
|
||||
// Si ha salido del suelo, el jugador cae
|
||||
if (state_ == State::STANDING && !isOnFloor()) {
|
||||
setState(State::FALLING);
|
||||
transitionToState(State::FALLING);
|
||||
auto_movement_ = false;
|
||||
}
|
||||
|
||||
@@ -392,7 +392,7 @@ void Player::handleJumpEnd() {
|
||||
// Si el jugador vuelve EXACTAMENTE a la altura inicial, debe CONTINUAR en JUMPING
|
||||
// Solo cuando la SUPERA (desciende más allá) cambia a FALLING
|
||||
if (state_ == State::JUMPING && vy_ > 0.0F && static_cast<int>(y_) > last_grounded_position_) {
|
||||
setState(State::FALLING);
|
||||
transitionToState(State::FALLING);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -551,7 +551,7 @@ void Player::updateFeet() {
|
||||
}
|
||||
|
||||
// Cambia el estado del jugador
|
||||
void Player::setState(State value) {
|
||||
void Player::transitionToState(State value) {
|
||||
previous_state_ = state_;
|
||||
state_ = value;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user