diff --git a/source/player.cpp b/source/player.cpp index 6d969d8..f9349d4 100644 --- a/source/player.cpp +++ b/source/player.cpp @@ -240,35 +240,20 @@ void Player::move() // Comprueba colisiones con rampas else { - tile_e slope = checkUpSlopes(); + tile_e slope = checkSlopes(); if (slope != t_empty) - { // Se mueve hacia la derecha y cuesta hacia la derecha - if (sprite->getFlip() == SDL_FLIP_NONE && slope == t_slope_r) + { // Cuesta hacia la derecha + if (slope == t_slope_r) { // Recoloca y = -h + room->getSlopeHeight(feet[1], t_slope_r); } - // Se mueve hacia la izquierda y cuesta hacia la izquierda - if (sprite->getFlip() == SDL_FLIP_HORIZONTAL && slope == t_slope_l) + // Cuesta hacia la izquierda + if (slope == t_slope_l) { // Recoloca y = -h + room->getSlopeHeight(feet[0], t_slope_l); } } - - slope = checkDownSlopes(); - if (slope != t_empty) - { // Se mueve hacia la derecha y cuesta hacia la izquierda - if (sprite->getFlip() == SDL_FLIP_NONE && slope == t_slope_l) - { // Recoloca - y = -h + room->getSlopeHeight(underFeet[0], t_slope_l); - } - - // Se mueve hacia la izquierda y cuesta hacia la derecha - if (sprite->getFlip() == SDL_FLIP_HORIZONTAL && slope == t_slope_r) - { // Recoloca - y = -h + room->getSlopeHeight(underFeet[1], t_slope_r); - } - } } y += vy; @@ -345,7 +330,7 @@ void Player::move() } } // EXPERIMENTAL - else if (checkUpSlopes() || checkDownSlopes()) + else if (checkSlopes()) { state = s_standing; vy = 0.0f; @@ -413,7 +398,7 @@ bool Player::checkWalls() } // Comprueba si el jugador está en una rampa -tile_e Player::checkUpSlopes() +tile_e Player::checkSlopes() { // Actualiza los puntos de colisión updateFeet(); @@ -441,35 +426,6 @@ tile_e Player::checkUpSlopes() return t_empty; } -// Comprueba si el jugador está en una rampa -tile_e Player::checkDownSlopes() -{ - // Actualiza los puntos de colisión - updateFeet(); - - bool slope_l = false; - bool slope_r = false; - - // Comprueba si ha colisionado con una rampa - for (auto f : underFeet) - { - slope_l |= (room->getTile(f) == t_slope_l); - slope_r |= (room->getTile(f) == t_slope_r); - } - - if (slope_l) - { - return t_slope_l; - } - - if (slope_r) - { - return t_slope_r; - } - - return t_empty; -} - // Obtiene algunos parametros del jugador player_t Player::getSpawnParams() { diff --git a/source/player.h b/source/player.h index 0719f68..a1ffdbb 100644 --- a/source/player.h +++ b/source/player.h @@ -91,10 +91,7 @@ public: bool checkWalls(); // Comprueba si el jugador está en una rampa - tile_e checkUpSlopes(); - - // Comprueba si el jugador está en una rampa - tile_e checkDownSlopes(); + tile_e checkSlopes(); // Actualiza los puntos de colisión void updateColliderPoints();