diff --git a/source/core/system/director.cpp b/source/core/system/director.cpp index b6e77fd..5c3cb04 100644 --- a/source/core/system/director.cpp +++ b/source/core/system/director.cpp @@ -334,7 +334,7 @@ auto Director::run() -> int { break; case SceneManager::Scene::LOADING_SCREEN: - runLogo(); + runLoadingScreen(); break; case SceneManager::Scene::TITLE: diff --git a/source/game/entities/player.cpp b/source/game/entities/player.cpp index 177d2c1..8f1fa50 100644 --- a/source/game/entities/player.cpp +++ b/source/game/entities/player.cpp @@ -63,19 +63,18 @@ void Player::move(float delta_time) { void Player::handleHorizontalMovement(float delta_time) { if (state_ == State::STANDING) { - // 1. Primero, determinamos cuál debe ser la velocidad (vx_) + // Determinama cuál debe ser la velocidad a partir de automovement o de wannaGo updateVelocity(); } - // 2. Ahora, aplicamos el movimiento y el flip basado en la velocidad resultante + // Aplica el movimiento y el flip basado en la velocidad resultante if (vx_ < 0.0F) { - moveHorizontal(delta_time, -1); + moveHorizontal(delta_time, Direction::LEFT); sprite_->setFlip(SDL_FLIP_HORIZONTAL); } else if (vx_ > 0.0F) { - moveHorizontal(delta_time, 1); + moveHorizontal(delta_time, Direction::RIGHT); sprite_->setFlip(SDL_FLIP_NONE); } - // Si vx_ es 0.0F, no se llama a moveHorizontal, lo cual es correcto. } void Player::handleVerticalMovement(float delta_time) { @@ -95,9 +94,6 @@ void Player::handleVerticalMovement(float delta_time) { } } -void Player::moveAndCollide(float delta_time) { -} - void Player::handleConveyorBelts() { if (!auto_movement_ and isOnConveyorBelt() and wannaGo == Direction::STAY) { auto_movement_ = true; @@ -200,9 +196,7 @@ void Player::handleState(float delta_time) { } else if (state_ == State::STANDING) { // Si no tiene suelo debajo y no está en rampa descendente -> FALLING if (!isOnFloor() && !isOnConveyorBelt() && !isOnDownSlope()) { - last_grounded_position_ = static_cast(y_); // Guarda Y actual al SALIR de STANDING transitionToState(State::FALLING); // setState() establece vx_=0, vy_=MAX_VY - playFallSound(delta_time); } } else if (state_ == State::JUMPING) { playJumpSound(delta_time); @@ -251,8 +245,7 @@ void Player::applyGravity(float delta_time) { } // Maneja el movimiento sobre rampas -// direction: -1 para izquierda, 1 para derecha -void Player::handleSlopeMovement(int direction) { +void Player::handleSlopeMovement(Direction direction) { // No procesa rampas durante el salto (permite atravesarlas cuando salta con movimiento horizontal) // Pero SÍ procesa en STANDING y FALLING (para pegarse a las rampas) if (state_ == State::JUMPING) { @@ -267,16 +260,16 @@ void Player::handleSlopeMovement(int direction) { // Regla: Si está STANDING y tropieza lateralmente con una Slope, se pega a la slope // Comprueba si hay rampa en contacto lateral (solo los dos pixels inferiores) - const int SIDE_X = direction < 0 ? static_cast(x_) : static_cast(x_) + WIDTH - 1; + const int SIDE_X = direction == Direction::LEFT ? static_cast(x_) : static_cast(x_) + WIDTH - 1; const LineVertical SIDE = { .x = SIDE_X, .y1 = static_cast(y_) + HEIGHT - 2, .y2 = static_cast(y_) + HEIGHT - 1}; // Comprueba la rampa correspondiente según la dirección - const int SLOPE_Y = direction < 0 ? room_->checkLeftSlopes(&SIDE) : room_->checkRightSlopes(&SIDE); + const int SLOPE_Y = direction == Direction::LEFT ? room_->checkLeftSlopes(SIDE) : room_->checkRightSlopes(SIDE); - if (SLOPE_Y > -1) { + if (SLOPE_Y != Collision::NONE) { // Hay rampa: sube al jugador para pegarlo a la rampa // --- INICIO DE LA CORRECCIÓN --- @@ -300,38 +293,44 @@ void Player::handleSlopeMovement(int direction) { } // Maneja el movimiento horizontal -// direction: -1 para izquierda, 1 para derecha -void Player::moveHorizontal(float delta_time, int direction) { +void Player::moveHorizontal(float delta_time, Direction direction) { const float DISPLACEMENT = vx_ * delta_time; // Crea el rectangulo de proyección en el eje X para ver si colisiona SDL_FRect proj; - if (direction < 0) { - // Movimiento a la izquierda - proj = { - .x = x_ + DISPLACEMENT, - .y = y_, - .w = std::ceil(std::fabs(DISPLACEMENT)), - .h = HEIGHT}; - } else { - // Movimiento a la derecha - proj = { - .x = x_ + WIDTH, - .y = y_, - .w = std::ceil(DISPLACEMENT), - .h = HEIGHT}; + switch (direction) { + case Direction::LEFT: + // Movimiento a la izquierda + proj = { + .x = x_ + DISPLACEMENT, + .y = y_, + .w = std::ceil(std::fabs(DISPLACEMENT)), + .h = HEIGHT}; + break; + + case Direction::RIGHT: + // Movimiento a la derecha + proj = { + .x = x_ + WIDTH, + .y = y_, + .w = std::ceil(DISPLACEMENT), + .h = HEIGHT}; + break; + + default: + break; } // Comprueba la colisión con las superficies - const int POS = direction < 0 ? room_->checkRightSurfaces(&proj) : room_->checkLeftSurfaces(&proj); + const int POS = direction == Direction::LEFT ? room_->checkRightSurfaces(proj) : room_->checkLeftSurfaces(proj); // Calcula la nueva posición - if (POS == -1) { + if (POS == Collision::NONE) { // No hay colisión: mueve al jugador x_ += DISPLACEMENT; } else { // Hay colisión: reposiciona al jugador en el punto de colisión - x_ = direction < 0 ? POS + 1 : POS - WIDTH; + x_ = direction == Direction::LEFT ? POS + 1 : POS - WIDTH; } // Maneja el movimiento sobre rampas @@ -350,10 +349,10 @@ void Player::moveVerticalUp(float delta_time) { }; // Comprueba la colisión - const int POS = room_->checkBottomSurfaces(&proj); + const int POS = room_->checkBottomSurfaces(proj); // Calcula la nueva posición - if (POS == -1) { + if (POS == Collision::NONE) { // Si no hay colisión y_ += DISPLACEMENT; } else { @@ -376,21 +375,11 @@ void Player::moveVerticalDown(float delta_time) { }; // Comprueba la colisión con las superficies normales y las automáticas - const float POS = std::max(room_->checkTopSurfaces(&proj), room_->checkAutoSurfaces(&proj)); - if (POS > -1) { + const float POS = std::max(room_->checkTopSurfaces(proj), room_->checkAutoSurfaces(proj)); + if (POS != Collision::NONE) { // Si hay colisión lo mueve hasta donde no colisiona y pasa a estar sobre la superficie y_ = POS - HEIGHT; - - // VERIFICAR MUERTE ANTES de cambiar de estado (PLAYER_MECHANICS.md línea 1268-1274) - const int FALL_DISTANCE = static_cast(y_) - last_grounded_position_; - if (previous_state_ == State::FALLING && FALL_DISTANCE > MAX_FALLING_HEIGHT) { - is_alive_ = false; // Muere si cae más de 32 píxeles - } - transitionToState(State::STANDING); - last_grounded_position_ = static_cast(y_); // Actualizar AL ENTRAR en STANDING - // Deja de estar enganchado a la superficie automatica - auto_movement_ = false; } else { // Si no hay colisión con los muros, comprueba la colisión con las rampas // CORRECCIÓN: FALLING siempre se pega a rampas, JUMPING se pega solo si vx_ == 0 @@ -399,20 +388,12 @@ void Player::moveVerticalDown(float delta_time) { auto rect = toSDLRect(proj); const LineVertical LEFT_SIDE = {.x = rect.x, .y1 = rect.y, .y2 = rect.y + rect.h}; const LineVertical RIGHT_SIDE = {.x = rect.x + rect.w - 1, .y1 = rect.y, .y2 = rect.y + rect.h}; - const float POINT = std::max(room_->checkRightSlopes(&RIGHT_SIDE), room_->checkLeftSlopes(&LEFT_SIDE)); - if (POINT > -1) { + const float POINT = std::max(room_->checkRightSlopes(RIGHT_SIDE), room_->checkLeftSlopes(LEFT_SIDE)); + if (POINT != Collision::NONE) { // No está saltando y hay colisión con una rampa // Calcula la nueva posición y_ = POINT - HEIGHT; - - // VERIFICAR MUERTE ANTES de cambiar de estado (PLAYER_MECHANICS.md línea 1268-1274) - const int FALL_DISTANCE = static_cast(y_) - last_grounded_position_; - if (previous_state_ == State::FALLING && FALL_DISTANCE > MAX_FALLING_HEIGHT) { - is_alive_ = false; // Muere si cae más de 32 píxeles - } - transitionToState(State::STANDING); - last_grounded_position_ = static_cast(y_); // Actualizar AL ENTRAR en STANDING } else { // No está saltando y no hay colisón con una rampa // Calcula la nueva posición @@ -452,7 +433,6 @@ void Player::playJumpSound(float delta_time) { } } - // Calcula y reproduce el sonido de caída basado en distancia vertical recorrida void Player::playFallSound(float delta_time) { size_t sound_index; @@ -466,18 +446,19 @@ void Player::playFallSound(float delta_time) { // Comprueba si el jugador tiene suelo debajo de los pies auto Player::isOnFloor() -> bool { bool on_floor = false; - updateFeet(); // Comprueba las superficies - for (auto f : under_feet_) { - on_floor |= room_->checkTopSurfaces(&f); - on_floor |= room_->checkConveyorBelts(&f); - } + on_floor |= room_->checkTopSurfaces(under_left_foot_); + on_floor |= room_->checkTopSurfaces(under_right_foot_); + + // Comprueba las cintas transportadoras + on_floor |= room_->checkConveyorBelts(under_left_foot_); + on_floor |= room_->checkConveyorBelts(under_right_foot_); // Comprueba las rampas - auto on_slope_l = room_->checkLeftSlopes(under_feet_.data()); - auto on_slope_r = room_->checkRightSlopes(&under_feet_[1]); + auto on_slope_l = room_->checkLeftSlopes(under_left_foot_); + auto on_slope_r = room_->checkRightSlopes(under_right_foot_); return on_floor || on_slope_l || on_slope_r; } @@ -485,13 +466,11 @@ auto Player::isOnFloor() -> bool { // Comprueba si el jugador esta sobre una superficie automática auto Player::isOnConveyorBelt() -> bool { bool on_conveyor_belt = false; - updateFeet(); // Comprueba las superficies - for (auto f : under_feet_) { - on_conveyor_belt |= room_->checkConveyorBelts(&f); - } + on_conveyor_belt |= room_->checkConveyorBelts(under_left_foot_); + on_conveyor_belt |= room_->checkConveyorBelts(under_right_foot_); return on_conveyor_belt; } @@ -499,19 +478,18 @@ auto Player::isOnConveyorBelt() -> bool { // Comprueba si el jugador está sobre una rampa hacia abajo auto Player::isOnDownSlope() -> bool { bool on_slope = false; - updateFeet(); // Cuando el jugador baja una escalera, se queda volando // Hay que mirar otro pixel más por debajo - SDL_FPoint foot0 = under_feet_[0]; - SDL_FPoint foot1 = under_feet_[1]; - foot0.y += 1.0F; - foot1.y += 1.0F; + SDL_FPoint left_foot = under_left_foot_; + SDL_FPoint right_foot = under_right_foot_; + left_foot.y += 1.0F; + right_foot.y += 1.0F; // Comprueba las rampas - on_slope |= room_->checkLeftSlopes(&foot0); - on_slope |= room_->checkRightSlopes(&foot1); + on_slope |= room_->checkLeftSlopes(left_foot); + on_slope |= room_->checkRightSlopes(right_foot); return on_slope; } @@ -555,13 +533,12 @@ void Player::updateColliderPoints() { // Actualiza los puntos de los pies void Player::updateFeet() { - const SDL_FPoint P = {x_, y_}; - - under_feet_[0] = {.x = P.x, .y = P.y + HEIGHT}; - under_feet_[1] = {.x = P.x + 7, .y = P.y + HEIGHT}; - - feet_[0] = {.x = P.x, .y = P.y + HEIGHT - 1}; - feet_[1] = {.x = P.x + 7, .y = P.y + HEIGHT - 1}; + under_left_foot_ = { + .x = x_, + .y = y_ + HEIGHT}; + under_right_foot_ = { + .x = x_ + WIDTH - 1, + .y = y_ + HEIGHT}; } // Inicializa los sonidos de salto y caida @@ -570,7 +547,7 @@ void Player::initSounds() { std::string sound_file = "jump" + std::to_string(i + 1) + ".wav"; jumping_sound_[i] = Resource::get()->getSound(sound_file); - if (i >= 10) { // i+1 >= 11 + if (i >= 10) { // i+1 >= 11 falling_sound_[i - 10] = Resource::get()->getSound(sound_file); } } @@ -658,7 +635,6 @@ auto Player::FallSoundController::shouldPlay(float delta_time, float current_y, return false; } - // Aplica los valores de spawn al jugador void Player::applySpawnValues(const SpawnData& spawn) { x_ = spawn.x; diff --git a/source/game/entities/player.hpp b/source/game/entities/player.hpp index bdd48aa..497d61a 100644 --- a/source/game/entities/player.hpp +++ b/source/game/entities/player.hpp @@ -76,31 +76,31 @@ class Player { struct JumpSoundController { // Duración del salto calculada automáticamente con física: t = 2 * v0 / g static constexpr float JUMP_DURATION = (2.0F * MAX_VY) / GRAVITY_FORCE; - static constexpr size_t FIRST_SOUND = 1; // Primer sonido a reproducir (índice 1) - static constexpr size_t LAST_SOUND = 17; // Último sonido a reproducir (índice 17) + static constexpr size_t FIRST_SOUND = 1; // Primer sonido a reproducir (índice 1) + static constexpr size_t LAST_SOUND = 17; // Último sonido a reproducir (índice 17) static constexpr float SECONDS_PER_SOUND = JUMP_DURATION / (LAST_SOUND - FIRST_SOUND + 1); - size_t current_index_ = 0; // Índice del sonido actual - float elapsed_time_ = 0.0F; // Tiempo transcurrido durante el salto - bool active_ = false; // Indica si el controlador está activo + size_t current_index_ = 0; // Índice del sonido actual + float elapsed_time_ = 0.0F; // Tiempo transcurrido durante el salto + bool active_ = false; // Indica si el controlador está activo - void start(); // Inicia el controlador - void reset(); // Resetea el controlador - bool shouldPlay(float delta_time, size_t& out_index); // Comprueba si debe reproducir un sonido + void start(); // Inicia el controlador + void reset(); // Resetea el controlador + bool shouldPlay(float delta_time, size_t& out_index); // Comprueba si debe reproducir un sonido }; struct FallSoundController { static constexpr float PIXELS_PER_SOUND = 5.0F; // Intervalo de píxeles por sonido (configurable) - static constexpr size_t FIRST_SOUND = 1; // Primer sonido a reproducir (índice 1) - static constexpr size_t LAST_SOUND = 13; // Último sonido a reproducir (índice 13) + static constexpr size_t FIRST_SOUND = 1; // Primer sonido a reproducir (índice 1) + static constexpr size_t LAST_SOUND = 13; // Último sonido a reproducir (índice 13) - size_t current_index_ = 0; // Índice del sonido actual + size_t current_index_ = 0; // Índice del sonido actual float distance_traveled_ = 0.0F; // Distancia acumulada durante la caída float last_y_ = 0.0F; // Última posición Y registrada bool active_ = false; // Indica si el controlador está activo - void start(float start_y); // Inicia el controlador - void reset(); // Resetea el controlador + void start(float start_y); // Inicia el controlador + void reset(); // Resetea el controlador bool shouldPlay(float delta_time, float current_y, size_t& out_index); // Comprueba si debe reproducir un sonido }; @@ -149,8 +149,8 @@ class Player { // --- Variables de colisión --- SDL_FRect collider_box_; // Caja de colisión con los enemigos u objetos std::array collider_points_{}; // Puntos de colisión con el mapa - std::array under_feet_{}; // Contiene los puntos que hay bajo cada pie del jugador - std::array feet_{}; // Contiene los puntos que hay en el pie del jugador + SDL_FPoint under_left_foot_ = {0.0F, 0.0F}; // El punto bajo la esquina inferior izquierda del jugador + SDL_FPoint under_right_foot_ = {0.0F, 0.0F}; // El punto bajo la esquina inferior derecha del jugador // --- Variables de juego --- bool is_on_border_ = false; // Indica si el jugador esta en uno de los cuatro bordes de la pantalla @@ -173,7 +173,6 @@ class Player { void handleConveyorBelts(); void handleShouldFall(); void updateState(float delta_time); - void moveAndCollide(float delta_time); // --- Funciones de inicialización --- void initSprite(const std::string& animations_path); // Inicializa el sprite del jugador @@ -191,11 +190,11 @@ class Player { void applyGravity(float delta_time); // Aplica gravedad al jugador // --- Funciones de movimiento y colisión --- - void move(float delta_time); // Orquesta el movimiento del jugador - void moveHorizontal(float delta_time, int direction); // Maneja el movimiento horizontal (-1: izq, 1: der) - void moveVerticalUp(float delta_time); // Maneja el movimiento vertical hacia arriba - void moveVerticalDown(float delta_time); // Maneja el movimiento vertical hacia abajo - void handleSlopeMovement(int direction); // Maneja el movimiento sobre rampas + void move(float delta_time); // Orquesta el movimiento del jugador + void moveHorizontal(float delta_time, Direction direction); // Maneja el movimiento horizontal (-1: izq, 1: der) + void moveVerticalUp(float delta_time); // Maneja el movimiento vertical hacia arriba + void moveVerticalDown(float delta_time); // Maneja el movimiento vertical hacia abajo + void handleSlopeMovement(Direction direction); // Maneja el movimiento sobre rampas // --- Funciones de detección de superficies --- auto isOnFloor() -> bool; // Comprueba si el jugador tiene suelo debajo de los pies @@ -209,12 +208,12 @@ class Player { void placeSprite(); // Coloca el sprite en la posición del jugador // --- Funciones de finalización --- - void animate(float delta_time); // Establece la animación del jugador - void handleBorders(); // Comprueba si se halla en alguno de los cuatro bordes - void handleJumpEnd(); // Comprueba si ha finalizado el salto al alcanzar la altura de inicio - auto handleKillingTiles() -> bool; // Comprueba que el jugador no toque ningun tile de los que matan + void animate(float delta_time); // Establece la animación del jugador + void handleBorders(); // Comprueba si se halla en alguno de los cuatro bordes + void handleJumpEnd(); // Comprueba si ha finalizado el salto al alcanzar la altura de inicio + auto handleKillingTiles() -> bool; // Comprueba que el jugador no toque ningun tile de los que matan void playJumpSound(float delta_time); // Calcula y reproduce el sonido de salto void playFallSound(float delta_time); // Calcula y reproduce el sonido de caer - void handleDeathByFalling(); // Gestiona la muerte al caer desde muy alto - void updateVelocity(); // Calcula la velocidad en x + void handleDeathByFalling(); // Gestiona la muerte al caer desde muy alto + void updateVelocity(); // Calcula la velocidad en x }; \ No newline at end of file diff --git a/source/game/gameplay/room.cpp b/source/game/gameplay/room.cpp index ea9e442..11527e0 100644 --- a/source/game/gameplay/room.cpp +++ b/source/game/gameplay/room.cpp @@ -681,109 +681,109 @@ void Room::renderAnimatedTiles() { } // Comprueba las colisiones -auto Room::checkRightSurfaces(SDL_FRect* rect) -> int { +auto Room::checkRightSurfaces(SDL_FRect& rect) -> int { for (const auto& s : right_walls_) { - if (checkCollision(s, *rect)) { + if (checkCollision(s, rect)) { return s.x; } } - return -1; + return Collision::NONE; } // Comprueba las colisiones -auto Room::checkLeftSurfaces(SDL_FRect* rect) -> int { +auto Room::checkLeftSurfaces(SDL_FRect& rect) -> int { for (const auto& s : left_walls_) { - if (checkCollision(s, *rect)) { + if (checkCollision(s, rect)) { return s.x; } } - return -1; + return Collision::NONE; } // Comprueba las colisiones -auto Room::checkTopSurfaces(SDL_FRect* rect) -> int { +auto Room::checkTopSurfaces(SDL_FRect& rect) -> int { for (const auto& s : top_floors_) { - if (checkCollision(s, *rect)) { + if (checkCollision(s, rect)) { return s.y; } } - return -1; + return Collision::NONE; } // Comprueba las colisiones -auto Room::checkBottomSurfaces(SDL_FRect* rect) -> int { +auto Room::checkBottomSurfaces(SDL_FRect& rect) -> int { for (const auto& s : bottom_floors_) { - if (checkCollision(s, *rect)) { + if (checkCollision(s, rect)) { return s.y; } } - return -1; + return Collision::NONE; } // Comprueba las colisiones -auto Room::checkAutoSurfaces(SDL_FRect* rect) -> int { +auto Room::checkAutoSurfaces(SDL_FRect& rect) -> int { for (const auto& s : conveyor_belt_floors_) { - if (checkCollision(s, *rect)) { + if (checkCollision(s, rect)) { return s.y; } } - return -1; + return Collision::NONE; } // Comprueba las colisiones -auto Room::checkTopSurfaces(SDL_FPoint* p) -> bool { +auto Room::checkTopSurfaces(SDL_FPoint& p) -> bool { return std::ranges::any_of(top_floors_, [&](const auto& s) { - return checkCollision(s, *p); + return checkCollision(s, p); }); } // Comprueba las colisiones -auto Room::checkConveyorBelts(SDL_FPoint* p) -> bool { +auto Room::checkConveyorBelts(SDL_FPoint& p) -> bool { return std::ranges::any_of(conveyor_belt_floors_, [&](const auto& s) { - return checkCollision(s, *p); + return checkCollision(s, p); }); } // Comprueba las colisiones -auto Room::checkLeftSlopes(const LineVertical* line) -> int { +auto Room::checkLeftSlopes(const LineVertical& line) -> int { for (const auto& slope : left_slopes_) { - const auto P = checkCollision(slope, *line); + const auto P = checkCollision(slope, line); if (P.x != -1) { return P.y; } } - return -1; + return Collision::NONE; } // Comprueba las colisiones -auto Room::checkLeftSlopes(SDL_FPoint* p) -> bool { +auto Room::checkLeftSlopes(SDL_FPoint& p) -> bool { return std::ranges::any_of(left_slopes_, [&](const auto& slope) { - return checkCollision(*p, slope); + return checkCollision(p, slope); }); } // Comprueba las colisiones -auto Room::checkRightSlopes(const LineVertical* line) -> int { +auto Room::checkRightSlopes(const LineVertical& line) -> int { for (const auto& slope : right_slopes_) { - const auto P = checkCollision(slope, *line); + const auto P = checkCollision(slope, line); if (P.x != -1) { return P.y; } } - return -1; + return Collision::NONE; } // Comprueba las colisiones -auto Room::checkRightSlopes(SDL_FPoint* p) -> bool { +auto Room::checkRightSlopes(SDL_FPoint& p) -> bool { return std::ranges::any_of(right_slopes_, [&](const auto& slope) { - return checkCollision(*p, slope); + return checkCollision(p, slope); }); } diff --git a/source/game/gameplay/room.hpp b/source/game/gameplay/room.hpp index 3de6ea5..881eee1 100644 --- a/source/game/gameplay/room.hpp +++ b/source/game/gameplay/room.hpp @@ -78,17 +78,17 @@ class Room { auto itemCollision(SDL_FRect& rect) -> bool; // Indica si hay colision con un objeto a partir de un rectangulo static auto getTileSize() -> int { return TILE_SIZE; } // Obten el tamaño del tile static auto getSlopeHeight(SDL_FPoint p, Tile slope) -> int; // Obten la coordenada de la cuesta a partir de un punto perteneciente a ese tile - auto checkRightSurfaces(SDL_FRect* rect) -> int; // Comprueba las colisiones - auto checkLeftSurfaces(SDL_FRect* rect) -> int; // Comprueba las colisiones - auto checkTopSurfaces(SDL_FRect* rect) -> int; // Comprueba las colisiones - auto checkBottomSurfaces(SDL_FRect* rect) -> int; // Comprueba las colisiones - auto checkAutoSurfaces(SDL_FRect* rect) -> int; // Comprueba las colisiones - auto checkTopSurfaces(SDL_FPoint* p) -> bool; // Comprueba las colisiones - auto checkConveyorBelts(SDL_FPoint* p) -> bool; // Comprueba las colisiones - auto checkLeftSlopes(const LineVertical* line) -> int; // Comprueba las colisiones - auto checkLeftSlopes(SDL_FPoint* p) -> bool; // Comprueba las colisiones - auto checkRightSlopes(const LineVertical* line) -> int; // Comprueba las colisiones - auto checkRightSlopes(SDL_FPoint* p) -> bool; // Comprueba las colisiones + auto checkRightSurfaces(SDL_FRect& rect) -> int; // Comprueba las colisiones + auto checkLeftSurfaces(SDL_FRect& rect) -> int; // Comprueba las colisiones + auto checkTopSurfaces(SDL_FRect& rect) -> int; // Comprueba las colisiones + auto checkBottomSurfaces(SDL_FRect& rect) -> int; // Comprueba las colisiones + auto checkAutoSurfaces(SDL_FRect& rect) -> int; // Comprueba las colisiones + auto checkTopSurfaces(SDL_FPoint& p) -> bool; // Comprueba las colisiones + auto checkConveyorBelts(SDL_FPoint& p) -> bool; // Comprueba las colisiones + auto checkLeftSlopes(const LineVertical& line) -> int; // Comprueba las colisiones + auto checkLeftSlopes(SDL_FPoint& p) -> bool; // Comprueba las colisiones + auto checkRightSlopes(const LineVertical& line) -> int; // Comprueba las colisiones + auto checkRightSlopes(SDL_FPoint& p) -> bool; // Comprueba las colisiones void setPaused(bool value) { is_paused_ = value; }; // Pone el mapa en modo pausa [[nodiscard]] auto getConveyorBeltDirection() const -> int { return conveyor_belt_direction_; } // Obten la direccion de las superficies automaticas static auto loadRoomFile(const std::string& file_path, bool verbose = false) -> Data; // Carga las variables desde un fichero de mapa diff --git a/source/utils/defines.hpp b/source/utils/defines.hpp index f27f6a6..d38b5b8 100644 --- a/source/utils/defines.hpp +++ b/source/utils/defines.hpp @@ -41,4 +41,9 @@ constexpr int GAMECANVAS_FIRST_QUARTER_X = GAMECANVAS_WIDTH / 4; constexpr int GAMECANVAS_THIRD_QUARTER_X = (GAMECANVAS_WIDTH / 4) * 3; constexpr int GAMECANVAS_CENTER_Y = GAMECANVAS_HEIGHT / 2; constexpr int GAMECANVAS_FIRST_QUARTER_Y = GAMECANVAS_HEIGHT / 4; -constexpr int GAMECANVAS_THIRD_QUARTER_Y = (GAMECANVAS_HEIGHT / 4) * 3; \ No newline at end of file +constexpr int GAMECANVAS_THIRD_QUARTER_Y = (GAMECANVAS_HEIGHT / 4) * 3; + +namespace Collision +{ + constexpr int NONE = -1; +} \ No newline at end of file