forked from jaildesigner-jailgames/jaildoctors_dilemma
linter
This commit is contained in:
@@ -439,7 +439,7 @@ void Ending::fillCoverTexture() {
|
||||
cover_surface_->clear(static_cast<Uint8>(PaletteColor::TRANSPARENT));
|
||||
|
||||
// Los primeros 8 pixels crea una malla
|
||||
const Uint8 COLOR = static_cast<Uint8>(PaletteColor::BLACK);
|
||||
const auto COLOR = static_cast<Uint8>(PaletteColor::BLACK);
|
||||
auto surface = Screen::get()->getRendererSurface();
|
||||
for (int i = 0; i < 256; i += 2) {
|
||||
surface->putPixel(i + 0, Options::game.height + 0, COLOR);
|
||||
|
||||
@@ -106,7 +106,7 @@ void Ending2::render() {
|
||||
renderTexts();
|
||||
|
||||
// Dibuja una trama arriba y abajo
|
||||
Uint8 color = static_cast<Uint8>(PaletteColor::BLACK);
|
||||
auto color = static_cast<Uint8>(PaletteColor::BLACK);
|
||||
auto surface = Screen::get()->getRendererSurface();
|
||||
for (int i = 0; i < 256; i += 2) {
|
||||
surface->putPixel(i + 0, 0, color);
|
||||
@@ -196,75 +196,75 @@ void Ending2::iniSpriteList() {
|
||||
sprite_list_.clear();
|
||||
|
||||
// Añade los valores
|
||||
sprite_list_.push_back("bin");
|
||||
sprite_list_.push_back("floppy");
|
||||
sprite_list_.push_back("bird");
|
||||
sprite_list_.push_back("chip");
|
||||
sprite_list_.push_back("jeannine");
|
||||
sprite_list_.push_back("spark");
|
||||
sprite_list_.push_back("code");
|
||||
sprite_list_.push_back("paco");
|
||||
sprite_list_.push_back("elsa");
|
||||
sprite_list_.push_back("z80");
|
||||
sprite_list_.emplace_back("bin");
|
||||
sprite_list_.emplace_back("floppy");
|
||||
sprite_list_.emplace_back("bird");
|
||||
sprite_list_.emplace_back("chip");
|
||||
sprite_list_.emplace_back("jeannine");
|
||||
sprite_list_.emplace_back("spark");
|
||||
sprite_list_.emplace_back("code");
|
||||
sprite_list_.emplace_back("paco");
|
||||
sprite_list_.emplace_back("elsa");
|
||||
sprite_list_.emplace_back("z80");
|
||||
|
||||
sprite_list_.push_back("bell");
|
||||
sprite_list_.push_back("dong");
|
||||
sprite_list_.emplace_back("bell");
|
||||
sprite_list_.emplace_back("dong");
|
||||
|
||||
sprite_list_.push_back("amstrad_cs");
|
||||
sprite_list_.push_back("breakout");
|
||||
sprite_list_.emplace_back("amstrad_cs");
|
||||
sprite_list_.emplace_back("breakout");
|
||||
|
||||
sprite_list_.push_back("flying_arounder");
|
||||
sprite_list_.push_back("stopped_arounder");
|
||||
sprite_list_.push_back("walking_arounder");
|
||||
sprite_list_.push_back("arounders_door");
|
||||
sprite_list_.push_back("arounders_machine");
|
||||
sprite_list_.emplace_back("flying_arounder");
|
||||
sprite_list_.emplace_back("stopped_arounder");
|
||||
sprite_list_.emplace_back("walking_arounder");
|
||||
sprite_list_.emplace_back("arounders_door");
|
||||
sprite_list_.emplace_back("arounders_machine");
|
||||
|
||||
sprite_list_.push_back("abad");
|
||||
sprite_list_.push_back("abad_bell");
|
||||
sprite_list_.push_back("lord_abad");
|
||||
sprite_list_.emplace_back("abad");
|
||||
sprite_list_.emplace_back("abad_bell");
|
||||
sprite_list_.emplace_back("lord_abad");
|
||||
|
||||
sprite_list_.push_back("bat");
|
||||
sprite_list_.push_back("batman_bell");
|
||||
sprite_list_.push_back("batman_fire");
|
||||
sprite_list_.push_back("batman");
|
||||
sprite_list_.emplace_back("bat");
|
||||
sprite_list_.emplace_back("batman_bell");
|
||||
sprite_list_.emplace_back("batman_fire");
|
||||
sprite_list_.emplace_back("batman");
|
||||
|
||||
sprite_list_.push_back("demon");
|
||||
sprite_list_.push_back("heavy");
|
||||
sprite_list_.push_back("dimallas");
|
||||
sprite_list_.push_back("guitar");
|
||||
sprite_list_.emplace_back("demon");
|
||||
sprite_list_.emplace_back("heavy");
|
||||
sprite_list_.emplace_back("dimallas");
|
||||
sprite_list_.emplace_back("guitar");
|
||||
|
||||
sprite_list_.push_back("jailbattle_alien");
|
||||
sprite_list_.push_back("jailbattle_human");
|
||||
sprite_list_.emplace_back("jailbattle_alien");
|
||||
sprite_list_.emplace_back("jailbattle_human");
|
||||
|
||||
sprite_list_.push_back("jailer_#1");
|
||||
sprite_list_.push_back("jailer_#2");
|
||||
sprite_list_.push_back("jailer_#3");
|
||||
sprite_list_.push_back("bry");
|
||||
sprite_list_.push_back("upv_student");
|
||||
sprite_list_.emplace_back("jailer_#1");
|
||||
sprite_list_.emplace_back("jailer_#2");
|
||||
sprite_list_.emplace_back("jailer_#3");
|
||||
sprite_list_.emplace_back("bry");
|
||||
sprite_list_.emplace_back("upv_student");
|
||||
|
||||
sprite_list_.push_back("lamp");
|
||||
sprite_list_.push_back("robot");
|
||||
sprite_list_.push_back("congo");
|
||||
sprite_list_.push_back("crosshair");
|
||||
sprite_list_.push_back("tree_thing");
|
||||
sprite_list_.emplace_back("lamp");
|
||||
sprite_list_.emplace_back("robot");
|
||||
sprite_list_.emplace_back("congo");
|
||||
sprite_list_.emplace_back("crosshair");
|
||||
sprite_list_.emplace_back("tree_thing");
|
||||
|
||||
sprite_list_.push_back("matatunos");
|
||||
sprite_list_.push_back("tuno");
|
||||
sprite_list_.emplace_back("matatunos");
|
||||
sprite_list_.emplace_back("tuno");
|
||||
|
||||
sprite_list_.push_back("mummy");
|
||||
sprite_list_.push_back("sam");
|
||||
sprite_list_.emplace_back("mummy");
|
||||
sprite_list_.emplace_back("sam");
|
||||
|
||||
sprite_list_.push_back("qvoid");
|
||||
sprite_list_.push_back("sigmasua");
|
||||
sprite_list_.emplace_back("qvoid");
|
||||
sprite_list_.emplace_back("sigmasua");
|
||||
|
||||
sprite_list_.push_back("tv_panel");
|
||||
sprite_list_.push_back("tv");
|
||||
sprite_list_.emplace_back("tv_panel");
|
||||
sprite_list_.emplace_back("tv");
|
||||
|
||||
sprite_list_.push_back("spider");
|
||||
sprite_list_.push_back("shock");
|
||||
sprite_list_.push_back("wave");
|
||||
sprite_list_.emplace_back("spider");
|
||||
sprite_list_.emplace_back("shock");
|
||||
sprite_list_.emplace_back("wave");
|
||||
|
||||
sprite_list_.push_back("player");
|
||||
sprite_list_.emplace_back("player");
|
||||
}
|
||||
|
||||
// Carga todos los sprites desde una lista
|
||||
@@ -283,29 +283,29 @@ void Ending2::loadSprites() {
|
||||
|
||||
// Actualiza los sprites
|
||||
void Ending2::updateSprites() {
|
||||
for (auto sprite : sprites_) {
|
||||
for (const auto& sprite : sprites_) {
|
||||
sprite->update();
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza los sprites de texto
|
||||
void Ending2::updateTextSprites() {
|
||||
for (auto sprite : sprite_texts_) {
|
||||
for (const auto& sprite : sprite_texts_) {
|
||||
sprite->update();
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza los sprites de texto del final
|
||||
void Ending2::updateTexts() {
|
||||
for (auto sprite : texts_) {
|
||||
for (const auto& sprite : texts_) {
|
||||
sprite->update();
|
||||
}
|
||||
}
|
||||
|
||||
// Dibuja los sprites
|
||||
void Ending2::renderSprites() {
|
||||
const Uint8 COLOR_A = static_cast<Uint8>(PaletteColor::RED);
|
||||
for (auto sprite : sprites_) {
|
||||
const auto COLOR_A = static_cast<Uint8>(PaletteColor::RED);
|
||||
for (const auto& sprite : sprites_) {
|
||||
const bool A = sprite->getRect().y + sprite->getRect().h > 0;
|
||||
const bool B = sprite->getRect().y < Options::game.height;
|
||||
if (A && B) {
|
||||
@@ -314,14 +314,14 @@ void Ending2::renderSprites() {
|
||||
}
|
||||
|
||||
// Pinta el ultimo elemento de otro color
|
||||
const Uint8 COLOR_B = static_cast<Uint8>(PaletteColor::WHITE);
|
||||
const auto COLOR_B = static_cast<Uint8>(PaletteColor::WHITE);
|
||||
sprites_.back()->render(1, COLOR_B);
|
||||
}
|
||||
|
||||
// Dibuja los sprites con el texto
|
||||
void Ending2::renderSpriteTexts() {
|
||||
const Uint8 COLOR = static_cast<Uint8>(PaletteColor::WHITE);
|
||||
for (auto sprite : sprite_texts_) {
|
||||
const auto COLOR = static_cast<Uint8>(PaletteColor::WHITE);
|
||||
for (const auto& sprite : sprite_texts_) {
|
||||
const bool A = sprite->getRect().y + sprite->getRect().h > 0;
|
||||
const bool B = sprite->getRect().y < Options::game.height;
|
||||
if (A && B) {
|
||||
@@ -332,7 +332,7 @@ void Ending2::renderSpriteTexts() {
|
||||
|
||||
// Dibuja los sprites con el texto del final
|
||||
void Ending2::renderTexts() {
|
||||
for (auto sprite : texts_) {
|
||||
for (const auto& sprite : texts_) {
|
||||
const bool A = sprite->getRect().y + sprite->getRect().h > 0;
|
||||
const bool B = sprite->getRect().y < Options::game.height;
|
||||
if (A && B) {
|
||||
@@ -370,7 +370,7 @@ void Ending2::createSpriteTexts() {
|
||||
|
||||
// Procesa y ajusta el texto del sprite actual
|
||||
std::string txt = sprite_list_[i];
|
||||
std::replace(txt.begin(), txt.end(), '_', ' '); // Reemplaza '_' por ' '
|
||||
std::ranges::replace(txt, '_', ' '); // Reemplaza '_' por ' '
|
||||
if (txt == "player") {
|
||||
txt = "JAILDOCTOR"; // Reemplaza "player" por "JAILDOCTOR"
|
||||
}
|
||||
@@ -405,7 +405,7 @@ void Ending2::createSpriteTexts() {
|
||||
void Ending2::createTexts() {
|
||||
// Crea los primeros textos
|
||||
std::vector<std::string> list;
|
||||
list.push_back("STARRING");
|
||||
list.emplace_back("STARRING");
|
||||
|
||||
auto text = Resource::get()->getText("smb2");
|
||||
|
||||
@@ -435,8 +435,8 @@ void Ending2::createTexts() {
|
||||
// El primer texto va a continuación del ultimo spriteText
|
||||
const int START = sprite_texts_.back()->getPosY() + (text->getCharacterSize() * 15);
|
||||
list.clear();
|
||||
list.push_back("THANK YOU");
|
||||
list.push_back("FOR PLAYING!");
|
||||
list.emplace_back("THANK YOU");
|
||||
list.emplace_back("FOR PLAYING!");
|
||||
|
||||
// Crea los sprites de texto a partir de la lista
|
||||
for (size_t i = 0; i < list.size(); ++i) {
|
||||
@@ -463,7 +463,7 @@ void Ending2::createTexts() {
|
||||
|
||||
// Actualiza el fade final
|
||||
void Ending2::updateFinalFade() {
|
||||
for (auto sprite : texts_) {
|
||||
for (const auto& sprite : texts_) {
|
||||
sprite->getSurface()->fadeSubPalette(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ class Ending2 {
|
||||
duration(state_duration) {}
|
||||
|
||||
// Método para comprobar si el estado ha terminado y verifica el nombre del estado
|
||||
bool hasEnded(EndingState expected_state) const {
|
||||
[[nodiscard]] auto hasEnded(EndingState expected_state) const -> bool {
|
||||
// Comprobar si el estado actual coincide con el estado esperado
|
||||
if (state != expected_state) {
|
||||
return false; // Si no coincide, considerar que no ha terminado
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include <utility>
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "core/input/global_inputs.hpp" // Para check
|
||||
@@ -263,7 +264,7 @@ void Game::renderRoomName() {
|
||||
}
|
||||
|
||||
// Cambia de habitación
|
||||
bool Game::changeRoom(const std::string& room_path) {
|
||||
auto Game::changeRoom(const std::string& room_path) -> bool {
|
||||
// En las habitaciones los limites tienen la cadena del fichero o un 0 en caso de no limitar con nada
|
||||
if (room_path == "0") {
|
||||
return false;
|
||||
@@ -313,7 +314,7 @@ void Game::checkPlayerIsOnBorder() {
|
||||
}
|
||||
|
||||
// Comprueba las colisiones del jugador con los enemigos
|
||||
bool Game::checkPlayerAndEnemies() {
|
||||
auto Game::checkPlayerAndEnemies() -> bool {
|
||||
const bool DEATH = room_->enemyCollision(player_->getCollider());
|
||||
if (DEATH) {
|
||||
killPlayer();
|
||||
@@ -415,7 +416,7 @@ void Game::setScoreBoardColor() {
|
||||
}
|
||||
|
||||
// Comprueba si ha finalizado el juego
|
||||
bool Game::checkEndGame() {
|
||||
auto Game::checkEndGame() -> bool {
|
||||
const bool IS_ON_THE_ROOM = room_->getName() == "THE JAIL"; // Estar en la habitación que toca
|
||||
const bool HAVE_THE_ITEMS = board_->items >= int(total_items_ * 0.9F) || Options::cheats.jail_is_open == Options::Cheat::State::ENABLED; // Con mas del 90% de los items recogidos
|
||||
const bool IS_ON_THE_DOOR = player_->getRect().x <= 128; // Y en la ubicación que toca (En la puerta)
|
||||
@@ -436,7 +437,7 @@ bool Game::checkEndGame() {
|
||||
}
|
||||
|
||||
// Obtiene la cantidad total de items que hay en el mapeado del juego
|
||||
int Game::getTotalItems() {
|
||||
auto Game::getTotalItems() -> int {
|
||||
int items = 0;
|
||||
auto rooms = Resource::get()->getRooms();
|
||||
|
||||
@@ -572,7 +573,7 @@ void Game::checkEndGameCheevos() {
|
||||
void Game::initPlayer(const PlayerSpawn& spawn_point, std::shared_ptr<Room> room) {
|
||||
std::string player_texture = Options::cheats.alternate_skin == Options::Cheat::State::ENABLED ? "player2.gif" : "player.gif";
|
||||
std::string player_animations = Options::cheats.alternate_skin == Options::Cheat::State::ENABLED ? "player2.ani" : "player.ani";
|
||||
const PlayerData PLAYER(spawn_point, player_texture, player_animations, room);
|
||||
const PlayerData PLAYER(spawn_point, player_texture, player_animations, std::move(room));
|
||||
player_ = std::make_shared<Player>(PLAYER);
|
||||
}
|
||||
|
||||
@@ -582,7 +583,7 @@ void Game::createRoomNameTexture() {
|
||||
room_name_surface_ = std::make_shared<Surface>(Options::game.width, text->getCharacterSize() * 2);
|
||||
|
||||
// Establece el destino de la textura
|
||||
room_name_rect_ = {0.0F, PLAY_AREA_HEIGHT, Options::game.width, text->getCharacterSize() * 2.0F};
|
||||
room_name_rect_ = {.x = 0.0F, .y = PLAY_AREA_HEIGHT, .w = Options::game.width, .h = text->getCharacterSize() * 2.0F};
|
||||
}
|
||||
|
||||
// Hace sonar la música
|
||||
|
||||
@@ -89,7 +89,7 @@ class Game {
|
||||
void renderRoomName();
|
||||
|
||||
// Cambia de habitación
|
||||
bool changeRoom(const std::string& room_path);
|
||||
auto changeRoom(const std::string& room_path) -> bool;
|
||||
|
||||
// Comprueba el teclado
|
||||
void checkInput();
|
||||
@@ -98,7 +98,7 @@ class Game {
|
||||
void checkPlayerIsOnBorder();
|
||||
|
||||
// Comprueba las colisiones del jugador con los enemigos
|
||||
bool checkPlayerAndEnemies();
|
||||
auto checkPlayerAndEnemies() -> bool;
|
||||
|
||||
// Comprueba las colisiones del jugador con los objetos
|
||||
void checkPlayerAndItems();
|
||||
@@ -125,10 +125,10 @@ class Game {
|
||||
void setScoreBoardColor();
|
||||
|
||||
// Comprueba si ha finalizado el juego
|
||||
bool checkEndGame();
|
||||
auto checkEndGame() -> bool;
|
||||
|
||||
// Obtiene la cantidad total de items que hay en el mapeado del juego
|
||||
static int getTotalItems();
|
||||
static auto getTotalItems() -> int;
|
||||
|
||||
// Pone el juego en pausa
|
||||
void togglePause();
|
||||
|
||||
@@ -20,10 +20,7 @@
|
||||
// Constructor
|
||||
GameOver::GameOver()
|
||||
: player_sprite_(std::make_shared<SurfaceAnimatedSprite>(Resource::get()->getSurface("player_game_over.gif"), Resource::get()->getAnimations("player_game_over.ani"))),
|
||||
tv_sprite_(std::make_shared<SurfaceAnimatedSprite>(Resource::get()->getSurface("tv.gif"), Resource::get()->getAnimations("tv.ani"))),
|
||||
pre_counter_(0),
|
||||
counter_(0),
|
||||
ticks_(0) {
|
||||
tv_sprite_(std::make_shared<SurfaceAnimatedSprite>(Resource::get()->getSurface("tv.gif"), Resource::get()->getAnimations("tv.ani"))) {
|
||||
SceneManager::current = SceneManager::Scene::GAME_OVER;
|
||||
SceneManager::options = SceneManager::Options::NONE;
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include "game/scenes/loading_screen.hpp"
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <stdlib.h> // Para rand
|
||||
|
||||
#include <cstdlib> // Para rand
|
||||
|
||||
#include "core/audio/audio.hpp" // Para Audio
|
||||
#include "core/input/global_inputs.hpp" // Para check
|
||||
@@ -9,10 +10,10 @@
|
||||
#include "core/rendering/surface.hpp" // Para Surface
|
||||
#include "core/rendering/surface_sprite.hpp" // Para SSprite
|
||||
#include "core/resources/resource.hpp" // Para Resource
|
||||
#include "core/system/global_events.hpp" // Para check
|
||||
#include "game/options.hpp" // Para Options, options, SectionState, Options...
|
||||
#include "game/scene_manager.hpp" // Para SceneManager
|
||||
#include "utils/defines.hpp" // Para GAME_SPEED
|
||||
#include "core/system/global_events.hpp" // Para check
|
||||
#include "utils/utils.hpp" // Para stringToColor, PaletteColor
|
||||
|
||||
// Constructor
|
||||
@@ -252,7 +253,7 @@ void LoadingScreen::renderYellowBorder() {
|
||||
border->clear(static_cast<Uint8>(PaletteColor::BLUE));
|
||||
|
||||
// Añade lineas amarillas
|
||||
const Uint8 COLOR = static_cast<Uint8>(PaletteColor::YELLOW);
|
||||
const auto COLOR = static_cast<Uint8>(PaletteColor::YELLOW);
|
||||
const int WIDTH = Options::game.width + (Options::video.border.width * 2);
|
||||
const int HEIGHT = Options::game.height + (Options::video.border.height * 2);
|
||||
bool draw_enabled = rand() % 2 == 0;
|
||||
@@ -279,7 +280,7 @@ void LoadingScreen::renderRedBorder() {
|
||||
border->clear(static_cast<Uint8>(PaletteColor::CYAN));
|
||||
|
||||
// Añade lineas rojas
|
||||
const Uint8 COLOR = static_cast<Uint8>(PaletteColor::RED);
|
||||
const auto COLOR = static_cast<Uint8>(PaletteColor::RED);
|
||||
const int WIDTH = Options::game.width + (Options::video.border.width * 2);
|
||||
const int HEIGHT = Options::game.height + (Options::video.border.height * 2);
|
||||
bool draw_enabled = true;
|
||||
|
||||
@@ -83,7 +83,7 @@ void Logo::updateJAILGAMES(float delta_time) {
|
||||
}
|
||||
|
||||
// Calcula el índice de color según el progreso (0.0-1.0)
|
||||
int Logo::getColorIndex(float progress) const {
|
||||
auto Logo::getColorIndex(float progress) const -> int {
|
||||
// Asegurar que progress esté en el rango [0.0, 1.0]
|
||||
progress = std::clamp(progress, 0.0F, 1.0F);
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ class Logo {
|
||||
void updateTextureColors(); // Gestiona el color de las texturas
|
||||
void updateState(float delta_time); // Actualiza el estado actual
|
||||
void transitionToState(LogoState new_state); // Transiciona a un nuevo estado
|
||||
int getColorIndex(float progress) const; // Calcula el índice de color según el progreso (0.0-1.0)
|
||||
[[nodiscard]] auto getColorIndex(float progress) const -> int; // Calcula el índice de color según el progreso (0.0-1.0)
|
||||
static void endSection(); // Termina la sección
|
||||
void initColors(); // Inicializa el vector de colores
|
||||
void initSprites(); // Crea los sprites de cada linea
|
||||
|
||||
@@ -328,7 +328,7 @@ void Title::createCheevosTexture() {
|
||||
Screen::get()->setRendererSurface(cheevos_surface_);
|
||||
|
||||
// Rellena la textura con color sólido
|
||||
const Uint8 CHEEVOS_BG_COLOR = static_cast<Uint8>(PaletteColor::BLACK);
|
||||
const auto CHEEVOS_BG_COLOR = static_cast<Uint8>(PaletteColor::BLACK);
|
||||
cheevos_surface_->clear(CHEEVOS_BG_COLOR);
|
||||
|
||||
// Escribe la lista de logros en la textura
|
||||
@@ -358,7 +358,7 @@ void Title::createCheevosTexture() {
|
||||
|
||||
// Crea el sprite para el listado de logros
|
||||
cheevos_sprite_ = std::make_shared<SurfaceSprite>(cheevos_surface_, (GAMECANVAS_WIDTH - cheevos_surface_->getWidth()) / 2, CHEEVOS_TEXTURE_POS_Y, cheevos_surface_->getWidth(), cheevos_surface_->getHeight());
|
||||
cheevos_surface_view_ = {0, 0, cheevos_surface_->getWidth(), CHEEVOS_TEXTURE_VIEW_HEIGHT};
|
||||
cheevos_surface_view_ = {.x = 0, .y = 0, .w = cheevos_surface_->getWidth(), .h = CHEEVOS_TEXTURE_VIEW_HEIGHT};
|
||||
cheevos_sprite_->setClip(cheevos_surface_view_);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user