clang-tidy
This commit is contained in:
@@ -223,7 +223,7 @@ void Player::moveHorizontal(float delta_time) {
|
||||
}
|
||||
|
||||
const auto& tc = room_->getTileCollider();
|
||||
float new_x = x_ + vx_ * delta_time;
|
||||
float new_x = x_ + (vx_ * delta_time);
|
||||
|
||||
// Colisión con paredes
|
||||
if (vx_ < 0.0F) {
|
||||
@@ -431,9 +431,9 @@ void Player::transitionToState(State state) {
|
||||
// Bordes de pantalla
|
||||
// ============================================================================
|
||||
|
||||
auto Player::handleBorders() -> Room::Border {
|
||||
const float CENTER_X = x_ + WIDTH / 2.0F;
|
||||
const float CENTER_Y = y_ + HEIGHT / 2.0F;
|
||||
auto Player::handleBorders() const -> Room::Border {
|
||||
const float CENTER_X = x_ + (WIDTH / 2.0F);
|
||||
const float CENTER_Y = y_ + (HEIGHT / 2.0F);
|
||||
|
||||
if (CENTER_X < PlayArea::LEFT) { return Room::Border::LEFT; }
|
||||
if (CENTER_X > PlayArea::RIGHT) { return Room::Border::RIGHT; }
|
||||
|
||||
@@ -143,7 +143,7 @@ class Player {
|
||||
void syncSpriteAndCollider();
|
||||
void placeSprite();
|
||||
void animate(float delta_time);
|
||||
auto handleBorders() -> Room::Border;
|
||||
auto handleBorders() const -> Room::Border;
|
||||
|
||||
// --- Inicialización ---
|
||||
void initSprite(const std::string& animations_path);
|
||||
|
||||
@@ -12,12 +12,12 @@ class Scoreboard {
|
||||
public:
|
||||
// Tipos anidados
|
||||
struct Data {
|
||||
int items{0}; // Lleva la cuenta de los objetos recogidos
|
||||
int lives{0}; // Lleva la cuenta de las vidas restantes del jugador
|
||||
int rooms{0}; // Lleva la cuenta de las habitaciones visitadas
|
||||
bool music{true}; // Indica si ha de sonar la música durante el juego
|
||||
Uint8 color{0}; // Color para escribir el texto del marcador
|
||||
Uint32 ini_clock{0}; // Tiempo inicial para calcular el tiempo transcurrido
|
||||
int items{0}; // Lleva la cuenta de los objetos recogidos
|
||||
int lives{0}; // Lleva la cuenta de las vidas restantes del jugador
|
||||
int rooms{0}; // Lleva la cuenta de las habitaciones visitadas
|
||||
bool music{true}; // Indica si ha de sonar la música durante el juego
|
||||
Uint8 color{0}; // Color para escribir el texto del marcador
|
||||
Uint32 ini_clock{0}; // Tiempo inicial para calcular el tiempo transcurrido
|
||||
};
|
||||
|
||||
// Métodos públicos
|
||||
|
||||
@@ -14,7 +14,7 @@ auto TileCollider::getTileAt(int tile_x, int tile_y) const -> Tile {
|
||||
if (tile_x < 0 || tile_x >= MW || tile_y < 0 || tile_y >= MH) {
|
||||
return Tile::EMPTY;
|
||||
}
|
||||
int value = tile_map_[tile_y * MW + tile_x];
|
||||
int value = tile_map_[(tile_y * MW) + tile_x];
|
||||
if (value >= 0 && value <= 5) {
|
||||
return static_cast<Tile>(value);
|
||||
}
|
||||
@@ -30,7 +30,7 @@ auto TileCollider::isSolid(int tile_x, int tile_y) const -> bool {
|
||||
// SLOPE_L (\): alto a la izquierda, bajo a la derecha. surface = bottom - (7 - x_in_tile)
|
||||
// SLOPE_R (/): alto a la derecha, bajo a la izquierda. surface = bottom - x_in_tile
|
||||
auto TileCollider::getSlopeY(int tile_x, int tile_y, float px) const -> float {
|
||||
float tile_bottom = static_cast<float>((tile_y + 1) * TS - 1);
|
||||
auto tile_bottom = static_cast<float>(((tile_y + 1) * TS) - 1);
|
||||
float x_in_tile = px - static_cast<float>(tile_x * TS);
|
||||
x_in_tile = std::clamp(x_in_tile, 0.0F, static_cast<float>(TS - 1));
|
||||
|
||||
@@ -96,6 +96,7 @@ auto TileCollider::checkCeiling(float x, float y, float w) const -> float {
|
||||
// SLOPE: solo si los pies estaban por encima de la superficie Y el jugador no está
|
||||
// parcialmente dentro de otra slope (evita aterrizar al hacer drop-through
|
||||
// o al saltar a través de una slope desde abajo).
|
||||
// NOLINTNEXTLINE(readability-function-cognitive-complexity)
|
||||
auto TileCollider::checkFloor(float x, float foot_y_current, float w, float foot_y_new) const -> FloorHit {
|
||||
int start_row = toTile(static_cast<int>(foot_y_current));
|
||||
int end_row = toTile(static_cast<int>(foot_y_new));
|
||||
@@ -115,7 +116,7 @@ auto TileCollider::checkFloor(float x, float foot_y_current, float w, float foot
|
||||
if (tile == Tile::WALL) {
|
||||
floor_y = static_cast<float>(row * TS);
|
||||
} else if (tile == Tile::PASSABLE) {
|
||||
float tile_top = static_cast<float>(row * TS);
|
||||
auto tile_top = static_cast<float>(row * TS);
|
||||
// Solo cuenta como suelo si los pies estaban por encima antes del movimiento
|
||||
if (foot_y_current <= tile_top) {
|
||||
floor_y = tile_top;
|
||||
@@ -130,7 +131,7 @@ auto TileCollider::checkFloor(float x, float foot_y_current, float w, float foot
|
||||
}
|
||||
|
||||
if (floor_y != Collision::NONE && (best.y == Collision::NONE || floor_y < best.y)) {
|
||||
best = {floor_y, tile, col, row};
|
||||
best = {.y = floor_y, .type = tile, .tile_x = col, .tile_y = row};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -193,6 +194,7 @@ auto TileCollider::isInsideAnySlope(float x, float foot_y, float w) const -> boo
|
||||
// Busca una slope directamente debajo del jugador (para transición ground→slope).
|
||||
// Escanea la fila de los pies Y la fila superior: las slopes en escalera siempre
|
||||
// tienen el tile de entrada una fila arriba del suelo desde el que se accede.
|
||||
// NOLINTNEXTLINE(readability-function-cognitive-complexity)
|
||||
auto TileCollider::checkSlopeBelow(float x, float foot_y, float w) const -> SlopeInfo {
|
||||
int foot_row = toTile(static_cast<int>(foot_y));
|
||||
int left_col = toTile(static_cast<int>(x));
|
||||
@@ -205,14 +207,14 @@ auto TileCollider::checkSlopeBelow(float x, float foot_y, float w) const -> Slop
|
||||
float foot_x = (col == left_col) ? x : x + w - 1;
|
||||
float slope_y = getSlopeY(col, row, foot_x);
|
||||
if (slope_y <= foot_y && slope_y >= foot_y - TS) {
|
||||
return {true, Tile::SLOPE_L, col, row, slope_y};
|
||||
return {.on_slope = true, .type = Tile::SLOPE_L, .tile_x = col, .tile_y = row, .surface_y = slope_y};
|
||||
}
|
||||
}
|
||||
if (tile == Tile::SLOPE_R) {
|
||||
float foot_x = (col == right_col) ? x + w - 1 : x;
|
||||
float slope_y = getSlopeY(col, row, foot_x);
|
||||
if (slope_y <= foot_y && slope_y >= foot_y - TS) {
|
||||
return {true, Tile::SLOPE_R, col, row, slope_y};
|
||||
return {.on_slope = true, .type = Tile::SLOPE_R, .tile_x = col, .tile_y = row, .surface_y = slope_y};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,6 @@ Game::Game(Mode mode)
|
||||
game_backbuffer_surface_ = std::make_shared<Surface>(Options::game.width, Options::game.height);
|
||||
changeRoom(current_room_);
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
Console::get()->setScope("debug");
|
||||
#else
|
||||
@@ -331,7 +330,6 @@ void Game::updatePlaying(float delta_time) {
|
||||
checkPlayerAndEnemies();
|
||||
checkIfPlayerIsAlive();
|
||||
|
||||
|
||||
// Avanzar transición
|
||||
if (transitioning_) {
|
||||
transition_timer_ += delta_time;
|
||||
@@ -906,7 +904,6 @@ void Game::togglePause() {
|
||||
scoreboard_->setPaused(paused_);
|
||||
}
|
||||
|
||||
|
||||
// Inicializa al jugador
|
||||
void Game::initPlayer(const Player::SpawnData& spawn_point, std::shared_ptr<Room> room) { // NOLINT(readability-convert-member-functions-to-static)
|
||||
const bool IGNORE_INPUT = player_ != nullptr && player_->getIgnoreInput();
|
||||
|
||||
@@ -31,9 +31,9 @@ class Title {
|
||||
};
|
||||
|
||||
// --- Constantes de tiempo (en segundos) ---
|
||||
static constexpr float FADE_STEP_INTERVAL = 0.05F; // Intervalo entre pasos de fade (antes cada 4 frames)
|
||||
static constexpr float POST_FADE_DELAY = 1.0F; // Delay después del fade (pantalla en negro)
|
||||
static constexpr float KEYBOARD_REMAP_DISPLAY_DELAY = 2.0F; // Tiempo mostrando teclas definidas antes de guardar
|
||||
static constexpr float FADE_STEP_INTERVAL = 0.05F; // Intervalo entre pasos de fade (antes cada 4 frames)
|
||||
static constexpr float POST_FADE_DELAY = 1.0F; // Delay después del fade (pantalla en negro)
|
||||
static constexpr float KEYBOARD_REMAP_DISPLAY_DELAY = 2.0F; // Tiempo mostrando teclas definidas antes de guardar
|
||||
// --- Métodos ---
|
||||
void handleEvents(); // Comprueba el manejador de eventos
|
||||
void handleMainMenuKeyPress(SDL_Keycode key); // Maneja las teclas del menu principal
|
||||
|
||||
Reference in New Issue
Block a user