forked from jaildesigner-jailgames/jaildoctors_dilemma
clang-format
clang-tidy (macos)
This commit is contained in:
@@ -49,7 +49,7 @@ void Enemy::update(float delta_time) {
|
||||
}
|
||||
|
||||
// Comprueba si ha llegado al limite del recorrido para darse media vuelta
|
||||
void Enemy::checkPath() {
|
||||
void Enemy::checkPath() { // NOLINT(readability-make-member-function-const)
|
||||
if (sprite_->getPosX() > x2_ || sprite_->getPosX() < x1_) {
|
||||
// Recoloca
|
||||
if (sprite_->getPosX() > x2_) {
|
||||
|
||||
@@ -29,15 +29,15 @@ void Item::update(float delta_time) {
|
||||
}
|
||||
|
||||
// Pinta el objeto en pantalla
|
||||
void Item::render() const {
|
||||
void Item::render() const { // NOLINT(readability-convert-member-functions-to-static)
|
||||
// Calcula el índice de color basado en el tiempo acumulado
|
||||
const int INDEX = static_cast<int>(time_accumulator_ / COLOR_CHANGE_INTERVAL) % static_cast<int>(color_.size());
|
||||
sprite_->render(1, color_.at(INDEX));
|
||||
}
|
||||
|
||||
// Obtiene su ubicación
|
||||
auto Item::getPos() -> SDL_FPoint {
|
||||
const SDL_FPoint P = {sprite_->getX(), sprite_->getY()};
|
||||
auto Item::getPos() -> SDL_FPoint { // NOLINT(readability-convert-member-functions-to-static)
|
||||
const SDL_FPoint P = {.x = sprite_->getX(), .y = sprite_->getY()};
|
||||
return P;
|
||||
}
|
||||
|
||||
|
||||
@@ -352,7 +352,7 @@ void Player::moveJumping(float delta_time) {
|
||||
// Comprueba la colisión con las superficies y las cintas transportadoras (sin rampas)
|
||||
// Extendemos 1px hacia arriba para detectar suelos traversados ligeramente al
|
||||
// entrar horizontalmente (consecuencia del margen h=HEIGHT-1 en la proyección horizontal)
|
||||
const SDL_FRect ADJ = {PROJECTION.x, PROJECTION.y - 1.0F, PROJECTION.w, PROJECTION.h + 1.0F};
|
||||
const SDL_FRect ADJ = {.x = PROJECTION.x, .y = PROJECTION.y - 1.0F, .w = PROJECTION.w, .h = PROJECTION.h + 1.0F};
|
||||
const float POS = std::max(room_->checkTopSurfaces(ADJ), room_->checkAutoSurfaces(ADJ));
|
||||
if (POS != Collision::NONE) {
|
||||
// Si hay colisión lo mueve hasta donde no colisiona y pasa a estar sobre la superficie
|
||||
@@ -445,7 +445,7 @@ void Player::applyGravity(float delta_time) {
|
||||
}
|
||||
|
||||
// Establece la animación del jugador
|
||||
void Player::animate(float delta_time) {
|
||||
void Player::animate(float delta_time) { // NOLINT(readability-make-member-function-const)
|
||||
if (vx_ != 0) {
|
||||
sprite_->update(delta_time);
|
||||
}
|
||||
@@ -461,7 +461,7 @@ void Player::handleJumpEnd() {
|
||||
}
|
||||
|
||||
// Calcula y reproduce el sonido de salto basado en tiempo transcurrido
|
||||
void Player::playJumpSound(float delta_time) {
|
||||
void Player::playJumpSound(float delta_time) { // NOLINT(readability-convert-member-functions-to-static)
|
||||
size_t sound_index;
|
||||
if (jump_sound_ctrl_.shouldPlay(delta_time, sound_index)) {
|
||||
if (sound_index < jumping_sound_.size()) {
|
||||
@@ -471,7 +471,7 @@ 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) {
|
||||
void Player::playFallSound(float delta_time) { // NOLINT(readability-convert-member-functions-to-static)
|
||||
size_t sound_index;
|
||||
if (fall_sound_ctrl_.shouldPlay(delta_time, y_, sound_index)) {
|
||||
if (sound_index < falling_sound_.size()) {
|
||||
@@ -593,7 +593,7 @@ void Player::updateCurrentSlope() {
|
||||
// Comprueba que el jugador no toque ningun tile de los que matan
|
||||
auto Player::handleKillingTiles() -> bool {
|
||||
// Comprueba si hay contacto con algún tile que mata
|
||||
if (std::ranges::any_of(collider_points_, [this](const auto& c) {
|
||||
if (std::ranges::any_of(collider_points_, [this](const auto& c) -> bool {
|
||||
return room_->getTile(c) == Room::Tile::KILL;
|
||||
})) {
|
||||
markAsDead(); // Mata al jugador inmediatamente
|
||||
@@ -643,7 +643,7 @@ void Player::updateFeet() {
|
||||
}
|
||||
|
||||
// Inicializa los sonidos de salto y caida
|
||||
void Player::initSounds() {
|
||||
void Player::initSounds() { // NOLINT(readability-convert-member-functions-to-static)
|
||||
for (int i = 0; i < 24; ++i) {
|
||||
std::string sound_file = "jump" + std::to_string(i + 1) + ".wav";
|
||||
jumping_sound_[i] = Resource::Cache::get()->getSound(sound_file);
|
||||
@@ -678,14 +678,14 @@ auto Player::JumpSoundController::shouldPlay(float delta_time, size_t& out_index
|
||||
elapsed_time += delta_time;
|
||||
|
||||
// Calcula qué sonido debería estar sonando según el tiempo
|
||||
size_t target_index = FIRST_SOUND + static_cast<size_t>(elapsed_time / SECONDS_PER_SOUND);
|
||||
size_t target_index = FIRST_SOUND + static_cast<size_t>((elapsed_time / SECONDS_PER_SOUND));
|
||||
target_index = std::min(target_index, LAST_SOUND);
|
||||
|
||||
// Reproduce si hemos avanzado a un nuevo sonido
|
||||
if (target_index > current_index) {
|
||||
current_index = target_index;
|
||||
out_index = current_index;
|
||||
return true;
|
||||
return true; // NOLINT(readability-simplify-boolean-expr)
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -721,7 +721,7 @@ auto Player::FallSoundController::shouldPlay(float delta_time, float current_y,
|
||||
last_y = current_y;
|
||||
|
||||
// Calcula qué sonido debería estar sonando según el intervalo
|
||||
size_t target_index = FIRST_SOUND + static_cast<size_t>(distance_traveled / PIXELS_PER_SOUND);
|
||||
size_t target_index = FIRST_SOUND + static_cast<size_t>((distance_traveled / PIXELS_PER_SOUND));
|
||||
|
||||
// El sonido a reproducir se limita a LAST_SOUND (13), pero el índice interno sigue creciendo
|
||||
size_t sound_to_play = std::min(target_index, LAST_SOUND);
|
||||
@@ -749,7 +749,7 @@ void Player::applySpawnValues(const SpawnData& spawn) {
|
||||
}
|
||||
|
||||
// Inicializa el sprite del jugador
|
||||
void Player::initSprite(const std::string& animations_path) {
|
||||
void Player::initSprite(const std::string& animations_path) { // NOLINT(readability-convert-member-functions-to-static)
|
||||
const auto& animation_data = Resource::Cache::get()->getAnimationData(animations_path);
|
||||
sprite_ = std::make_unique<SurfaceAnimatedSprite>(animation_data);
|
||||
sprite_->setWidth(WIDTH);
|
||||
@@ -865,7 +865,7 @@ void Player::resetSoundControllersOnLanding() {
|
||||
}
|
||||
|
||||
// Devuelve el rectangulo de proyeccion
|
||||
auto Player::getProjection(Direction direction, float displacement) -> SDL_FRect {
|
||||
auto Player::getProjection(Direction direction, float displacement) -> SDL_FRect { // NOLINT(readability-convert-member-functions-to-static)
|
||||
switch (direction) {
|
||||
case Direction::LEFT:
|
||||
return {
|
||||
|
||||
@@ -96,7 +96,7 @@ class Player {
|
||||
[[nodiscard]] auto isOnBorder() const -> bool { return border_ != Room::Border::NONE; } // Indica si el jugador esta en uno de los cuatro bordes de la pantalla
|
||||
[[nodiscard]] auto getBorder() const -> Room::Border { return border_; } // Indica en cual de los cuatro bordes se encuentra
|
||||
void switchBorders(); // Cambia al jugador de un borde al opuesto. Util para el cambio de pantalla
|
||||
auto getRect() -> SDL_FRect { return {x_, y_, WIDTH, HEIGHT}; } // Obtiene el rectangulo que delimita al jugador
|
||||
auto getRect() -> SDL_FRect { return {.x = x_, .y = y_, .w = WIDTH, .h = HEIGHT}; } // Obtiene el rectangulo que delimita al jugador
|
||||
auto getCollider() -> SDL_FRect& { return collider_box_; } // Obtiene el rectangulo de colision del jugador
|
||||
auto getSpawnParams() -> SpawnData { return {.x = x_, .y = y_, .vx = vx_, .vy = vy_, .last_grounded_position = last_grounded_position_, .state = state_, .flip = sprite_->getFlip()}; } // Obtiene el estado de reaparición del jugador
|
||||
void setColor(Uint8 color = 0); // Establece el color del jugador (0 = automático según cheats)
|
||||
@@ -138,8 +138,8 @@ class Player {
|
||||
// --- Variables de colisión ---
|
||||
SDL_FRect collider_box_{}; // Caja de colisión con los enemigos u objetos
|
||||
std::array<SDL_FPoint, 8> collider_points_{}; // Puntos de colisión con el mapa
|
||||
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
|
||||
SDL_FPoint under_left_foot_ = {.x = 0.0F, .y = 0.0F}; // El punto bajo la esquina inferior izquierda del jugador
|
||||
SDL_FPoint under_right_foot_ = {.x = 0.0F, .y = 0.0F}; // El punto bajo la esquina inferior derecha del jugador
|
||||
const LineDiagonal* current_slope_{nullptr}; // Rampa actual sobe la que está el jugador
|
||||
|
||||
// --- Variables de juego ---
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
Cheevos* Cheevos::cheevos = nullptr;
|
||||
|
||||
// [SINGLETON] Crearemos el objeto con esta función estática
|
||||
void Cheevos::init(const std::string& file) {
|
||||
void Cheevos::init(const std::string& file) { // NOLINT(readability-convert-member-functions-to-static)
|
||||
Cheevos::cheevos = new Cheevos(file);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ Cheevos::~Cheevos() {
|
||||
}
|
||||
|
||||
// Inicializa los logros
|
||||
void Cheevos::init() {
|
||||
void Cheevos::init() { // NOLINT(readability-convert-member-functions-to-static)
|
||||
cheevos_list_.clear();
|
||||
auto* loc = Locale::get();
|
||||
cheevos_list_.emplace_back(Achievement{.id = 1, .caption = loc->get("achievements.c1"), .description = loc->get("achievements.d1"), .icon = 2});
|
||||
@@ -61,7 +61,7 @@ void Cheevos::init() {
|
||||
}
|
||||
|
||||
// Busca un logro por id y devuelve el indice
|
||||
auto Cheevos::find(int id) -> int {
|
||||
auto Cheevos::find(int id) -> int { // NOLINT(readability-convert-member-functions-to-static)
|
||||
for (int i = 0; i < (int)cheevos_list_.size(); ++i) {
|
||||
if (cheevos_list_[i].id == id) {
|
||||
return i;
|
||||
@@ -101,7 +101,7 @@ void Cheevos::setUnobtainable(int id) {
|
||||
}
|
||||
|
||||
// Carga el estado de los logros desde un fichero
|
||||
void Cheevos::loadFromFile() {
|
||||
void Cheevos::loadFromFile() { // NOLINT(readability-convert-member-functions-to-static)
|
||||
std::ifstream file(file_, std::ios::binary);
|
||||
|
||||
// El fichero no existe
|
||||
@@ -162,7 +162,7 @@ void Cheevos::saveToFile() {
|
||||
|
||||
// Devuelve el número total de logros desbloqueados
|
||||
auto Cheevos::getTotalUnlockedAchievements() -> int {
|
||||
return std::count_if(cheevos_list_.begin(), cheevos_list_.end(), [](const auto& cheevo) { return cheevo.completed; });
|
||||
return std::count_if(cheevos_list_.begin(), cheevos_list_.end(), [](const auto& cheevo) -> bool { return cheevo.completed; });
|
||||
}
|
||||
|
||||
// Elimina el estado "no obtenible"
|
||||
|
||||
@@ -36,7 +36,7 @@ auto CollisionMap::getTile(SDL_FPoint point) const -> Tile {
|
||||
}
|
||||
|
||||
// Devuelve el tipo de tile que hay en ese indice
|
||||
auto CollisionMap::getTile(int index) const -> Tile {
|
||||
auto CollisionMap::getTile(int index) const -> Tile { // NOLINT(readability-convert-member-functions-to-static)
|
||||
const bool ON_RANGE = (index > -1) && (index < (int)tile_map_.size());
|
||||
|
||||
if (ON_RANGE) {
|
||||
@@ -107,7 +107,7 @@ auto CollisionMap::getSlopeHeight(SDL_FPoint p, Tile slope) -> int {
|
||||
// === Queries de colisión ===
|
||||
|
||||
// Comprueba las colisiones con paredes derechas
|
||||
auto CollisionMap::checkRightSurfaces(const SDL_FRect& rect) -> int {
|
||||
auto CollisionMap::checkRightSurfaces(const SDL_FRect& rect) -> int { // NOLINT(readability-convert-member-functions-to-static)
|
||||
for (const auto& s : right_walls_) {
|
||||
if (checkCollision(s, rect)) {
|
||||
return s.x;
|
||||
@@ -117,7 +117,7 @@ auto CollisionMap::checkRightSurfaces(const SDL_FRect& rect) -> int {
|
||||
}
|
||||
|
||||
// Comprueba las colisiones con paredes izquierdas
|
||||
auto CollisionMap::checkLeftSurfaces(const SDL_FRect& rect) -> int {
|
||||
auto CollisionMap::checkLeftSurfaces(const SDL_FRect& rect) -> int { // NOLINT(readability-convert-member-functions-to-static)
|
||||
for (const auto& s : left_walls_) {
|
||||
if (checkCollision(s, rect)) {
|
||||
return s.x;
|
||||
@@ -127,7 +127,7 @@ auto CollisionMap::checkLeftSurfaces(const SDL_FRect& rect) -> int {
|
||||
}
|
||||
|
||||
// Comprueba las colisiones con techos
|
||||
auto CollisionMap::checkTopSurfaces(const SDL_FRect& rect) -> int {
|
||||
auto CollisionMap::checkTopSurfaces(const SDL_FRect& rect) -> int { // NOLINT(readability-convert-member-functions-to-static)
|
||||
for (const auto& s : top_floors_) {
|
||||
if (checkCollision(s, rect)) {
|
||||
return s.y;
|
||||
@@ -138,13 +138,13 @@ auto CollisionMap::checkTopSurfaces(const SDL_FRect& rect) -> int {
|
||||
|
||||
// Comprueba las colisiones punto con techos
|
||||
auto CollisionMap::checkTopSurfaces(const SDL_FPoint& p) -> bool {
|
||||
return std::ranges::any_of(top_floors_, [&](const auto& s) {
|
||||
return std::ranges::any_of(top_floors_, [&](const auto& s) -> bool {
|
||||
return checkCollision(s, p);
|
||||
});
|
||||
}
|
||||
|
||||
// Comprueba las colisiones con suelos
|
||||
auto CollisionMap::checkBottomSurfaces(const SDL_FRect& rect) -> int {
|
||||
auto CollisionMap::checkBottomSurfaces(const SDL_FRect& rect) -> int { // NOLINT(readability-convert-member-functions-to-static)
|
||||
for (const auto& s : bottom_floors_) {
|
||||
if (checkCollision(s, rect)) {
|
||||
return s.y;
|
||||
@@ -154,7 +154,7 @@ auto CollisionMap::checkBottomSurfaces(const SDL_FRect& rect) -> int {
|
||||
}
|
||||
|
||||
// Comprueba las colisiones con conveyor belts
|
||||
auto CollisionMap::checkAutoSurfaces(const SDL_FRect& rect) -> int {
|
||||
auto CollisionMap::checkAutoSurfaces(const SDL_FRect& rect) -> int { // NOLINT(readability-convert-member-functions-to-static)
|
||||
for (const auto& s : conveyor_belt_floors_) {
|
||||
if (checkCollision(s, rect)) {
|
||||
return s.y;
|
||||
@@ -165,13 +165,13 @@ auto CollisionMap::checkAutoSurfaces(const SDL_FRect& rect) -> int {
|
||||
|
||||
// Comprueba las colisiones punto con conveyor belts
|
||||
auto CollisionMap::checkConveyorBelts(const SDL_FPoint& p) -> bool {
|
||||
return std::ranges::any_of(conveyor_belt_floors_, [&](const auto& s) {
|
||||
return std::ranges::any_of(conveyor_belt_floors_, [&](const auto& s) -> bool {
|
||||
return checkCollision(s, p);
|
||||
});
|
||||
}
|
||||
|
||||
// Comprueba las colisiones línea con rampas izquierdas
|
||||
auto CollisionMap::checkLeftSlopes(const LineVertical& line) -> int {
|
||||
auto CollisionMap::checkLeftSlopes(const LineVertical& line) -> int { // NOLINT(readability-convert-member-functions-to-static)
|
||||
for (const auto& slope : left_slopes_) {
|
||||
const auto P = checkCollision(slope, line);
|
||||
if (P.x != -1) {
|
||||
@@ -183,13 +183,13 @@ auto CollisionMap::checkLeftSlopes(const LineVertical& line) -> int {
|
||||
|
||||
// Comprueba las colisiones punto con rampas izquierdas
|
||||
auto CollisionMap::checkLeftSlopes(const SDL_FPoint& p) -> bool {
|
||||
return std::ranges::any_of(left_slopes_, [&](const auto& slope) {
|
||||
return std::ranges::any_of(left_slopes_, [&](const auto& slope) -> bool {
|
||||
return checkCollision(p, slope);
|
||||
});
|
||||
}
|
||||
|
||||
// Comprueba las colisiones línea con rampas derechas
|
||||
auto CollisionMap::checkRightSlopes(const LineVertical& line) -> int {
|
||||
auto CollisionMap::checkRightSlopes(const LineVertical& line) -> int { // NOLINT(readability-convert-member-functions-to-static)
|
||||
for (const auto& slope : right_slopes_) {
|
||||
const auto P = checkCollision(slope, line);
|
||||
if (P.x != -1) {
|
||||
@@ -201,13 +201,13 @@ auto CollisionMap::checkRightSlopes(const LineVertical& line) -> int {
|
||||
|
||||
// Comprueba las colisiones punto con rampas derechas
|
||||
auto CollisionMap::checkRightSlopes(const SDL_FPoint& p) -> bool {
|
||||
return std::ranges::any_of(right_slopes_, [&](const auto& slope) {
|
||||
return std::ranges::any_of(right_slopes_, [&](const auto& slope) -> bool {
|
||||
return checkCollision(p, slope);
|
||||
});
|
||||
}
|
||||
|
||||
// Obtiene puntero a slope en un punto (prioriza left_slopes_ sobre right_slopes_)
|
||||
auto CollisionMap::getSlopeAtPoint(const SDL_FPoint& p) const -> const LineDiagonal* {
|
||||
auto CollisionMap::getSlopeAtPoint(const SDL_FPoint& p) const -> const LineDiagonal* { // NOLINT(readability-convert-member-functions-to-static)
|
||||
// Primero busca en rampas izquierdas
|
||||
for (const auto& slope : left_slopes_) {
|
||||
if (checkCollision(p, slope)) {
|
||||
@@ -229,7 +229,7 @@ auto CollisionMap::getSlopeAtPoint(const SDL_FPoint& p) const -> const LineDiago
|
||||
// === Helpers para recopilar tiles ===
|
||||
|
||||
// Helper: recopila tiles inferiores (muros sin muro debajo)
|
||||
auto CollisionMap::collectBottomTiles() -> std::vector<int> {
|
||||
auto CollisionMap::collectBottomTiles() -> std::vector<int> { // NOLINT(readability-make-member-function-const)
|
||||
std::vector<int> tile;
|
||||
|
||||
// Busca todos los tiles de tipo muro que no tengan debajo otro muro
|
||||
@@ -251,7 +251,7 @@ auto CollisionMap::collectBottomTiles() -> std::vector<int> {
|
||||
}
|
||||
|
||||
// Helper: recopila tiles superiores (muros o pasables sin muro encima)
|
||||
auto CollisionMap::collectTopTiles() -> std::vector<int> {
|
||||
auto CollisionMap::collectTopTiles() -> std::vector<int> { // NOLINT(readability-make-member-function-const)
|
||||
std::vector<int> tile;
|
||||
|
||||
// Busca todos los tiles de tipo muro o pasable que no tengan encima un muro
|
||||
@@ -273,7 +273,7 @@ auto CollisionMap::collectTopTiles() -> std::vector<int> {
|
||||
}
|
||||
|
||||
// Helper: recopila tiles animados (para superficies automaticas/conveyor belts)
|
||||
auto CollisionMap::collectAnimatedTiles() -> std::vector<int> {
|
||||
auto CollisionMap::collectAnimatedTiles() -> std::vector<int> { // NOLINT(readability-make-member-function-const)
|
||||
std::vector<int> tile;
|
||||
|
||||
// Busca todos los tiles de tipo animado
|
||||
@@ -298,13 +298,13 @@ auto CollisionMap::collectAnimatedTiles() -> std::vector<int> {
|
||||
}
|
||||
|
||||
// Helper: construye lineas horizontales a partir de tiles consecutivos
|
||||
void CollisionMap::buildHorizontalLines(const std::vector<int>& tiles, std::vector<LineHorizontal>& lines, bool is_bottom_surface) {
|
||||
void CollisionMap::buildHorizontalLines(const std::vector<int>& tiles, std::vector<LineHorizontal>& lines, bool is_bottom_surface) { // NOLINT(readability-convert-member-functions-to-static)
|
||||
if (tiles.size() <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
while (i < (int)tiles.size() - 1) {
|
||||
while (i < static_cast<int>(tiles.size()) - 1) {
|
||||
LineHorizontal line;
|
||||
line.x1 = (tiles[i] % MAP_WIDTH) * TILE_SIZE;
|
||||
|
||||
@@ -319,11 +319,11 @@ void CollisionMap::buildHorizontalLines(const std::vector<int>& tiles, std::vect
|
||||
i++;
|
||||
|
||||
// Encuentra tiles consecutivos
|
||||
if (i < (int)tiles.size()) {
|
||||
if (i < static_cast<int>(tiles.size())) {
|
||||
while (tiles[i] == tiles[i - 1] + 1) {
|
||||
last_one = i;
|
||||
i++;
|
||||
if (i >= (int)tiles.size()) {
|
||||
if (i >= static_cast<int>(tiles.size())) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -333,7 +333,7 @@ void CollisionMap::buildHorizontalLines(const std::vector<int>& tiles, std::vect
|
||||
lines.push_back(line);
|
||||
|
||||
// Salta separadores
|
||||
if (i < (int)tiles.size() && tiles[i] == -1) {
|
||||
if (i < static_cast<int>(tiles.size()) && tiles[i] == -1) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -354,7 +354,7 @@ void CollisionMap::setTopSurfaces() {
|
||||
}
|
||||
|
||||
// Calcula las superficies laterales izquierdas
|
||||
void CollisionMap::setLeftSurfaces() {
|
||||
void CollisionMap::setLeftSurfaces() { // NOLINT(readability-make-member-function-const)
|
||||
std::vector<int> tile;
|
||||
|
||||
// Busca todos los tiles de tipo muro que no tienen a su izquierda un tile de tipo muro
|
||||
@@ -394,7 +394,7 @@ void CollisionMap::setLeftSurfaces() {
|
||||
}
|
||||
|
||||
// Calcula las superficies laterales derechas
|
||||
void CollisionMap::setRightSurfaces() {
|
||||
void CollisionMap::setRightSurfaces() { // NOLINT(readability-make-member-function-const)
|
||||
std::vector<int> tile;
|
||||
|
||||
// Busca todos los tiles de tipo muro que no tienen a su derecha un tile de tipo muro
|
||||
@@ -434,7 +434,7 @@ void CollisionMap::setRightSurfaces() {
|
||||
}
|
||||
|
||||
// Encuentra todas las rampas que suben hacia la izquierda
|
||||
void CollisionMap::setLeftSlopes() {
|
||||
void CollisionMap::setLeftSlopes() { // NOLINT(readability-make-member-function-const)
|
||||
// Recorre la habitación entera por filas buscando tiles de tipo t_slope_l
|
||||
std::vector<int> found;
|
||||
for (int i = 0; i < (int)tile_map_.size(); ++i) {
|
||||
@@ -469,7 +469,7 @@ void CollisionMap::setLeftSlopes() {
|
||||
}
|
||||
|
||||
// Encuentra todas las rampas que suben hacia la derecha
|
||||
void CollisionMap::setRightSlopes() {
|
||||
void CollisionMap::setRightSlopes() { // NOLINT(readability-make-member-function-const)
|
||||
// Recorre la habitación entera por filas buscando tiles de tipo t_slope_r
|
||||
std::vector<int> found;
|
||||
for (int i = 0; i < (int)tile_map_.size(); ++i) {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "utils/utils.hpp" // Para checkCollision
|
||||
|
||||
// Añade un enemigo a la colección
|
||||
void EnemyManager::addEnemy(std::shared_ptr<Enemy> enemy) {
|
||||
void EnemyManager::addEnemy(std::shared_ptr<Enemy> enemy) { // NOLINT(readability-identifier-naming)
|
||||
enemies_.push_back(std::move(enemy));
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ void EnemyManager::clear() {
|
||||
}
|
||||
|
||||
// Elimina el último enemigo de la colección
|
||||
void EnemyManager::removeLastEnemy() {
|
||||
void EnemyManager::removeLastEnemy() { // NOLINT(readability-convert-member-functions-to-static)
|
||||
if (!enemies_.empty()) {
|
||||
enemies_.pop_back();
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ ItemManager::ItemManager(std::string room_name, std::shared_ptr<Scoreboard::Data
|
||||
}
|
||||
|
||||
// Añade un item a la colección
|
||||
void ItemManager::addItem(std::shared_ptr<Item> item) {
|
||||
void ItemManager::addItem(std::shared_ptr<Item> item) { // NOLINT(readability-identifier-naming)
|
||||
items_.push_back(std::move(item));
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ void ItemManager::setPaused(bool paused) {
|
||||
}
|
||||
|
||||
// Comprueba si hay colisión con algún item
|
||||
auto ItemManager::checkCollision(SDL_FRect& rect) -> bool {
|
||||
auto ItemManager::checkCollision(SDL_FRect& rect) -> bool { // NOLINT(readability-convert-member-functions-to-static)
|
||||
for (int i = 0; i < static_cast<int>(items_.size()); ++i) {
|
||||
if (::checkCollision(rect, items_.at(i)->getCollider())) {
|
||||
// Registra el item como recogido
|
||||
|
||||
@@ -32,7 +32,7 @@ auto ItemTracker::hasBeenPicked(const std::string& name, SDL_FPoint pos) -> bool
|
||||
}
|
||||
|
||||
// Añade el objeto a la lista de objetos cogidos
|
||||
void ItemTracker::addItem(const std::string& name, SDL_FPoint pos) {
|
||||
void ItemTracker::addItem(const std::string& name, SDL_FPoint pos) { // NOLINT(readability-convert-member-functions-to-static)
|
||||
// Comprueba si el objeto no ha sido recogido con anterioridad
|
||||
if (!hasBeenPicked(name, pos)) {
|
||||
// Primero busca si ya hay una entrada con ese nombre
|
||||
@@ -47,7 +47,7 @@ void ItemTracker::addItem(const std::string& name, SDL_FPoint pos) {
|
||||
}
|
||||
|
||||
// Busca una entrada en la lista por nombre
|
||||
auto ItemTracker::findByName(const std::string& name) -> int {
|
||||
auto ItemTracker::findByName(const std::string& name) -> int { // NOLINT(readability-convert-member-functions-to-static)
|
||||
int i = 0;
|
||||
|
||||
for (const auto& item : items_) {
|
||||
@@ -61,7 +61,7 @@ auto ItemTracker::findByName(const std::string& name) -> int {
|
||||
}
|
||||
|
||||
// Busca una entrada en la lista por posición
|
||||
auto ItemTracker::findByPos(int index, SDL_FPoint pos) -> int {
|
||||
auto ItemTracker::findByPos(int index, SDL_FPoint pos) -> int { // NOLINT(readability-convert-member-functions-to-static)
|
||||
int i = 0;
|
||||
|
||||
for (const auto& item : items_[index].pos) {
|
||||
|
||||
@@ -81,7 +81,7 @@ void Room::initializeRoom(const Data& room) {
|
||||
}
|
||||
|
||||
// Abre la jail para poder entrar
|
||||
void Room::openTheJail() {
|
||||
void Room::openTheJail() { // NOLINT(readability-convert-member-functions-to-static)
|
||||
if (data_->jail_is_open && name_ == "THE JAIL") {
|
||||
// Elimina el último enemigo (Bry debe ser el último enemigo definido en el fichero)
|
||||
if (!enemy_manager_->isEmpty()) {
|
||||
@@ -123,7 +123,7 @@ void Room::redrawMap() {
|
||||
#endif
|
||||
|
||||
// Actualiza las variables y objetos de la habitación
|
||||
void Room::update(float delta_time) {
|
||||
void Room::update(float delta_time) { // NOLINT(readability-make-member-function-const)
|
||||
if (is_paused_) {
|
||||
// Si está en modo pausa no se actualiza nada
|
||||
return;
|
||||
@@ -147,7 +147,7 @@ void Room::setPaused(bool value) {
|
||||
}
|
||||
|
||||
// Devuelve la cadena del fichero de la habitación contigua segun el borde
|
||||
auto Room::getRoom(Border border) -> std::string {
|
||||
auto Room::getRoom(Border border) -> std::string { // NOLINT(readability-convert-member-functions-to-static)
|
||||
switch (border) {
|
||||
case Border::TOP:
|
||||
return upper_room_;
|
||||
@@ -163,14 +163,14 @@ auto Room::getRoom(Border border) -> std::string {
|
||||
}
|
||||
|
||||
// Devuelve el tipo de tile que hay en ese pixel
|
||||
auto Room::getTile(SDL_FPoint point) -> Tile {
|
||||
auto Room::getTile(SDL_FPoint point) -> Tile { // NOLINT(readability-convert-member-functions-to-static)
|
||||
// Delega a CollisionMap y convierte el resultado
|
||||
const auto COLLISION_TILE = collision_map_->getTile(point);
|
||||
return static_cast<Tile>(COLLISION_TILE);
|
||||
}
|
||||
|
||||
// Devuelve el tipo de tile en un índice del tilemap
|
||||
auto Room::getTile(int index) -> Tile {
|
||||
auto Room::getTile(int index) -> Tile { // NOLINT(readability-convert-member-functions-to-static)
|
||||
// Delega a CollisionMap y convierte el resultado
|
||||
const auto COLLISION_TILE = collision_map_->getTile(index);
|
||||
return static_cast<Tile>(COLLISION_TILE);
|
||||
@@ -256,6 +256,6 @@ auto Room::getSlopeAtPoint(const SDL_FPoint& p) const -> const LineDiagonal* {
|
||||
}
|
||||
|
||||
// Carga una habitación desde un archivo YAML (delegado a RoomLoader)
|
||||
auto Room::loadYAML(const std::string& file_path, bool verbose) -> Data {
|
||||
auto Room::loadYAML(const std::string& file_path, bool verbose) -> Data { // NOLINT(readability-convert-member-functions-to-static)
|
||||
return RoomLoader::loadYAML(file_path, verbose);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ class Room {
|
||||
|
||||
// Constructor y destructor
|
||||
Room(const std::string& room_path, std::shared_ptr<Scoreboard::Data> data);
|
||||
~Room(); // Definido en .cpp para poder usar unique_ptr con forward declarations
|
||||
~Room(); // NOLINT(modernize-use-equals-default, performance-trivially-destructible) -- defined in .cpp for unique_ptr with forward declarations
|
||||
|
||||
// --- Funciones ---
|
||||
[[nodiscard]] auto getName() const -> const std::string& { return name_; } // Devuelve el nombre de la habitación
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "utils/utils.hpp" // Para stringToColor
|
||||
|
||||
// Convierte room connection de YAML a formato interno
|
||||
auto RoomLoader::convertRoomConnection(const std::string& value) -> std::string {
|
||||
auto RoomLoader::convertRoomConnection(const std::string& value) -> std::string { // NOLINT(readability-convert-member-functions-to-static)
|
||||
if (value == "null" || value.empty()) {
|
||||
return "0";
|
||||
}
|
||||
@@ -22,7 +22,7 @@ auto RoomLoader::convertRoomConnection(const std::string& value) -> std::string
|
||||
}
|
||||
|
||||
// Convierte string de autoSurface a int
|
||||
auto RoomLoader::convertAutoSurface(const fkyaml::node& node) -> int {
|
||||
auto RoomLoader::convertAutoSurface(const fkyaml::node& node) -> int { // NOLINT(readability-convert-member-functions-to-static)
|
||||
if (node.is_integer()) {
|
||||
return node.get_value<int>();
|
||||
}
|
||||
@@ -39,7 +39,7 @@ auto RoomLoader::convertAutoSurface(const fkyaml::node& node) -> int {
|
||||
}
|
||||
|
||||
// Convierte un tilemap 2D a vector 1D flat
|
||||
auto RoomLoader::flattenTilemap(const std::vector<std::vector<int>>& tilemap_2d) -> std::vector<int> {
|
||||
auto RoomLoader::flattenTilemap(const std::vector<std::vector<int>>& tilemap_2d) -> std::vector<int> { // NOLINT(readability-convert-member-functions-to-static, readability-named-parameter)
|
||||
std::vector<int> tilemap_flat;
|
||||
tilemap_flat.reserve(512); // 16 rows × 32 cols
|
||||
|
||||
@@ -53,7 +53,7 @@ auto RoomLoader::flattenTilemap(const std::vector<std::vector<int>>& tilemap_2d)
|
||||
}
|
||||
|
||||
// Parsea la configuración general de la habitación
|
||||
void RoomLoader::parseRoomConfig(const fkyaml::node& yaml, Room::Data& room, const std::string& file_name) {
|
||||
void RoomLoader::parseRoomConfig(const fkyaml::node& yaml, Room::Data& room, const std::string& file_name) { // NOLINT(readability-convert-member-functions-to-static)
|
||||
if (!yaml.contains("room")) {
|
||||
return;
|
||||
}
|
||||
@@ -120,7 +120,7 @@ void RoomLoader::parseRoomConnections(const fkyaml::node& conn_node, Room::Data&
|
||||
}
|
||||
|
||||
// Parsea el tilemap de la habitación
|
||||
void RoomLoader::parseTilemap(const fkyaml::node& yaml, Room::Data& room, const std::string& file_name, bool verbose) {
|
||||
void RoomLoader::parseTilemap(const fkyaml::node& yaml, Room::Data& room, const std::string& file_name, bool verbose) { // NOLINT(readability-convert-member-functions-to-static)
|
||||
if (!yaml.contains("tilemap")) {
|
||||
std::cerr << "Warning: No tilemap found in " << file_name << '\n';
|
||||
return;
|
||||
@@ -152,7 +152,7 @@ void RoomLoader::parseTilemap(const fkyaml::node& yaml, Room::Data& room, const
|
||||
}
|
||||
|
||||
// Parsea los límites de movimiento de un enemigo
|
||||
void RoomLoader::parseEnemyBoundaries(const fkyaml::node& bounds_node, Enemy::Data& enemy) {
|
||||
void RoomLoader::parseEnemyBoundaries(const fkyaml::node& bounds_node, Enemy::Data& enemy) { // NOLINT(readability-convert-member-functions-to-static)
|
||||
// Nuevo formato: position1 y position2
|
||||
if (bounds_node.contains("position1")) {
|
||||
const auto& pos1 = bounds_node["position1"];
|
||||
@@ -189,7 +189,7 @@ void RoomLoader::parseEnemyBoundaries(const fkyaml::node& bounds_node, Enemy::Da
|
||||
}
|
||||
|
||||
// Parsea los datos de un enemigo individual
|
||||
auto RoomLoader::parseEnemyData(const fkyaml::node& enemy_node) -> Enemy::Data {
|
||||
auto RoomLoader::parseEnemyData(const fkyaml::node& enemy_node) -> Enemy::Data { // NOLINT(readability-convert-member-functions-to-static)
|
||||
Enemy::Data enemy;
|
||||
|
||||
// Animation path
|
||||
@@ -246,7 +246,7 @@ auto RoomLoader::parseEnemyData(const fkyaml::node& enemy_node) -> Enemy::Data {
|
||||
}
|
||||
|
||||
// Parsea la lista de enemigos de la habitación
|
||||
void RoomLoader::parseEnemies(const fkyaml::node& yaml, Room::Data& room, bool verbose) {
|
||||
void RoomLoader::parseEnemies(const fkyaml::node& yaml, Room::Data& room, bool verbose) { // NOLINT(readability-convert-member-functions-to-static)
|
||||
if (!yaml.contains("enemies") || yaml["enemies"].is_null()) {
|
||||
return;
|
||||
}
|
||||
@@ -263,7 +263,7 @@ void RoomLoader::parseEnemies(const fkyaml::node& yaml, Room::Data& room, bool v
|
||||
}
|
||||
|
||||
// Parsea los datos de un item individual
|
||||
auto RoomLoader::parseItemData(const fkyaml::node& item_node, const Room::Data& room) -> Item::Data {
|
||||
auto RoomLoader::parseItemData(const fkyaml::node& item_node, const Room::Data& room) -> Item::Data { // NOLINT(readability-convert-member-functions-to-static)
|
||||
Item::Data item;
|
||||
|
||||
// Tileset file
|
||||
@@ -300,7 +300,7 @@ auto RoomLoader::parseItemData(const fkyaml::node& item_node, const Room::Data&
|
||||
}
|
||||
|
||||
// Parsea la lista de items de la habitación
|
||||
void RoomLoader::parseItems(const fkyaml::node& yaml, Room::Data& room, bool verbose) {
|
||||
void RoomLoader::parseItems(const fkyaml::node& yaml, Room::Data& room, bool verbose) { // NOLINT(readability-convert-member-functions-to-static)
|
||||
if (!yaml.contains("items") || yaml["items"].is_null()) {
|
||||
return;
|
||||
}
|
||||
@@ -317,7 +317,7 @@ void RoomLoader::parseItems(const fkyaml::node& yaml, Room::Data& room, bool ver
|
||||
}
|
||||
|
||||
// Carga un archivo de room en formato YAML
|
||||
auto RoomLoader::loadYAML(const std::string& file_path, bool verbose) -> Room::Data {
|
||||
auto RoomLoader::loadYAML(const std::string& file_path, bool verbose) -> Room::Data { // NOLINT(readability-convert-member-functions-to-static)
|
||||
Room::Data room;
|
||||
|
||||
// Extract filename for logging
|
||||
|
||||
@@ -67,7 +67,7 @@ class RoomLoader {
|
||||
* @param tilemap_2d Array 2D de tiles (16 rows × 32 cols)
|
||||
* @return Vector 1D flat con 512 elementos
|
||||
*/
|
||||
static auto flattenTilemap(const std::vector<std::vector<int>>& tilemap_2d) -> std::vector<int>;
|
||||
static auto flattenTilemap(const std::vector<std::vector<int>>& tilemap_2d) -> std::vector<int>; // NOLINT(readability-avoid-const-params-in-decls)
|
||||
|
||||
/**
|
||||
* @brief Parsea la configuración general de la habitación
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
#include <algorithm> // Para std::ranges::any_of
|
||||
|
||||
// Comprueba si la habitación ya ha sido visitada
|
||||
auto RoomTracker::hasBeenVisited(const std::string& name) -> bool {
|
||||
return std::ranges::any_of(rooms_, [&name](const auto& l) { return l == name; });
|
||||
auto RoomTracker::hasBeenVisited(const std::string& name) -> bool { // NOLINT(readability-convert-member-functions-to-static)
|
||||
return std::ranges::any_of(rooms_, [&name](const auto& l) -> bool { return l == name; });
|
||||
}
|
||||
|
||||
// Añade la habitación a la lista
|
||||
auto RoomTracker::addRoom(const std::string& name) -> bool {
|
||||
auto RoomTracker::addRoom(const std::string& name) -> bool { // NOLINT(readability-convert-member-functions-to-static)
|
||||
// Comprueba si la habitación ya ha sido visitada
|
||||
if (!hasBeenVisited(name)) {
|
||||
// En caso contrario añádela a la lista
|
||||
rooms_.push_back(name);
|
||||
return true;
|
||||
return true; // NOLINT(readability-simplify-boolean-expr)
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -65,7 +65,7 @@ void Scoreboard::update(float delta_time) {
|
||||
}
|
||||
|
||||
// Obtiene el tiempo transcurrido de partida
|
||||
auto Scoreboard::getTime() -> Scoreboard::ClockData {
|
||||
auto Scoreboard::getTime() -> Scoreboard::ClockData { // NOLINT(readability-convert-member-functions-to-static)
|
||||
const Uint32 TIME_ELAPSED = SDL_GetTicks() - data_->ini_clock - paused_time_elapsed_;
|
||||
|
||||
ClockData time;
|
||||
@@ -149,7 +149,7 @@ void Scoreboard::fillTexture() {
|
||||
// Muestra si suena la música
|
||||
if (data_->music) {
|
||||
const Uint8 C = data_->color;
|
||||
SDL_FRect clip = {0, 8, 8, 8};
|
||||
SDL_FRect clip = {.x = 0, .y = 8, .w = 8, .h = 8};
|
||||
item_surface_->renderWithColorReplace(20 * Tile::SIZE, LINE2, 1, C, &clip);
|
||||
}
|
||||
|
||||
@@ -157,13 +157,13 @@ void Scoreboard::fillTexture() {
|
||||
auto text = Resource::Cache::get()->getText("smb2");
|
||||
const std::string TIME_TEXT = std::to_string((clock_.minutes % 100) / 10) + std::to_string(clock_.minutes % 10) + clock_.separator + std::to_string((clock_.seconds % 60) / 10) + std::to_string(clock_.seconds % 10);
|
||||
const std::string ITEMS_TEXT = std::to_string(data_->items / 100) + std::to_string((data_->items % 100) / 10) + std::to_string(data_->items % 10);
|
||||
text->writeColored(Tile::SIZE, LINE1, Locale::get()->get("scoreboard.items"), data_->color);
|
||||
text->writeColored(Tile::SIZE, LINE1, Locale::get()->get("scoreboard.items"), data_->color); // NOLINT(readability-static-accessed-through-instance)
|
||||
text->writeColored(17 * Tile::SIZE, LINE1, ITEMS_TEXT, items_color_);
|
||||
text->writeColored(20 * Tile::SIZE, LINE1, Locale::get()->get("scoreboard.time"), data_->color);
|
||||
text->writeColored(20 * Tile::SIZE, LINE1, Locale::get()->get("scoreboard.time"), data_->color); // NOLINT(readability-static-accessed-through-instance)
|
||||
text->writeColored(26 * Tile::SIZE, LINE1, TIME_TEXT, stringToColor("white"));
|
||||
|
||||
const std::string ROOMS_TEXT = std::to_string(data_->rooms / 100) + std::to_string((data_->rooms % 100) / 10) + std::to_string(data_->rooms % 10);
|
||||
text->writeColored(22 * Tile::SIZE, LINE2, Locale::get()->get("scoreboard.rooms"), stringToColor("white"));
|
||||
text->writeColored(22 * Tile::SIZE, LINE2, Locale::get()->get("scoreboard.rooms"), stringToColor("white")); // NOLINT(readability-static-accessed-through-instance)
|
||||
text->writeColored(28 * Tile::SIZE, LINE2, ROOMS_TEXT, stringToColor("white"));
|
||||
|
||||
// Deja el renderizador como estaba
|
||||
|
||||
@@ -40,7 +40,7 @@ void Stats::init()
|
||||
}
|
||||
|
||||
// Añade una muerte a las estadisticas
|
||||
void Stats::addDeath(const std::string& name) {
|
||||
void Stats::addDeath(const std::string& name) { // NOLINT(readability-convert-member-functions-to-static)
|
||||
// Primero busca si ya hay una entrada con ese nombre
|
||||
const int INDEX = findByName(name, buffer_list_);
|
||||
if (INDEX != -1) {
|
||||
@@ -58,7 +58,7 @@ void Stats::addDeath(const std::string& name) {
|
||||
}
|
||||
|
||||
// Añade una visita a las estadisticas
|
||||
void Stats::addVisit(const std::string& name) {
|
||||
void Stats::addVisit(const std::string& name) { // NOLINT(readability-convert-member-functions-to-static)
|
||||
// Primero busca si ya hay una entrada con ese nombre
|
||||
const int INDEX = findByName(name, buffer_list_);
|
||||
if (INDEX != -1) {
|
||||
@@ -76,7 +76,7 @@ void Stats::addVisit(const std::string& name) {
|
||||
}
|
||||
|
||||
// Busca una entrada en la lista por nombre
|
||||
auto Stats::findByName(const std::string& name, const std::vector<RoomData>& list) -> int {
|
||||
auto Stats::findByName(const std::string& name, const std::vector<RoomData>& list) -> int { // NOLINT(readability-convert-member-functions-to-static)
|
||||
int i = 0;
|
||||
|
||||
for (const auto& l : list) {
|
||||
@@ -90,7 +90,7 @@ auto Stats::findByName(const std::string& name, const std::vector<RoomData>& lis
|
||||
}
|
||||
|
||||
// Carga las estadisticas desde un fichero
|
||||
auto Stats::loadFromFile(const std::string& file_path, std::vector<RoomData>& list) -> bool {
|
||||
auto Stats::loadFromFile(const std::string& file_path, std::vector<RoomData>& list) -> bool { // NOLINT(readability-convert-member-functions-to-static)
|
||||
list.clear();
|
||||
|
||||
// Indicador de éxito en la carga
|
||||
@@ -109,7 +109,7 @@ auto Stats::loadFromFile(const std::string& file_path, std::vector<RoomData>& li
|
||||
line.pop_back();
|
||||
}
|
||||
// Comprueba que la linea no sea un comentario
|
||||
if (line.substr(0, 1) != "#") {
|
||||
if (!line.starts_with("#")) {
|
||||
RoomData stat;
|
||||
std::stringstream ss(line);
|
||||
std::string tmp;
|
||||
@@ -159,7 +159,7 @@ void Stats::saveToFile(const std::string& file_path, const std::vector<RoomData>
|
||||
}
|
||||
|
||||
// Calcula cual es la habitación con más muertes
|
||||
void Stats::checkWorstNightmare() {
|
||||
void Stats::checkWorstNightmare() { // NOLINT(readability-convert-member-functions-to-static)
|
||||
int deaths = 0;
|
||||
for (const auto& item : list_) {
|
||||
if (item.died > deaths) {
|
||||
@@ -171,7 +171,7 @@ void Stats::checkWorstNightmare() {
|
||||
|
||||
// Añade una entrada al diccionario
|
||||
void Stats::addDictionary(const std::string& number, const std::string& name) {
|
||||
dictionary_.push_back({number, name});
|
||||
dictionary_.push_back({.number = number, .name = name});
|
||||
}
|
||||
|
||||
// Vuelca los datos del buffer en la lista de estadisticas
|
||||
|
||||
@@ -42,7 +42,7 @@ void TilemapRenderer::update(float delta_time) {
|
||||
// Renderiza el mapa completo en pantalla
|
||||
void TilemapRenderer::render() {
|
||||
// Dibuja la textura con el mapa en pantalla
|
||||
SDL_FRect dest = {0, 0, PlayArea::WIDTH, PlayArea::HEIGHT};
|
||||
SDL_FRect dest = {.x = 0, .y = 0, .w = PlayArea::WIDTH, .h = PlayArea::HEIGHT};
|
||||
map_surface_->render(nullptr, &dest);
|
||||
|
||||
// Dibuja los tiles animados
|
||||
@@ -103,7 +103,7 @@ void TilemapRenderer::redrawMap(const CollisionMap* collision_map) {
|
||||
#endif
|
||||
|
||||
// Pinta el mapa estático y debug lines
|
||||
void TilemapRenderer::fillMapTexture(const CollisionMap* collision_map) {
|
||||
void TilemapRenderer::fillMapTexture(const CollisionMap* collision_map) { // NOLINT(readability-convert-member-functions-to-static)
|
||||
const Uint8 COLOR = stringToColor(bg_color_);
|
||||
auto previous_renderer = Screen::get()->getRendererSurface();
|
||||
Screen::get()->setRendererSurface(map_surface_);
|
||||
@@ -111,7 +111,7 @@ void TilemapRenderer::fillMapTexture(const CollisionMap* collision_map) {
|
||||
|
||||
// Los tileSetFiles son de 20x20 tiles. El primer tile es el 0. Cuentan hacia la derecha y hacia abajo
|
||||
|
||||
SDL_FRect clip = {0, 0, TILE_SIZE, TILE_SIZE};
|
||||
SDL_FRect clip = {.x = 0, .y = 0, .w = TILE_SIZE, .h = TILE_SIZE};
|
||||
for (int y = 0; y < MAP_HEIGHT; ++y) {
|
||||
for (int x = 0; x < MAP_WIDTH; ++x) {
|
||||
// Tiled pone los tiles vacios del mapa como cero y empieza a contar de 1 a n.
|
||||
@@ -145,7 +145,7 @@ void TilemapRenderer::fillMapTexture(const CollisionMap* collision_map) {
|
||||
}
|
||||
|
||||
// Localiza todos los tiles animados
|
||||
void TilemapRenderer::setAnimatedTiles(const CollisionMap* collision_map) {
|
||||
void TilemapRenderer::setAnimatedTiles(const CollisionMap* collision_map) { // NOLINT(readability-convert-member-functions-to-static)
|
||||
// Recorre la habitación entera por filas buscando tiles de tipo t_animated
|
||||
for (int i = 0; i < (int)tile_map_.size(); ++i) {
|
||||
const auto TILE_TYPE = collision_map->getTile(i);
|
||||
@@ -168,7 +168,7 @@ void TilemapRenderer::setAnimatedTiles(const CollisionMap* collision_map) {
|
||||
}
|
||||
|
||||
// Actualiza tiles animados
|
||||
void TilemapRenderer::updateAnimatedTiles() {
|
||||
void TilemapRenderer::updateAnimatedTiles() { // NOLINT(readability-make-member-function-const)
|
||||
const int NUM_FRAMES = 4;
|
||||
|
||||
// Calcular frame actual basado en tiempo
|
||||
|
||||
@@ -308,6 +308,17 @@ namespace Options {
|
||||
}
|
||||
}
|
||||
|
||||
// Helper: carga el campo palette con validación extra
|
||||
void loadPaletteFromYaml(const fkyaml::node& vid) {
|
||||
if (!vid.contains("palette")) { return; }
|
||||
try {
|
||||
auto palette_str = vid["palette"].get_value<std::string>();
|
||||
video.palette = isValidPalette(palette_str) ? palette_str : Defaults::Video::PALETTE_NAME;
|
||||
} catch (...) {
|
||||
video.palette = Defaults::Video::PALETTE_NAME;
|
||||
}
|
||||
}
|
||||
|
||||
// Carga los campos básicos de configuración de video
|
||||
void loadBasicVideoFieldsFromYaml(const fkyaml::node& vid) {
|
||||
// fullscreen (antes era "mode")
|
||||
@@ -377,18 +388,7 @@ namespace Options {
|
||||
}
|
||||
}
|
||||
|
||||
if (vid.contains("palette")) {
|
||||
try {
|
||||
auto palette_str = vid["palette"].get_value<std::string>();
|
||||
if (isValidPalette(palette_str)) {
|
||||
video.palette = palette_str;
|
||||
} else {
|
||||
video.palette = Defaults::Video::PALETTE_NAME;
|
||||
}
|
||||
} catch (...) {
|
||||
video.palette = Defaults::Video::PALETTE_NAME;
|
||||
}
|
||||
}
|
||||
loadPaletteFromYaml(vid);
|
||||
}
|
||||
|
||||
// Carga configuración de video desde YAML
|
||||
@@ -745,7 +745,9 @@ namespace Options {
|
||||
// Preservar el índice cargado desde config.yaml; clampar al rango válido.
|
||||
if (!postfx_presets.empty()) {
|
||||
current_postfx_preset = std::clamp(
|
||||
current_postfx_preset, 0, static_cast<int>(postfx_presets.size()) - 1);
|
||||
current_postfx_preset,
|
||||
0,
|
||||
static_cast<int>(postfx_presets.size()) - 1);
|
||||
} else {
|
||||
current_postfx_preset = 0;
|
||||
}
|
||||
@@ -854,12 +856,12 @@ namespace Options {
|
||||
|
||||
// Cargar los presets recién creados
|
||||
postfx_presets.clear();
|
||||
postfx_presets.push_back({"CRT", 0.6F, 0.7F, 0.3F, 0.6F, 0.8F, 0.0F, 0.0F, 0.0F});
|
||||
postfx_presets.push_back({"NTSC", 0.4F, 0.5F, 0.2F, 0.4F, 0.5F, 0.0F, 0.6F, 0.0F});
|
||||
postfx_presets.push_back({"CURVED", 0.5F, 0.6F, 0.1F, 0.5F, 0.7F, 0.8F, 0.0F, 0.0F});
|
||||
postfx_presets.push_back({"SCANLINES",0.0F, 0.8F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F});
|
||||
postfx_presets.push_back({"SUBTLE", 0.3F, 0.4F, 0.05F, 0.0F, 0.3F, 0.0F, 0.0F, 0.0F});
|
||||
postfx_presets.push_back({"CRT LIVE", 0.5F, 0.6F, 0.3F, 0.3F, 0.4F, 0.3F, 0.4F, 0.8F});
|
||||
postfx_presets.push_back({"CRT", 0.6F, 0.7F, 0.3F, 0.6F, 0.8F, 0.0F, 0.0F, 0.0F});
|
||||
postfx_presets.push_back({"NTSC", 0.4F, 0.5F, 0.2F, 0.4F, 0.5F, 0.0F, 0.6F, 0.0F});
|
||||
postfx_presets.push_back({"CURVED", 0.5F, 0.6F, 0.1F, 0.5F, 0.7F, 0.8F, 0.0F, 0.0F});
|
||||
postfx_presets.push_back({"SCANLINES", 0.0F, 0.8F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F});
|
||||
postfx_presets.push_back({"SUBTLE", 0.3F, 0.4F, 0.05F, 0.0F, 0.3F, 0.0F, 0.0F, 0.0F});
|
||||
postfx_presets.push_back({"CRT LIVE", 0.5F, 0.6F, 0.3F, 0.3F, 0.4F, 0.3F, 0.4F, 0.8F});
|
||||
current_postfx_preset = 0;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -117,15 +117,15 @@ namespace Options {
|
||||
|
||||
// Estructura para un preset de PostFX
|
||||
struct PostFXPreset {
|
||||
std::string name; // Nombre del preset
|
||||
float vignette{0.6F}; // Intensidad de la viñeta (0.0 = ninguna, 1.0 = máxima)
|
||||
float scanlines{0.7F}; // Intensidad de las scanlines (0.0 = desactivadas, 1.0 = máximas)
|
||||
float chroma{0.15F}; // Intensidad de la aberración cromática (0.0 = ninguna, 1.0 = máxima)
|
||||
float mask{0.0F}; // Intensidad de la máscara de fósforo RGB (0.0 = desactivada, 1.0 = máxima)
|
||||
float gamma{0.0F}; // Corrección gamma input 2.4 / output 2.2 (0.0 = off, 1.0 = plena)
|
||||
float curvature{0.0F}; // Distorsión barrel CRT (0.0 = plana, 1.0 = máxima curvatura)
|
||||
float bleeding{0.0F}; // Sangrado de color NTSC horizontal Y/C (0.0 = off, 1.0 = máximo)
|
||||
float flicker{0.0F}; // Parpadeo de fósforo CRT ~50 Hz (0.0 = off, 1.0 = máximo)
|
||||
std::string name; // Nombre del preset
|
||||
float vignette{0.6F}; // Intensidad de la viñeta (0.0 = ninguna, 1.0 = máxima)
|
||||
float scanlines{0.7F}; // Intensidad de las scanlines (0.0 = desactivadas, 1.0 = máximas)
|
||||
float chroma{0.15F}; // Intensidad de la aberración cromática (0.0 = ninguna, 1.0 = máxima)
|
||||
float mask{0.0F}; // Intensidad de la máscara de fósforo RGB (0.0 = desactivada, 1.0 = máxima)
|
||||
float gamma{0.0F}; // Corrección gamma input 2.4 / output 2.2 (0.0 = off, 1.0 = plena)
|
||||
float curvature{0.0F}; // Distorsión barrel CRT (0.0 = plana, 1.0 = máxima curvatura)
|
||||
float bleeding{0.0F}; // Sangrado de color NTSC horizontal Y/C (0.0 = off, 1.0 = máximo)
|
||||
float flicker{0.0F}; // Parpadeo de fósforo CRT ~50 Hz (0.0 = off, 1.0 = máximo)
|
||||
};
|
||||
|
||||
// --- Variables globales ---
|
||||
|
||||
@@ -30,7 +30,7 @@ Credits::Credits()
|
||||
// Configura la escena
|
||||
SceneManager::current = SceneManager::Scene::CREDITS;
|
||||
SceneManager::options = SceneManager::Options::NONE;
|
||||
shining_sprite_->setPos({194, 174, 8, 8});
|
||||
shining_sprite_->setPos({.x = 194, .y = 174, .w = 8, .h = 8});
|
||||
|
||||
Screen::get()->setBorderColor(static_cast<Uint8>(PaletteColor::BLACK)); // Cambia el color del borde
|
||||
fillTexture(); // Escribe el texto en la textura
|
||||
@@ -52,37 +52,37 @@ void Credits::handleInput() {
|
||||
}
|
||||
|
||||
// Inicializa los textos
|
||||
void Credits::iniTexts() {
|
||||
void Credits::iniTexts() { // NOLINT(readability-convert-member-functions-to-static)
|
||||
auto* loc = Locale::get();
|
||||
|
||||
texts_.clear();
|
||||
texts_.push_back({"", static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({loc->get("credits.instructions"), static_cast<Uint8>(PaletteColor::YELLOW)});
|
||||
texts_.push_back({"", static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({loc->get("credits.l0"), static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({loc->get("credits.l1"), static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({loc->get("credits.l2"), static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({"", static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({"", static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({.label = "", .color = static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({.label = loc->get("credits.instructions"), .color = static_cast<Uint8>(PaletteColor::YELLOW)});
|
||||
texts_.push_back({.label = "", .color = static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({.label = loc->get("credits.l0"), .color = static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({.label = loc->get("credits.l1"), .color = static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({.label = loc->get("credits.l2"), .color = static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({.label = "", .color = static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({.label = "", .color = static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
|
||||
texts_.push_back({loc->get("credits.keys"), static_cast<Uint8>(PaletteColor::YELLOW)});
|
||||
texts_.push_back({"", static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({loc->get("credits.keys_move"), static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({loc->get("credits.f8"), static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({loc->get("credits.f11"), static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({loc->get("credits.f1f2"), static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({loc->get("credits.f3"), static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({loc->get("credits.f9"), static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({"", static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({"", static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({.label = loc->get("credits.keys"), .color = static_cast<Uint8>(PaletteColor::YELLOW)});
|
||||
texts_.push_back({.label = "", .color = static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({.label = loc->get("credits.keys_move"), .color = static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({.label = loc->get("credits.f8"), .color = static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({.label = loc->get("credits.f11"), .color = static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({.label = loc->get("credits.f1f2"), .color = static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({.label = loc->get("credits.f3"), .color = static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({.label = loc->get("credits.f9"), .color = static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({.label = "", .color = static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({.label = "", .color = static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
|
||||
texts_.push_back({loc->get("credits.author"), static_cast<Uint8>(PaletteColor::YELLOW)});
|
||||
texts_.push_back({loc->get("credits.date"), static_cast<Uint8>(PaletteColor::YELLOW)});
|
||||
texts_.push_back({"", static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({"", static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({.label = loc->get("credits.author"), .color = static_cast<Uint8>(PaletteColor::YELLOW)});
|
||||
texts_.push_back({.label = loc->get("credits.date"), .color = static_cast<Uint8>(PaletteColor::YELLOW)});
|
||||
texts_.push_back({.label = "", .color = static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({.label = "", .color = static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
|
||||
texts_.push_back({loc->get("credits.love"), static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({"", static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({.label = loc->get("credits.love"), .color = static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
texts_.push_back({.label = "", .color = static_cast<Uint8>(PaletteColor::WHITE)});
|
||||
}
|
||||
|
||||
// Escribe el texto en la textura
|
||||
|
||||
@@ -14,7 +14,7 @@ class Credits {
|
||||
public:
|
||||
// --- Constructor y Destructor ---
|
||||
Credits();
|
||||
~Credits();
|
||||
~Credits(); // NOLINT(modernize-use-equals-default, performance-trivially-destructible) -- defined in .cpp for unique_ptr with forward declarations
|
||||
|
||||
// --- Bucle principal ---
|
||||
void run();
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
#include "utils/delta_timer.hpp" // Para DeltaTimer
|
||||
#include "utils/utils.hpp" // Para PaletteColor
|
||||
|
||||
// Destructor
|
||||
Ending::~Ending() = default;
|
||||
|
||||
// Constructor
|
||||
Ending::Ending()
|
||||
: delta_timer_(std::make_unique<DeltaTimer>()) {
|
||||
@@ -31,9 +34,6 @@ Ending::Ending()
|
||||
Screen::get()->setBorderColor(static_cast<Uint8>(PaletteColor::BLACK)); // Cambia el color del borde
|
||||
}
|
||||
|
||||
// Destructor
|
||||
Ending::~Ending() = default;
|
||||
|
||||
// Actualiza el objeto
|
||||
void Ending::update() {
|
||||
const float DELTA_TIME = delta_timer_->tick();
|
||||
@@ -170,39 +170,39 @@ void Ending::updateState(float delta_time) {
|
||||
}
|
||||
|
||||
// Inicializa los textos
|
||||
void Ending::iniTexts() {
|
||||
void Ending::iniTexts() { // NOLINT(readability-convert-member-functions-to-static)
|
||||
// Vector con los textos (traducidos según el idioma activo)
|
||||
std::vector<TextAndPosition> texts;
|
||||
auto* loc = Locale::get();
|
||||
|
||||
// Escena #0
|
||||
texts.push_back({loc->get("ending.t0"), 32});
|
||||
texts.push_back({loc->get("ending.t1"), 42});
|
||||
texts.push_back({loc->get("ending.t2"), 142});
|
||||
texts.push_back({loc->get("ending.t3"), 152});
|
||||
texts.push_back({.caption = loc->get("ending.t0"), .pos = 32});
|
||||
texts.push_back({.caption = loc->get("ending.t1"), .pos = 42});
|
||||
texts.push_back({.caption = loc->get("ending.t2"), .pos = 142});
|
||||
texts.push_back({.caption = loc->get("ending.t3"), .pos = 152});
|
||||
|
||||
// Escena #1
|
||||
texts.push_back({loc->get("ending.t4"), 1});
|
||||
texts.push_back({loc->get("ending.t5"), 11});
|
||||
texts.push_back({loc->get("ending.t6"), 21});
|
||||
texts.push_back({.caption = loc->get("ending.t4"), .pos = 1});
|
||||
texts.push_back({.caption = loc->get("ending.t5"), .pos = 11});
|
||||
texts.push_back({.caption = loc->get("ending.t6"), .pos = 21});
|
||||
|
||||
texts.push_back({loc->get("ending.t7"), 161});
|
||||
texts.push_back({loc->get("ending.t8"), 171});
|
||||
texts.push_back({.caption = loc->get("ending.t7"), .pos = 161});
|
||||
texts.push_back({.caption = loc->get("ending.t8"), .pos = 171});
|
||||
|
||||
texts.push_back({loc->get("ending.t9"), 181});
|
||||
texts.push_back({.caption = loc->get("ending.t9"), .pos = 181});
|
||||
|
||||
// Escena #2
|
||||
texts.push_back({loc->get("ending.t10"), 19});
|
||||
texts.push_back({loc->get("ending.t11"), 29});
|
||||
texts.push_back({.caption = loc->get("ending.t10"), .pos = 19});
|
||||
texts.push_back({.caption = loc->get("ending.t11"), .pos = 29});
|
||||
|
||||
// Escena #3
|
||||
texts.push_back({loc->get("ending.t12"), 36});
|
||||
texts.push_back({loc->get("ending.t13"), 46});
|
||||
texts.push_back({.caption = loc->get("ending.t12"), .pos = 36});
|
||||
texts.push_back({.caption = loc->get("ending.t13"), .pos = 46});
|
||||
|
||||
// Escena #4
|
||||
texts.push_back({loc->get("ending.t14"), 36});
|
||||
texts.push_back({loc->get("ending.t15"), 46});
|
||||
texts.push_back({loc->get("ending.t16"), 158});
|
||||
texts.push_back({.caption = loc->get("ending.t14"), .pos = 36});
|
||||
texts.push_back({.caption = loc->get("ending.t15"), .pos = 46});
|
||||
texts.push_back({.caption = loc->get("ending.t16"), .pos = 158});
|
||||
|
||||
// Crea los sprites
|
||||
sprite_texts_.clear();
|
||||
@@ -242,11 +242,11 @@ void Ending::iniPics() {
|
||||
// Vector con las rutas y la posición
|
||||
std::vector<TextAndPosition> pics;
|
||||
|
||||
pics.push_back({"ending1.gif", 48});
|
||||
pics.push_back({"ending2.gif", 26});
|
||||
pics.push_back({"ending3.gif", 29});
|
||||
pics.push_back({"ending4.gif", 63});
|
||||
pics.push_back({"ending5.gif", 53});
|
||||
pics.push_back({.caption = "ending1.gif", .pos = 48});
|
||||
pics.push_back({.caption = "ending2.gif", .pos = 26});
|
||||
pics.push_back({.caption = "ending3.gif", .pos = 29});
|
||||
pics.push_back({.caption = "ending4.gif", .pos = 63});
|
||||
pics.push_back({.caption = "ending5.gif", .pos = 53});
|
||||
|
||||
// Crea los sprites
|
||||
sprite_pics_.clear();
|
||||
@@ -274,7 +274,7 @@ void Ending::iniPics() {
|
||||
}
|
||||
|
||||
// Inicializa las escenas
|
||||
void Ending::iniScenes() {
|
||||
void Ending::iniScenes() { // NOLINT(readability-convert-member-functions-to-static)
|
||||
// Variable para los tiempos
|
||||
int trigger;
|
||||
constexpr int LAPSE = 80;
|
||||
@@ -291,13 +291,13 @@ void Ending::iniScenes() {
|
||||
sc.text_index.clear();
|
||||
trigger = 85 * 2;
|
||||
trigger += LAPSE;
|
||||
sc.text_index.push_back({0, trigger});
|
||||
sc.text_index.push_back({.index = 0, .trigger = trigger});
|
||||
trigger += LAPSE;
|
||||
sc.text_index.push_back({1, trigger});
|
||||
sc.text_index.push_back({.index = 1, .trigger = trigger});
|
||||
trigger += LAPSE * 3;
|
||||
sc.text_index.push_back({2, trigger});
|
||||
sc.text_index.push_back({.index = 2, .trigger = trigger});
|
||||
trigger += LAPSE;
|
||||
sc.text_index.push_back({3, trigger});
|
||||
sc.text_index.push_back({.index = 3, .trigger = trigger});
|
||||
scenes_.push_back(sc);
|
||||
|
||||
// Crea la escena #1
|
||||
@@ -306,17 +306,17 @@ void Ending::iniScenes() {
|
||||
sc.text_index.clear();
|
||||
trigger = 140 * 2;
|
||||
trigger += LAPSE;
|
||||
sc.text_index.push_back({4, trigger});
|
||||
sc.text_index.push_back({.index = 4, .trigger = trigger});
|
||||
trigger += LAPSE;
|
||||
sc.text_index.push_back({5, trigger});
|
||||
sc.text_index.push_back({.index = 5, .trigger = trigger});
|
||||
trigger += LAPSE;
|
||||
sc.text_index.push_back({6, trigger});
|
||||
sc.text_index.push_back({.index = 6, .trigger = trigger});
|
||||
trigger += LAPSE * 3;
|
||||
sc.text_index.push_back({7, trigger});
|
||||
sc.text_index.push_back({.index = 7, .trigger = trigger});
|
||||
trigger += LAPSE;
|
||||
sc.text_index.push_back({8, trigger});
|
||||
sc.text_index.push_back({.index = 8, .trigger = trigger});
|
||||
trigger += LAPSE * 3;
|
||||
sc.text_index.push_back({9, trigger});
|
||||
sc.text_index.push_back({.index = 9, .trigger = trigger});
|
||||
scenes_.push_back(sc);
|
||||
|
||||
// Crea la escena #2
|
||||
@@ -325,9 +325,9 @@ void Ending::iniScenes() {
|
||||
sc.text_index.clear();
|
||||
trigger = 148 / 2;
|
||||
trigger += LAPSE;
|
||||
sc.text_index.push_back({10, trigger});
|
||||
sc.text_index.push_back({.index = 10, .trigger = trigger});
|
||||
trigger += LAPSE;
|
||||
sc.text_index.push_back({11, trigger});
|
||||
sc.text_index.push_back({.index = 11, .trigger = trigger});
|
||||
scenes_.push_back(sc);
|
||||
|
||||
// Crea la escena #3
|
||||
@@ -336,9 +336,9 @@ void Ending::iniScenes() {
|
||||
sc.text_index.clear();
|
||||
trigger = 87 / 2;
|
||||
trigger += LAPSE;
|
||||
sc.text_index.push_back({12, trigger});
|
||||
sc.text_index.push_back({.index = 12, .trigger = trigger});
|
||||
trigger += LAPSE / 2;
|
||||
sc.text_index.push_back({13, trigger});
|
||||
sc.text_index.push_back({.index = 13, .trigger = trigger});
|
||||
scenes_.push_back(sc);
|
||||
|
||||
// Crea la escena #4
|
||||
@@ -347,11 +347,11 @@ void Ending::iniScenes() {
|
||||
sc.text_index.clear();
|
||||
trigger = 91 * 2;
|
||||
trigger += LAPSE;
|
||||
sc.text_index.push_back({14, trigger});
|
||||
sc.text_index.push_back({.index = 14, .trigger = trigger});
|
||||
trigger += LAPSE * 2;
|
||||
sc.text_index.push_back({15, trigger});
|
||||
sc.text_index.push_back({.index = 15, .trigger = trigger});
|
||||
trigger += LAPSE * 3;
|
||||
sc.text_index.push_back({16, trigger});
|
||||
sc.text_index.push_back({.index = 16, .trigger = trigger});
|
||||
scenes_.push_back(sc);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ class Ending {
|
||||
public:
|
||||
// --- Constructor y Destructor ---
|
||||
Ending();
|
||||
~Ending();
|
||||
~Ending(); // NOLINT(modernize-use-equals-default, performance-trivially-destructible) -- defined in .cpp for unique_ptr with forward declarations
|
||||
|
||||
// --- Bucle principal ---
|
||||
void run();
|
||||
|
||||
@@ -374,7 +374,7 @@ void Ending2::renderTexts() {
|
||||
}
|
||||
|
||||
// Coloca los sprites en su sito
|
||||
void Ending2::placeSprites() {
|
||||
void Ending2::placeSprites() const {
|
||||
for (int i = 0; i < static_cast<int>(sprites_.size()); ++i) {
|
||||
const float X = i % 2 == 0 ? FIRST_COL : SECOND_COL;
|
||||
const float Y = ((i / 1) * (sprite_max_height_ + DIST_SPRITE_TEXT + Resource::Cache::get()->getText("smb2")->getCharacterSize() + DIST_SPRITE_SPRITE)) + Options::game.height + INITIAL_Y_OFFSET;
|
||||
@@ -383,7 +383,7 @@ void Ending2::placeSprites() {
|
||||
const float DX = -(W / 2);
|
||||
const float DY = sprite_max_height_ - H;
|
||||
|
||||
sprites_.at(i)->setPos({X + DX, Y + DY, W, H});
|
||||
sprites_.at(i)->setPos({.x = X + DX, .y = Y + DY, .w = W, .h = H});
|
||||
sprites_.at(i)->setVelY(SPRITE_DESP_SPEED);
|
||||
}
|
||||
|
||||
@@ -395,7 +395,7 @@ void Ending2::placeSprites() {
|
||||
}
|
||||
|
||||
// Crea los sprites con las texturas con los textos
|
||||
void Ending2::createSpriteTexts() {
|
||||
void Ending2::createSpriteTexts() { // NOLINT(readability-convert-member-functions-to-static)
|
||||
// Crea los sprites de texto a partir de la lista
|
||||
for (size_t i = 0; i < sprite_list_.size(); ++i) {
|
||||
auto text = Resource::Cache::get()->getText("smb2");
|
||||
@@ -404,7 +404,7 @@ void Ending2::createSpriteTexts() {
|
||||
std::string txt = sprite_list_[i];
|
||||
std::ranges::replace(txt, '_', ' '); // Reemplaza '_' por ' '
|
||||
if (txt == "player") {
|
||||
txt = Locale::get()->get("ending2.jaildoctor"); // Reemplaza "player" por nombre localizado
|
||||
txt = Locale::get()->get("ending2.jaildoctor"); // NOLINT(readability-static-accessed-through-instance) Reemplaza "player" por nombre localizado
|
||||
}
|
||||
|
||||
// Calcula las dimensiones del texto
|
||||
@@ -426,7 +426,7 @@ void Ending2::createSpriteTexts() {
|
||||
text->write(0, 0, txt);
|
||||
|
||||
// Crea el sprite
|
||||
SDL_FRect pos = {X, Y, W, H};
|
||||
SDL_FRect pos = {.x = X, .y = Y, .w = W, .h = H};
|
||||
sprite_texts_.emplace_back(std::make_shared<SurfaceDissolveSprite>(surface, pos));
|
||||
sprite_texts_.back()->setColorReplace(1, static_cast<Uint8>(PaletteColor::WHITE));
|
||||
sprite_texts_.back()->setProgress(1.0F); // comença invisible
|
||||
@@ -436,7 +436,7 @@ void Ending2::createSpriteTexts() {
|
||||
}
|
||||
|
||||
// Crea los sprites con las texturas con los textos del final
|
||||
void Ending2::createTexts() {
|
||||
void Ending2::createTexts() { // NOLINT(readability-convert-member-functions-to-static)
|
||||
// Crea los primeros textos
|
||||
std::vector<std::string> list;
|
||||
list.emplace_back(Locale::get()->get("ending2.starring"));
|
||||
@@ -459,7 +459,7 @@ void Ending2::createTexts() {
|
||||
text->write(0, 0, list[i]);
|
||||
|
||||
// Crea el sprite
|
||||
SDL_FRect pos = {X + DX, Y, W, H};
|
||||
SDL_FRect pos = {.x = X + DX, .y = Y, .w = W, .h = H};
|
||||
texts_.emplace_back(std::make_shared<SurfaceDissolveSprite>(surface, pos));
|
||||
texts_.back()->setProgress(1.0F); // comença invisible
|
||||
texts_.back()->setVelY(SPRITE_DESP_SPEED);
|
||||
@@ -489,7 +489,7 @@ void Ending2::createTexts() {
|
||||
text->write(0, 0, list[i]);
|
||||
|
||||
// Crea el sprite
|
||||
SDL_FRect pos = {X + DX, Y, W, H};
|
||||
SDL_FRect pos = {.x = X + DX, .y = Y, .w = W, .h = H};
|
||||
texts_.emplace_back(std::make_shared<SurfaceDissolveSprite>(surface, pos));
|
||||
texts_.back()->setProgress(1.0F); // comença invisible
|
||||
texts_.back()->setVelY(SPRITE_DESP_SPEED);
|
||||
|
||||
@@ -70,7 +70,7 @@ class Ending2 {
|
||||
void renderSprites(); // Dibuja los sprites
|
||||
void renderSpriteTexts(); // Dibuja los sprites con el texto
|
||||
void renderTexts(); // Dibuja los sprites con el texto del final
|
||||
void placeSprites(); // Coloca los sprites en su sitio
|
||||
void placeSprites() const; // Coloca los sprites en su sitio
|
||||
void createSpriteTexts(); // Crea los sprites con las texturas con los textos
|
||||
void createTexts(); // Crea los sprites con las texturas con los textos del final
|
||||
void updateFinalFade(); // Actualiza el fade final
|
||||
|
||||
@@ -94,9 +94,9 @@ void Game::handleInput() {
|
||||
}
|
||||
|
||||
// Input de pausa solo en estado PLAYING
|
||||
if (Input::get()->checkAction(InputAction::PAUSE, Input::DO_NOT_ALLOW_REPEAT)) {
|
||||
if (Input::get()->checkAction(InputAction::PAUSE, Input::DO_NOT_ALLOW_REPEAT)) { // NOLINT(readability-static-accessed-through-instance)
|
||||
togglePause();
|
||||
Notifier::get()->show({paused_ ? Locale::get()->get("game.paused") : Locale::get()->get("game.running")});
|
||||
Notifier::get()->show({paused_ ? Locale::get()->get("game.paused") : Locale::get()->get("game.running")}); // NOLINT(readability-static-accessed-through-instance)
|
||||
}
|
||||
|
||||
GlobalInputs::handle();
|
||||
@@ -371,7 +371,7 @@ void Game::renderPostFadeEnding() {
|
||||
static void toggleCheat(Options::Cheat::State& cheat, const std::string& label) {
|
||||
cheat = (cheat == Options::Cheat::State::ENABLED) ? Options::Cheat::State::DISABLED : Options::Cheat::State::ENABLED;
|
||||
const bool ENABLED = (cheat == Options::Cheat::State::ENABLED);
|
||||
Notifier::get()->show({label + (ENABLED ? Locale::get()->get("game.enabled") : Locale::get()->get("game.disabled"))}, Notifier::Style::DEFAULT, -1, true);
|
||||
Notifier::get()->show({label + (ENABLED ? Locale::get()->get("game.enabled") : Locale::get()->get("game.disabled"))}, Notifier::Style::DEFAULT, -1, true); // NOLINT(readability-static-accessed-through-instance)
|
||||
}
|
||||
|
||||
// Pasa la información de debug
|
||||
@@ -390,7 +390,7 @@ void Game::renderDebugInfo() {
|
||||
auto surface = Screen::get()->getRendererSurface();
|
||||
|
||||
// Borra el marcador
|
||||
SDL_FRect rect = {0, 18 * Tile::SIZE, PlayArea::WIDTH, GameCanvas::HEIGHT - PlayArea::HEIGHT};
|
||||
SDL_FRect rect = {.x = 0, .y = 18 * Tile::SIZE, .w = PlayArea::WIDTH, .h = GameCanvas::HEIGHT - PlayArea::HEIGHT};
|
||||
surface->fillRect(&rect, static_cast<Uint8>(PaletteColor::BLACK));
|
||||
|
||||
// Pinta la rejilla
|
||||
@@ -406,12 +406,12 @@ void Game::renderDebugInfo() {
|
||||
}*/
|
||||
|
||||
// Pinta el texto
|
||||
Debug::get()->setPos({1, 18 * 8});
|
||||
Debug::get()->setPos({.x = 1, .y = 18 * 8});
|
||||
Debug::get()->render();
|
||||
}
|
||||
|
||||
// Comprueba los eventos
|
||||
void Game::handleDebugEvents(const SDL_Event& event) {
|
||||
void Game::handleDebugEvents(const SDL_Event& event) { // NOLINT(readability-convert-member-functions-to-static)
|
||||
if (event.type == SDL_EVENT_KEY_DOWN && static_cast<int>(event.key.repeat) == 0) {
|
||||
switch (event.key.key) {
|
||||
case SDLK_R:
|
||||
@@ -435,26 +435,26 @@ void Game::handleDebugEvents(const SDL_Event& event) {
|
||||
break;
|
||||
|
||||
case SDLK_1:
|
||||
toggleCheat(Options::cheats.infinite_lives, Locale::get()->get("game.cheat_infinite_lives"));
|
||||
toggleCheat(Options::cheats.infinite_lives, Locale::get()->get("game.cheat_infinite_lives")); // NOLINT(readability-static-accessed-through-instance)
|
||||
player_->setColor();
|
||||
break;
|
||||
|
||||
case SDLK_2:
|
||||
toggleCheat(Options::cheats.invincible, Locale::get()->get("game.cheat_invincible"));
|
||||
toggleCheat(Options::cheats.invincible, Locale::get()->get("game.cheat_invincible")); // NOLINT(readability-static-accessed-through-instance)
|
||||
player_->setColor();
|
||||
break;
|
||||
|
||||
case SDLK_3:
|
||||
toggleCheat(Options::cheats.jail_is_open, Locale::get()->get("game.cheat_jail_open"));
|
||||
toggleCheat(Options::cheats.jail_is_open, Locale::get()->get("game.cheat_jail_open")); // NOLINT(readability-static-accessed-through-instance)
|
||||
break;
|
||||
|
||||
case SDLK_7:
|
||||
Notifier::get()->show({Locale::get()->get("achievements.header"), Locale::get()->get("achievements.c11")}, Notifier::Style::CHEEVO, -1, false, "F7");
|
||||
Notifier::get()->show({Locale::get()->get("achievements.header"), Locale::get()->get("achievements.c11")}, Notifier::Style::CHEEVO, -1, false, "F7"); // NOLINT(readability-static-accessed-through-instance)
|
||||
break;
|
||||
|
||||
case SDLK_0:
|
||||
Debug::get()->toggleEnabled();
|
||||
Notifier::get()->show({Debug::get()->isEnabled() ? Locale::get()->get("game.debug_enabled") : Locale::get()->get("game.debug_disabled")});
|
||||
Notifier::get()->show({Debug::get()->isEnabled() ? Locale::get()->get("game.debug_enabled") : Locale::get()->get("game.debug_disabled")}); // NOLINT(readability-static-accessed-through-instance)
|
||||
room_->redrawMap();
|
||||
Options::cheats.invincible = static_cast<Options::Cheat::State>(Debug::get()->isEnabled());
|
||||
player_->setColor();
|
||||
@@ -556,7 +556,7 @@ auto Game::changeRoom(const std::string& room_path) -> bool {
|
||||
}
|
||||
|
||||
// Verifica que exista el fichero que se va a cargar
|
||||
if (!Resource::List::get()->get(room_path).empty()) {
|
||||
if (!Resource::List::get()->get(room_path).empty()) { // NOLINT(readability-static-accessed-through-instance)
|
||||
// Crea un objeto habitación nuevo a partir del fichero
|
||||
room_ = std::make_shared<Room>(room_path, scoreboard_data_);
|
||||
|
||||
@@ -655,7 +655,7 @@ void Game::killPlayer() {
|
||||
}
|
||||
|
||||
// Pone el color del marcador en función del color del borde de la habitación
|
||||
void Game::setScoreBoardColor() {
|
||||
void Game::setScoreBoardColor() { // NOLINT(readability-convert-member-functions-to-static)
|
||||
// Obtiene el color del borde
|
||||
const Uint8 BORDER_COLOR = room_->getBorderColor();
|
||||
|
||||
@@ -734,7 +734,7 @@ void Game::checkRestoringJail(float delta_time) {
|
||||
}
|
||||
|
||||
// Inicializa el diccionario de las estadísticas
|
||||
void Game::initStats() {
|
||||
void Game::initStats() { // NOLINT(readability-convert-member-functions-to-static)
|
||||
auto list = Resource::Cache::get()->getRooms();
|
||||
|
||||
for (const auto& room : list) {
|
||||
@@ -745,7 +745,7 @@ void Game::initStats() {
|
||||
}
|
||||
|
||||
// Crea la textura con el nombre de la habitación
|
||||
void Game::fillRoomNameTexture() {
|
||||
void Game::fillRoomNameTexture() { // NOLINT(readability-convert-member-functions-to-static)
|
||||
// Pone la textura como destino de renderizado
|
||||
auto previuos_renderer = Screen::get()->getRendererSurface();
|
||||
Screen::get()->setRendererSurface(room_name_surface_);
|
||||
@@ -762,7 +762,7 @@ void Game::fillRoomNameTexture() {
|
||||
}
|
||||
|
||||
// Comprueba algunos logros
|
||||
void Game::checkSomeCheevos() {
|
||||
void Game::checkSomeCheevos() { // NOLINT(readability-convert-member-functions-to-static)
|
||||
auto* cheevos = Cheevos::get();
|
||||
|
||||
// Logros sobre la cantidad de items
|
||||
@@ -796,7 +796,7 @@ void Game::checkSomeCheevos() {
|
||||
}
|
||||
|
||||
// Comprueba los logros de completar el juego
|
||||
void Game::checkEndGameCheevos() {
|
||||
void Game::checkEndGameCheevos() { // NOLINT(readability-convert-member-functions-to-static)
|
||||
auto* cheevos = Cheevos::get();
|
||||
|
||||
// "Complete the game"
|
||||
@@ -820,7 +820,7 @@ void Game::checkEndGameCheevos() {
|
||||
}
|
||||
|
||||
// Inicializa al jugador
|
||||
void Game::initPlayer(const Player::SpawnData& spawn_point, std::shared_ptr<Room> room) {
|
||||
void Game::initPlayer(const Player::SpawnData& spawn_point, std::shared_ptr<Room> room) { // NOLINT(readability-convert-member-functions-to-static)
|
||||
std::string player_animations = Options::cheats.alternate_skin == Options::Cheat::State::ENABLED ? "player2.yaml" : "player.yaml";
|
||||
const Player::Data PLAYER{.spawn_data = spawn_point, .animations_path = player_animations, .room = std::move(room)};
|
||||
player_ = std::make_shared<Player>(PLAYER);
|
||||
|
||||
@@ -70,7 +70,7 @@ void GameOver::render() {
|
||||
|
||||
// Escribe el texto de GAME OVER
|
||||
auto* loc = Locale::get();
|
||||
text->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, GameCanvas::CENTER_X, TEXT_Y, loc->get("game_over.title"), 1, color_);
|
||||
text->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, GameCanvas::CENTER_X, TEXT_Y, loc->get("game_over.title"), 1, color_); // NOLINT(readability-static-accessed-through-instance)
|
||||
|
||||
// Dibuja los sprites (ya posicionados en el constructor, solo ajustamos Y)
|
||||
player_sprite_->setPosY(TEXT_Y + SPRITE_Y_OFFSET);
|
||||
@@ -80,11 +80,11 @@ void GameOver::render() {
|
||||
// Escribe el texto con las habitaciones y los items
|
||||
const std::string ITEMS_TEXT = std::to_string(Options::stats.items / 100) + std::to_string((Options::stats.items % 100) / 10) + std::to_string(Options::stats.items % 10);
|
||||
const std::string ROOMS_TEXT = std::to_string(Options::stats.rooms / 100) + std::to_string((Options::stats.rooms % 100) / 10) + std::to_string(Options::stats.rooms % 10);
|
||||
text->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, GameCanvas::CENTER_X, TEXT_Y + ITEMS_Y_OFFSET, loc->get("game_over.items") + ITEMS_TEXT, 1, color_);
|
||||
text->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, GameCanvas::CENTER_X, TEXT_Y + ROOMS_Y_OFFSET, loc->get("game_over.rooms") + ROOMS_TEXT, 1, color_);
|
||||
text->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, GameCanvas::CENTER_X, TEXT_Y + ITEMS_Y_OFFSET, loc->get("game_over.items") + ITEMS_TEXT, 1, color_); // NOLINT(readability-static-accessed-through-instance)
|
||||
text->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, GameCanvas::CENTER_X, TEXT_Y + ROOMS_Y_OFFSET, loc->get("game_over.rooms") + ROOMS_TEXT, 1, color_); // NOLINT(readability-static-accessed-through-instance)
|
||||
|
||||
// Escribe el texto con "Tu peor pesadilla"
|
||||
text->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, GameCanvas::CENTER_X, TEXT_Y + NIGHTMARE_TITLE_Y_OFFSET, loc->get("game_over.worst_nightmare"), 1, color_);
|
||||
text->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, GameCanvas::CENTER_X, TEXT_Y + NIGHTMARE_TITLE_Y_OFFSET, loc->get("game_over.worst_nightmare"), 1, color_); // NOLINT(readability-static-accessed-through-instance)
|
||||
text->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, GameCanvas::CENTER_X, TEXT_Y + NIGHTMARE_TEXT_Y_OFFSET, Options::stats.worst_nightmare, 1, color_);
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
|
||||
@@ -63,7 +63,7 @@ void LoadingScreen::handleInput() {
|
||||
}
|
||||
|
||||
// Inicializa el array de índices de líneas (imita el direccionamiento de memoria del Spectrum)
|
||||
void LoadingScreen::initLineIndexArray() {
|
||||
void LoadingScreen::initLineIndexArray() { // NOLINT(readability-convert-member-functions-to-static)
|
||||
for (int i = 0; i < MONO_TOTAL_LINES; ++i) {
|
||||
if (i < 64) { // Primer bloque de 2K
|
||||
line_index_[i] = ((i % 8) * 8) + (i / 8);
|
||||
@@ -449,7 +449,7 @@ void LoadingScreen::renderBorder() {
|
||||
}
|
||||
|
||||
// Escribe el nombre del programa
|
||||
void LoadingScreen::printProgramName() {
|
||||
void LoadingScreen::printProgramName() { // NOLINT(readability-convert-member-functions-to-static)
|
||||
auto previous_renderer = Screen::get()->getRendererSurface();
|
||||
Screen::get()->setRendererSurface(screen_surface_);
|
||||
program_sprite_->render();
|
||||
@@ -463,7 +463,7 @@ void LoadingScreen::updateCarrier(float delta_time) {
|
||||
|
||||
// Oscilación compuesta: mezcla de dos frecuencias para evitar patrón predecible
|
||||
const float MODULATION = std::sin(carrier_.total_time * 1.2F) * std::sin((carrier_.total_time * 0.35F) + 1.0F);
|
||||
const float SPEED = CARRIER_BASE_SPEED * (0.5F + 0.5F * MODULATION); // rango [-200, 0]
|
||||
const float SPEED = CARRIER_BASE_SPEED * (0.5F + (0.5F * MODULATION)); // rango [-200, 0]
|
||||
|
||||
carrier_.offset += SPEED * delta_time;
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ class LoadingScreen {
|
||||
|
||||
// Arrays y estructuras auxiliares
|
||||
std::array<int, MONO_TOTAL_LINES> line_index_; // El orden en el que se procesan las 192 líneas de la pantalla de carga
|
||||
SDL_FRect load_rect_{0.0F, 0.0F, 0.0F, 1.0F}; // Rectángulo para dibujar la pantalla de carga
|
||||
SDL_FRect load_rect_{.x = 0.0F, .y = 0.0F, .w = 0.0F, .h = 1.0F}; // Rectángulo para dibujar la pantalla de carga
|
||||
Carrier carrier_; // Estructura para los efectos de la carga de cabeceras
|
||||
Noise noise_; // Variaciones de ruido durante los silencios
|
||||
|
||||
|
||||
@@ -40,8 +40,8 @@ Logo::Logo()
|
||||
// Seleccionar función de easing aleatoria para la animación del logo
|
||||
// Usamos lambdas para funciones con parámetros opcionales
|
||||
static const std::array<EasingFunction, 4> EASING_OPTIONS = {
|
||||
[](float t) { return Easing::backOut(t); }, // Overshoot retro
|
||||
[](float t) { return Easing::elasticOut(t); }, // Rebote múltiple con oscilación
|
||||
[](float t) -> float { return Easing::backOut(t); }, // Overshoot retro
|
||||
[](float t) -> float { return Easing::elasticOut(t); }, // Rebote múltiple con oscilación
|
||||
Easing::bounceOut, // Rebote físico decreciente
|
||||
Easing::cubicOut // Suavizado sin overshoot (para variedad)
|
||||
};
|
||||
@@ -94,7 +94,7 @@ void Logo::updateJAILGAMES(float delta_time) {
|
||||
}
|
||||
|
||||
// Calcula el índice de color según el progreso (0.0-1.0)
|
||||
auto Logo::getColorIndex(float progress) const -> int {
|
||||
auto Logo::getColorIndex(float progress) const -> int { // NOLINT(readability-convert-member-functions-to-static)
|
||||
// Asegurar que progress esté en el rango [0.0, 1.0]
|
||||
progress = std::clamp(progress, 0.0F, 1.0F);
|
||||
|
||||
@@ -207,7 +207,7 @@ void Logo::update() {
|
||||
}
|
||||
|
||||
// Dibuja en pantalla
|
||||
void Logo::render() {
|
||||
void Logo::render() { // NOLINT(readability-convert-member-functions-to-static)
|
||||
// Prepara para empezar a dibujar en la textura de juego
|
||||
Screen::get()->start();
|
||||
Screen::get()->clearSurface(static_cast<Uint8>(PaletteColor::BLACK));
|
||||
@@ -248,7 +248,7 @@ void Logo::endSection() {
|
||||
}
|
||||
|
||||
// Inicializa el vector de colores
|
||||
void Logo::initColors() {
|
||||
void Logo::initColors() { // NOLINT(readability-convert-member-functions-to-static)
|
||||
// Inicializa el vector de colores
|
||||
const std::vector<Uint8> COLORS = {
|
||||
static_cast<Uint8>(PaletteColor::BLACK),
|
||||
@@ -265,7 +265,7 @@ void Logo::initColors() {
|
||||
}
|
||||
|
||||
// Crea los sprites de cada linea
|
||||
void Logo::initSprites() {
|
||||
void Logo::initSprites() { // NOLINT(readability-convert-member-functions-to-static)
|
||||
const float WIDTH = jailgames_surface_->getWidth();
|
||||
jailgames_initial_x_.reserve(jailgames_surface_->getHeight());
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ Title::Title()
|
||||
}
|
||||
|
||||
// Destructor
|
||||
Title::~Title() {
|
||||
Title::~Title() { // NOLINT(modernize-use-equals-default)
|
||||
loading_screen_surface_->resetSubPalette();
|
||||
title_surface_->resetSubPalette();
|
||||
}
|
||||
@@ -66,7 +66,7 @@ void Title::initMarquee() {
|
||||
uint32_t cp = Text::nextCodepoint(long_text_, pos);
|
||||
Glyph l;
|
||||
l.codepoint = cp;
|
||||
l.clip = marquee_text_->getGlyphClip(cp); // Pre-calcular clip rect (evita búsqueda por frame)
|
||||
l.clip = marquee_text_->getGlyphClip(cp); // Pre-calcular clip rect (evita búsqueda por frame)
|
||||
l.x = MARQUEE_START_X;
|
||||
l.width = static_cast<float>(marquee_text_->glyphWidth(cp, 0)); // Pre-calcular ancho visual del glifo
|
||||
l.enabled = false;
|
||||
@@ -223,7 +223,7 @@ void Title::updateMarquee(float delta_time) {
|
||||
}
|
||||
|
||||
// Dibuja la marquesina
|
||||
void Title::renderMarquee() {
|
||||
void Title::renderMarquee() const {
|
||||
auto* sprite = marquee_text_->getSprite();
|
||||
sprite->setY(MARQUEE_Y);
|
||||
// Solo renderizar letras activas (optimización: usa cache y rangos)
|
||||
@@ -442,7 +442,7 @@ void Title::run() {
|
||||
}
|
||||
|
||||
// Crea y rellena la textura para mostrar los logros
|
||||
void Title::createCheevosTexture() {
|
||||
void Title::createCheevosTexture() { // NOLINT(readability-convert-member-functions-to-static)
|
||||
// Define la zona central del menu (entre el logo y la marquesina)
|
||||
constexpr int MENU_ZONE_Y = 73; // Top of menu zone
|
||||
constexpr int MENU_ZONE_HEIGHT = 102; // Height of menu zone
|
||||
@@ -466,7 +466,7 @@ void Title::createCheevosTexture() {
|
||||
cheevos_surface_->clear(CHEEVOS_BG_COLOR);
|
||||
|
||||
// Escribe la lista de logros en la textura
|
||||
const std::string CHEEVOS_OWNER = Locale::get()->get("title.projects");
|
||||
const std::string CHEEVOS_OWNER = Locale::get()->get("title.projects"); // NOLINT(readability-static-accessed-through-instance)
|
||||
const std::string CHEEVOS_LIST_CAPTION = CHEEVOS_OWNER + " (" + std::to_string(Cheevos::get()->getTotalUnlockedAchievements()) + " / " + std::to_string(Cheevos::get()->size()) + ")";
|
||||
int pos = 2;
|
||||
TEXT->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, cheevos_surface_->getWidth() / 2, pos, CHEEVOS_LIST_CAPTION, 1, stringToColor("bright_green"));
|
||||
@@ -632,7 +632,7 @@ auto Title::isKeyValid(SDL_Scancode scancode) -> bool {
|
||||
}
|
||||
|
||||
// Verifica si una tecla ya fue usada en pasos anteriores
|
||||
auto Title::isKeyDuplicate(SDL_Scancode scancode, int current_step) -> bool {
|
||||
auto Title::isKeyDuplicate(SDL_Scancode scancode, int current_step) -> bool { // NOLINT(readability-convert-member-functions-to-static)
|
||||
for (int i = 0; i < current_step; i++) {
|
||||
if (temp_keys_[i] == scancode) {
|
||||
return true;
|
||||
@@ -642,7 +642,7 @@ auto Title::isKeyDuplicate(SDL_Scancode scancode, int current_step) -> bool {
|
||||
}
|
||||
|
||||
// Retorna el nombre de la accion para el paso actual
|
||||
auto Title::getActionName(int step) -> std::string {
|
||||
auto Title::getActionName(int step) -> std::string { // NOLINT(readability-convert-member-functions-to-static)
|
||||
switch (step) {
|
||||
case 0:
|
||||
return "LEFT";
|
||||
@@ -656,7 +656,7 @@ auto Title::getActionName(int step) -> std::string {
|
||||
}
|
||||
|
||||
// Aplica y guarda las teclas redefinidas
|
||||
void Title::applyKeyboardRemap() {
|
||||
void Title::applyKeyboardRemap() { // NOLINT(readability-convert-member-functions-to-static)
|
||||
// Guardar las nuevas teclas en Options::controls
|
||||
Options::keyboard_controls.key_left = temp_keys_[0];
|
||||
Options::keyboard_controls.key_right = temp_keys_[1];
|
||||
@@ -670,7 +670,7 @@ void Title::applyKeyboardRemap() {
|
||||
}
|
||||
|
||||
// Dibuja la pantalla de redefinir teclado
|
||||
void Title::renderKeyboardRemap() {
|
||||
void Title::renderKeyboardRemap() const {
|
||||
// Zona central del menu (debe coincidir con la textura de cheevos)
|
||||
constexpr int MENU_ZONE_Y = 73;
|
||||
constexpr int MENU_ZONE_HEIGHT = 102;
|
||||
@@ -697,17 +697,17 @@ void Title::renderKeyboardRemap() {
|
||||
const int KEYS_START_Y = START_Y + (2 * LINE_SPACING);
|
||||
if (remap_step_ > 0) {
|
||||
const std::string LEFT_KEY = SDL_GetScancodeName(temp_keys_[0]);
|
||||
const std::string LEFT_MSG = loc->get("title.keys.label0") + LEFT_KEY;
|
||||
const std::string LEFT_MSG = loc->get("title.keys.label0") + LEFT_KEY; // NOLINT(readability-static-accessed-through-instance)
|
||||
menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, KEYS_START_Y, LEFT_MSG, 1, COLOR);
|
||||
}
|
||||
if (remap_step_ > 1) {
|
||||
const std::string RIGHT_KEY = SDL_GetScancodeName(temp_keys_[1]);
|
||||
const std::string RIGHT_MSG = loc->get("title.keys.label1") + RIGHT_KEY;
|
||||
const std::string RIGHT_MSG = loc->get("title.keys.label1") + RIGHT_KEY; // NOLINT(readability-static-accessed-through-instance)
|
||||
menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, KEYS_START_Y + LINE_SPACING, RIGHT_MSG, 1, COLOR);
|
||||
}
|
||||
if (remap_step_ >= 3) {
|
||||
const std::string JUMP_KEY = SDL_GetScancodeName(temp_keys_[2]);
|
||||
const std::string JUMP_MSG = loc->get("title.keys.label2") + JUMP_KEY;
|
||||
const std::string JUMP_MSG = loc->get("title.keys.label2") + JUMP_KEY; // NOLINT(readability-static-accessed-through-instance)
|
||||
menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, KEYS_START_Y + (2 * LINE_SPACING), JUMP_MSG, 1, COLOR);
|
||||
}
|
||||
|
||||
@@ -718,7 +718,7 @@ void Title::renderKeyboardRemap() {
|
||||
}
|
||||
|
||||
// Dibuja la pantalla de redefinir joystick
|
||||
void Title::renderJoystickRemap() {
|
||||
void Title::renderJoystickRemap() const {
|
||||
// Zona central del menu (debe coincidir con la textura de cheevos)
|
||||
constexpr int MENU_ZONE_Y = 73;
|
||||
constexpr int MENU_ZONE_HEIGHT = 102;
|
||||
@@ -745,17 +745,17 @@ void Title::renderJoystickRemap() {
|
||||
const int BUTTONS_START_Y = START_Y + (2 * LINE_SPACING);
|
||||
if (remap_step_ > 0) {
|
||||
const std::string LEFT_BTN = getButtonName(temp_buttons_[0]);
|
||||
const std::string LEFT_MSG = loc->get("title.keys.label0") + LEFT_BTN;
|
||||
const std::string LEFT_MSG = loc->get("title.keys.label0") + LEFT_BTN; // NOLINT(readability-static-accessed-through-instance)
|
||||
menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, BUTTONS_START_Y, LEFT_MSG, 1, COLOR);
|
||||
}
|
||||
if (remap_step_ > 1) {
|
||||
const std::string RIGHT_BTN = getButtonName(temp_buttons_[1]);
|
||||
const std::string RIGHT_MSG = loc->get("title.keys.label1") + RIGHT_BTN;
|
||||
const std::string RIGHT_MSG = loc->get("title.keys.label1") + RIGHT_BTN; // NOLINT(readability-static-accessed-through-instance)
|
||||
menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, BUTTONS_START_Y + LINE_SPACING, RIGHT_MSG, 1, COLOR);
|
||||
}
|
||||
if (remap_step_ >= 3) {
|
||||
const std::string JUMP_BTN = getButtonName(temp_buttons_[2]);
|
||||
const std::string JUMP_MSG = loc->get("title.keys.label2") + JUMP_BTN;
|
||||
const std::string JUMP_MSG = loc->get("title.keys.label2") + JUMP_BTN; // NOLINT(readability-static-accessed-through-instance)
|
||||
menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, BUTTONS_START_Y + (2 * LINE_SPACING), JUMP_MSG, 1, COLOR);
|
||||
}
|
||||
|
||||
@@ -827,7 +827,7 @@ void Title::handleJoystickRemap(const SDL_Event& event) {
|
||||
}
|
||||
|
||||
// Valida si un botón está duplicado
|
||||
auto Title::isButtonDuplicate(int button, int current_step) -> bool {
|
||||
auto Title::isButtonDuplicate(int button, int current_step) -> bool { // NOLINT(readability-convert-member-functions-to-static)
|
||||
for (int i = 0; i < current_step; ++i) {
|
||||
if (temp_buttons_[i] == button) {
|
||||
return true;
|
||||
@@ -837,7 +837,7 @@ auto Title::isButtonDuplicate(int button, int current_step) -> bool {
|
||||
}
|
||||
|
||||
// Aplica y guarda los botones del gamepad redefinidos
|
||||
void Title::applyJoystickRemap() {
|
||||
void Title::applyJoystickRemap() { // NOLINT(readability-convert-member-functions-to-static)
|
||||
// Guardar los nuevos botones en Options::gamepad_controls
|
||||
Options::gamepad_controls.button_left = temp_buttons_[0];
|
||||
Options::gamepad_controls.button_right = temp_buttons_[1];
|
||||
@@ -851,7 +851,7 @@ void Title::applyJoystickRemap() {
|
||||
}
|
||||
|
||||
// Retorna el nombre amigable del botón del gamepad
|
||||
auto Title::getButtonName(int button) -> std::string {
|
||||
auto Title::getButtonName(int button) -> std::string { // NOLINT(readability-convert-member-functions-to-static)
|
||||
// Triggers especiales
|
||||
if (button == Input::TRIGGER_L2_AS_BUTTON) {
|
||||
return "L2";
|
||||
|
||||
@@ -74,12 +74,12 @@ class Title {
|
||||
void updatePostFadeMenu(float delta_time); // Actualiza POST_FADE_MENU
|
||||
void initMarquee(); // Inicializa la marquesina
|
||||
void updateMarquee(float delta_time); // Actualiza la marquesina (time-based)
|
||||
void renderMarquee(); // Dibuja la marquesina
|
||||
void renderMarquee() const; // Dibuja la marquesina
|
||||
void renderGameLogo(); // Dibuja el logo con el titulo del juego
|
||||
void renderMainMenu(); // Dibuja el menu principal
|
||||
void renderCheevosMenu(); // Dibuja el menu de logros
|
||||
void renderKeyboardRemap(); // Dibuja la pantalla de redefinir teclado
|
||||
void renderJoystickRemap(); // Dibuja la pantalla de redefinir joystick
|
||||
void renderKeyboardRemap() const; // Dibuja la pantalla de redefinir teclado
|
||||
void renderJoystickRemap() const; // Dibuja la pantalla de redefinir joystick
|
||||
void handleKeyboardRemap(const SDL_Event& event); // Maneja la captura de teclas
|
||||
void handleJoystickRemap(const SDL_Event& event); // Maneja la captura de botones del gamepad
|
||||
static auto isKeyValid(SDL_Scancode scancode) -> bool; // Valida si una tecla es permitida
|
||||
|
||||
@@ -43,7 +43,7 @@ const Notifier::Style Notifier::Style::CHEEVO = {
|
||||
.play_sound = true};
|
||||
|
||||
// [SINGLETON] Crearemos el objeto con esta función estática
|
||||
void Notifier::init(const std::string& icon_file, const std::string& text) {
|
||||
void Notifier::init(const std::string& icon_file, const std::string& text) { // NOLINT(readability-convert-member-functions-to-static)
|
||||
Notifier::notifier = new Notifier(icon_file, text);
|
||||
}
|
||||
|
||||
@@ -128,8 +128,8 @@ void Notifier::update(float delta_time) {
|
||||
}
|
||||
|
||||
// Elimina las notificaciones finalizadas
|
||||
void Notifier::clearFinishedNotifications() {
|
||||
auto result = std::ranges::remove_if(notifications_, [](const Notification& notification) {
|
||||
void Notifier::clearFinishedNotifications() { // NOLINT(readability-convert-member-functions-to-static)
|
||||
auto result = std::ranges::remove_if(notifications_, [](const Notification& notification) -> bool {
|
||||
return notification.state == Status::FINISHED;
|
||||
});
|
||||
notifications_.erase(result.begin(), result.end());
|
||||
@@ -147,7 +147,7 @@ void Notifier::show(std::vector<std::string> texts, const Style& style, int icon
|
||||
}
|
||||
|
||||
// Elimina las cadenas vacías
|
||||
auto result = std::ranges::remove_if(texts, [](const std::string& s) { return s.empty(); });
|
||||
auto result = std::ranges::remove_if(texts, [](const std::string& s) -> bool { return s.empty(); });
|
||||
texts.erase(result.begin(), result.end());
|
||||
|
||||
// Encuentra la cadena más larga
|
||||
@@ -219,15 +219,15 @@ void Notifier::show(std::vector<std::string> texts, const Style& style, int icon
|
||||
|
||||
else if (SHAPE == Shape::SQUARED) {
|
||||
n.surface->clear(style.bg_color);
|
||||
SDL_FRect squared_rect = {0, 0, n.surface->getWidth(), n.surface->getHeight()};
|
||||
SDL_FRect squared_rect = {.x = 0, .y = 0, .w = n.surface->getWidth(), .h = n.surface->getHeight()};
|
||||
n.surface->drawRectBorder(&squared_rect, style.border_color);
|
||||
}
|
||||
|
||||
// Dibuja el icono de la notificación
|
||||
if (has_icons_ && icon >= 0 && texts.size() >= 2) {
|
||||
auto sp = std::make_unique<SurfaceSprite>(icon_surface_, (SDL_FRect){0, 0, ICON_SIZE, ICON_SIZE});
|
||||
sp->setPosition({PADDING_IN_H, PADDING_IN_V, ICON_SIZE, ICON_SIZE});
|
||||
sp->setClip((SDL_FRect){ICON_SIZE * (icon % 10), ICON_SIZE * (icon / 10), ICON_SIZE, ICON_SIZE});
|
||||
auto sp = std::make_unique<SurfaceSprite>(icon_surface_, SDL_FRect{.x = 0, .y = 0, .w = ICON_SIZE, .h = ICON_SIZE});
|
||||
sp->setPosition({.x = PADDING_IN_H, .y = PADDING_IN_V, .w = ICON_SIZE, .h = ICON_SIZE});
|
||||
sp->setClip(SDL_FRect{.x = ICON_SIZE * (icon % 10), .y = ICON_SIZE * (icon / 10), .w = ICON_SIZE, .h = ICON_SIZE});
|
||||
sp->render();
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ class Notifier {
|
||||
std::vector<std::string> texts;
|
||||
Status state{Status::RISING};
|
||||
Shape shape{Shape::SQUARED};
|
||||
SDL_FRect rect{0.0F, 0.0F, 0.0F, 0.0F};
|
||||
SDL_FRect rect{.x = 0.0F, .y = 0.0F, .w = 0.0F, .h = 0.0F};
|
||||
int y{0};
|
||||
int travel_dist{0};
|
||||
std::string code;
|
||||
|
||||
Reference in New Issue
Block a user