From cdb9bde6aa9a8be1a2f48b4399f2aeed7b36fbc4 Mon Sep 17 00:00:00 2001 From: Sergio Date: Mon, 27 Oct 2025 13:01:11 +0100 Subject: [PATCH] linter --- source/core/audio/audio.cpp | 8 +- source/core/input/input.cpp | 3 +- source/core/rendering/gif.hpp | 6 +- .../core/rendering/opengl/opengl_shader.cpp | 2 +- source/core/rendering/screen.cpp | 54 +-- source/core/rendering/screen.hpp | 8 +- source/core/rendering/surface.cpp | 7 +- source/core/resources/resource.cpp | 38 +- source/core/resources/resource.hpp | 14 +- source/core/system/director.cpp | 364 +++++++++--------- source/core/system/director.hpp | 24 +- source/game/entities/item.cpp | 4 +- source/game/entities/player.cpp | 122 +++--- source/game/entities/player.hpp | 20 +- source/game/gameplay/room.cpp | 20 +- source/game/gameplay/stats.cpp | 16 +- source/game/gameplay/stats.hpp | 2 +- source/game/scenes/ending2.cpp | 20 +- source/game/scenes/ending2.hpp | 6 +- source/game/scenes/game.cpp | 8 +- source/game/scenes/game.hpp | 2 +- source/game/ui/notifier.cpp | 18 +- source/utils/utils.cpp | 18 +- 23 files changed, 392 insertions(+), 392 deletions(-) diff --git a/source/core/audio/audio.cpp b/source/core/audio/audio.cpp index ab2d86e..fec25fc 100644 --- a/source/core/audio/audio.cpp +++ b/source/core/audio/audio.cpp @@ -36,16 +36,16 @@ void Audio::update() { // Reproduce la música void Audio::playMusic(const std::string& name, const int loop) { - bool newLoop = (loop != 0); + bool new_loop = (loop != 0); // Si ya está sonando exactamente la misma pista y mismo modo loop, no hacemos nada - if (music_.state == MusicState::PLAYING && music_.name == name && music_.loop == newLoop) { + if (music_.state == MusicState::PLAYING && music_.name == name && music_.loop == new_loop) { return; } // Intentar obtener recurso; si falla, no tocar estado auto* resource = Resource::get()->getMusic(name); - if (!resource) { + if (resource == nullptr) { // manejo de error opcional return; } @@ -60,7 +60,7 @@ void Audio::playMusic(const std::string& name, const int loop) { // Actualizar estado y metadatos después de iniciar con éxito music_.name = name; - music_.loop = newLoop; + music_.loop = new_loop; music_.state = MusicState::PLAYING; } diff --git a/source/core/input/input.cpp b/source/core/input/input.cpp index ea7f012..7bab4c3 100644 --- a/source/core/input/input.cpp +++ b/source/core/input/input.cpp @@ -277,7 +277,8 @@ bool Input::checkAxisInput(InputAction input, int controller_index, bool repeat) // Transición de inactivo a activo binding.axis_active = true; return true; - } else if (!axis_active_now && binding.axis_active) { + } + if (!axis_active_now && binding.axis_active) { // Transición de activo a inactivo binding.axis_active = false; } diff --git a/source/core/rendering/gif.hpp b/source/core/rendering/gif.hpp index 5f0fb2f..839e5d1 100644 --- a/source/core/rendering/gif.hpp +++ b/source/core/rendering/gif.hpp @@ -76,17 +76,17 @@ class Gif { // Carga el stream GIF; devuelve un vector con los datos de imagen sin comprimir y // asigna el ancho y alto mediante referencias. - std::vector loadGif(const uint8_t* buffer, uint16_t& w, uint16_t& h); + static std::vector loadGif(const uint8_t* buffer, uint16_t& w, uint16_t& h); private: // Lee los sub-bloques de datos y los acumula en un std::vector. static std::vector readSubBlocks(const uint8_t*& buffer); // Procesa el Image Descriptor y retorna el vector de datos sin comprimir. - std::vector processImageDescriptor(const uint8_t*& buffer, const std::vector& gct, int resolution_bits); + static std::vector processImageDescriptor(const uint8_t*& buffer, const std::vector& gct, int resolution_bits); // Procesa el stream completo del GIF y devuelve los datos sin comprimir. - std::vector processGifStream(const uint8_t* buffer, uint16_t& w, uint16_t& h); + static std::vector processGifStream(const uint8_t* buffer, uint16_t& w, uint16_t& h); }; } // namespace GIF diff --git a/source/core/rendering/opengl/opengl_shader.cpp b/source/core/rendering/opengl/opengl_shader.cpp index 8f9b352..ccbb7ac 100644 --- a/source/core/rendering/opengl/opengl_shader.cpp +++ b/source/core/rendering/opengl/opengl_shader.cpp @@ -441,7 +441,7 @@ void OpenGLShader::render() { // Restaurar estados OpenGL glUseProgram(old_program); glBindTexture(GL_TEXTURE_2D, old_texture); - if (was_texture_enabled == 0u) { + if (was_texture_enabled == 0U) { glDisable(GL_TEXTURE_2D); } glBindVertexArray(old_vao); diff --git a/source/core/rendering/screen.cpp b/source/core/rendering/screen.cpp index f5eb30e..254f35b 100644 --- a/source/core/rendering/screen.cpp +++ b/source/core/rendering/screen.cpp @@ -52,7 +52,7 @@ Screen::Screen() // Crea la textura donde se dibujan los graficos del juego game_texture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, Options::game.width, Options::game.height); - if (!game_texture_) { + if (game_texture_ == nullptr) { // Registrar el error si está habilitado if (Options::console) { std::cerr << "Error: game_texture_ could not be created!\nSDL Error: " << SDL_GetError() << std::endl; @@ -61,8 +61,8 @@ Screen::Screen() SDL_SetTextureScaleMode(game_texture_, SDL_SCALEMODE_NEAREST); // Crea la textura donde se dibuja el borde que rodea el area de juego - border_texture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, Options::game.width + Options::video.border.width * 2, Options::game.height + Options::video.border.height * 2); - if (!border_texture_) { + border_texture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, Options::game.width + (Options::video.border.width * 2), Options::game.height + (Options::video.border.height * 2)); + if (border_texture_ == nullptr) { // Registrar el error si está habilitado if (Options::console) { std::cerr << "Error: border_texture_ could not be created!\nSDL Error: " << SDL_GetError() << std::endl; @@ -76,7 +76,7 @@ Screen::Screen() game_surface_->clear(static_cast(PaletteColor::BLACK)); // Crea la surface para el borde de colores - border_surface_ = std::make_shared(Options::game.width + Options::video.border.width * 2, Options::game.height + Options::video.border.height * 2); + border_surface_ = std::make_shared(Options::game.width + (Options::video.border.width * 2), Options::game.height + (Options::video.border.height * 2)); border_surface_->setPalette(readPalFile(palettes_.at(current_palette_))); border_surface_->clear(border_color_); @@ -143,7 +143,7 @@ void Screen::toggleVideoMode() { // Reduce el tamaño de la ventana bool Screen::decWindowZoom() { - if (Options::video.fullscreen == 0) { + if (static_cast(Options::video.fullscreen) == 0) { const int PREVIOUS_ZOOM = Options::window.zoom; --Options::window.zoom; Options::window.zoom = std::max(Options::window.zoom, 1); @@ -159,7 +159,7 @@ bool Screen::decWindowZoom() { // Aumenta el tamaño de la ventana bool Screen::incWindowZoom() { - if (Options::video.fullscreen == 0) { + if (static_cast(Options::video.fullscreen) == 0) { const int PREVIOUS_ZOOM = Options::window.zoom; ++Options::window.zoom; Options::window.zoom = std::min(Options::window.zoom, Options::window.max_zoom); @@ -187,7 +187,7 @@ void Screen::toggleBorder() { } // Dibuja las notificaciones -void Screen::renderNotifications() { +void Screen::renderNotifications() const { if (notifications_enabled_) { Notifier::get()->render(); } @@ -212,15 +212,17 @@ void Screen::adjustWindowSize() { window_height_ = Options::game.height + (Options::video.border.enabled ? Options::video.border.height * 2 : 0); // Establece el nuevo tamaño - if (Options::video.fullscreen == 0) { - int old_width, old_height; + if (static_cast(Options::video.fullscreen) == 0) { + int old_width; + int old_height; SDL_GetWindowSize(window_, &old_width, &old_height); - int old_pos_x, old_pos_y; + int old_pos_x; + int old_pos_y; SDL_GetWindowPosition(window_, &old_pos_x, &old_pos_y); - const int NEW_POS_X = old_pos_x + (old_width - (window_width_ * Options::window.zoom)) / 2; - const int NEW_POS_Y = old_pos_y + (old_height - (window_height_ * Options::window.zoom)) / 2; + const int NEW_POS_X = old_pos_x + ((old_width - (window_width_ * Options::window.zoom)) / 2); + const int NEW_POS_Y = old_pos_y + ((old_height - (window_height_ * Options::window.zoom)) / 2); SDL_SetWindowSize(window_, window_width_ * Options::window.zoom, window_height_ * Options::window.zoom); SDL_SetWindowPosition(window_, std::max(NEW_POS_X, WINDOWS_DECORATIONS), std::max(NEW_POS_Y, 0)); @@ -327,7 +329,7 @@ size_t Screen::findPalette(const std::string& name) { // Muestra información por pantalla void Screen::renderInfo() { - if (show_debug_info_ && Resource::get()) { + if (show_debug_info_ && (Resource::get() != nullptr)) { auto text = Resource::get()->getText("smb2"); auto color = static_cast(PaletteColor::YELLOW); @@ -382,11 +384,11 @@ std::vector loadData(const std::string& filepath) { return {}; } - std::streamsize fileSize = file.tellg(); + std::streamsize file_size = file.tellg(); file.seekg(0, std::ios::beg); - std::vector data(fileSize); - if (!file.read(reinterpret_cast(data.data()), fileSize)) { + std::vector data(file_size); + if (!file.read(reinterpret_cast(data.data()), file_size)) { return {}; } @@ -398,13 +400,13 @@ void Screen::loadShaders() { if (vertex_shader_source_.empty()) { // Detectar si necesitamos OpenGL ES (Raspberry Pi) // Intentar cargar versión ES primero si existe - std::string VERTEX_FILE = "crtpi_vertex_es.glsl"; - auto data = loadData(Asset::get()->get(VERTEX_FILE)); + std::string vertex_file = "crtpi_vertex_es.glsl"; + auto data = loadData(Asset::get()->get(vertex_file)); if (data.empty()) { // Si no existe versión ES, usar versión Desktop - VERTEX_FILE = "crtpi_vertex.glsl"; - data = loadData(Asset::get()->get(VERTEX_FILE)); + vertex_file = "crtpi_vertex.glsl"; + data = loadData(Asset::get()->get(vertex_file)); SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Usando shaders OpenGL Desktop 3.3"); } else { @@ -418,13 +420,13 @@ void Screen::loadShaders() { } if (fragment_shader_source_.empty()) { // Intentar cargar versión ES primero si existe - std::string FRAGMENT_FILE = "crtpi_fragment_es.glsl"; - auto data = loadData(Asset::get()->get(FRAGMENT_FILE)); + std::string fragment_file = "crtpi_fragment_es.glsl"; + auto data = loadData(Asset::get()->get(fragment_file)); if (data.empty()) { // Si no existe versión ES, usar versión Desktop - FRAGMENT_FILE = "crtpi_fragment.glsl"; - data = loadData(Asset::get()->get(FRAGMENT_FILE)); + fragment_file = "crtpi_fragment.glsl"; + data = loadData(Asset::get()->get(fragment_file)); } if (!data.empty()) { @@ -536,8 +538,8 @@ auto Screen::initSDLVideo() -> bool { #endif // Crear ventana - const auto WINDOW_WIDTH = Options::video.border.enabled ? Options::game.width + Options::video.border.width * 2 : Options::game.width; - const auto WINDOW_HEIGHT = Options::video.border.enabled ? Options::game.height + Options::video.border.height * 2 : Options::game.height; + const auto WINDOW_WIDTH = Options::video.border.enabled ? Options::game.width + (Options::video.border.width * 2) : Options::game.width; + const auto WINDOW_HEIGHT = Options::video.border.enabled ? Options::game.height + (Options::video.border.height * 2) : Options::game.height; #ifdef __APPLE__ SDL_WindowFlags window_flags = SDL_WINDOW_METAL; #else diff --git a/source/core/rendering/screen.hpp b/source/core/rendering/screen.hpp index 4b58446..b2dcca5 100644 --- a/source/core/rendering/screen.hpp +++ b/source/core/rendering/screen.hpp @@ -93,7 +93,7 @@ class Screen { #endif // Dibuja las notificaciones - void renderNotifications(); + void renderNotifications() const; // Calcula el tamaño de la ventana void adjustWindowSize(); @@ -172,13 +172,13 @@ class Screen { void setBorderColor(Uint8 color); // Establece el tamaño del borde - void setBorderWidth(int width); + static void setBorderWidth(int width); // Establece el tamaño del borde - void setBorderHeight(int height); + static void setBorderHeight(int height); // Establece si se ha de ver el borde en el modo ventana - void setBorderEnabled(bool value); + static void setBorderEnabled(bool value); // Cambia entre borde visible y no visible void toggleBorder(); diff --git a/source/core/rendering/surface.cpp b/source/core/rendering/surface.cpp index c68ab51..0cc4e8b 100644 --- a/source/core/rendering/surface.cpp +++ b/source/core/rendering/surface.cpp @@ -35,8 +35,7 @@ Palette loadPalette(const std::string& file_path) { } // Cargar la paleta usando los datos del buffer - GIF::Gif gif; - std::vector pal = gif.loadPalette(buffer.data()); + std::vector pal = GIF::Gif::loadPalette(buffer.data()); if (pal.empty()) { throw std::runtime_error("No palette found in GIF file: " + file_path); } @@ -435,7 +434,7 @@ void Surface::copyToTexture(SDL_Renderer* renderer, SDL_Texture* texture) { throw std::runtime_error("Renderer or texture is null."); } - if (surface_data_->width <= 0 || surface_data_->height <= 0 || (surface_data_->data.get() == nullptr)) { + if (surface_data_->width <= 0 || surface_data_->height <= 0 || (surface_data_->data == nullptr)) { throw std::runtime_error("Invalid surface dimensions or data."); } @@ -474,7 +473,7 @@ void Surface::copyToTexture(SDL_Renderer* renderer, SDL_Texture* texture, SDL_FR throw std::runtime_error("Renderer or texture is null."); } - if (surface_data_->width <= 0 || surface_data_->height <= 0 || (surface_data_->data.get() == nullptr)) { + if (surface_data_->width <= 0 || surface_data_->height <= 0 || (surface_data_->data == nullptr)) { throw std::runtime_error("Invalid surface dimensions or data."); } diff --git a/source/core/resources/resource.cpp b/source/core/resources/resource.cpp index 2be853b..aca9270 100644 --- a/source/core/resources/resource.cpp +++ b/source/core/resources/resource.cpp @@ -18,16 +18,16 @@ struct JA_Music_t; // lines 17-17 struct JA_Sound_t; // lines 18-18 // [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado -Resource* Resource::resource_ = nullptr; +Resource* Resource::resource = nullptr; // [SINGLETON] Crearemos el objeto screen con esta función estática -void Resource::init() { Resource::resource_ = new Resource(); } +void Resource::init() { Resource::resource = new Resource(); } // [SINGLETON] Destruiremos el objeto screen con esta función estática -void Resource::destroy() { delete Resource::resource_; } +void Resource::destroy() { delete Resource::resource; } // [SINGLETON] Con este método obtenemos el objeto screen y podemos trabajar con él -Resource* Resource::get() { return Resource::resource_; } +Resource* Resource::get() { return Resource::resource; } // Constructor Resource::Resource() { load(); } @@ -155,7 +155,7 @@ std::vector& Resource::getTileMap(const std::string& name) { auto it = std::find_if(tile_maps_.begin(), tile_maps_.end(), [&name](const auto& t) { return t.name == name; }); if (it != tile_maps_.end()) { - return it->tileMap; + return it->tile_map; } std::cerr << "Error: Mapa de tiles no encontrado " << name << std::endl; @@ -300,14 +300,14 @@ void Resource::loadRooms() { void Resource::createText() { struct ResourceInfo { std::string key; // Identificador del recurso - std::string textureFile; // Nombre del archivo de textura - std::string textFile; // Nombre del archivo de texto + std::string texture_file; // Nombre del archivo de textura + std::string text_file; // Nombre del archivo de texto // Constructor para facilitar la creación de objetos ResourceInfo - ResourceInfo(const std::string& k, const std::string& tFile, const std::string& txtFile) + ResourceInfo(const std::string& k, const std::string& t_file, const std::string& txt_file) : key(k), - textureFile(tFile), - textFile(txtFile) {} + texture_file(t_file), + text_file(txt_file) {} }; std::cout << "\n>> CREATING TEXT_OBJECTS" << std::endl; @@ -320,7 +320,7 @@ void Resource::createText() { {"8bithud", "8bithud.gif", "8bithud.txt"}}; for (const auto& resource : resources) { - texts_.emplace_back(ResourceText(resource.key, std::make_shared(getSurface(resource.textureFile), getTextFile(resource.textFile)))); + texts_.emplace_back(ResourceText(resource.key, std::make_shared(getSurface(resource.texture_file), getTextFile(resource.text_file)))); printWithDots("Text : ", resource.key, "[ DONE ]"); } } @@ -329,7 +329,7 @@ void Resource::createText() { void Resource::clearSounds() { // Itera sobre el vector y libera los recursos asociados a cada JA_Sound_t for (auto& sound : sounds_) { - if (sound.sound) { + if (sound.sound != nullptr) { JA_DeleteSound(sound.sound); sound.sound = nullptr; } @@ -341,7 +341,7 @@ void Resource::clearSounds() { void Resource::clearMusics() { // Itera sobre el vector y libera los recursos asociados a cada JA_Music_t for (auto& music : musics_) { - if (music.music) { + if (music.music != nullptr) { JA_DeleteMusic(music.music); music.music = nullptr; } @@ -351,7 +351,7 @@ void Resource::clearMusics() { // Calcula el numero de recursos para cargar void Resource::calculateTotal() { - std::vector assetTypes = { + std::vector asset_types = { AssetType::SOUND, AssetType::MUSIC, AssetType::BITMAP, @@ -362,8 +362,8 @@ void Resource::calculateTotal() { AssetType::ROOM}; size_t total = 0; - for (const auto& assetType : assetTypes) { - auto list = Asset::get()->getListByType(assetType); + for (const auto& asset_type : asset_types) { + auto list = Asset::get()->getListByType(asset_type); total += list.size(); } @@ -375,17 +375,17 @@ void Resource::renderProgress() { constexpr float X_PADDING = 10; constexpr float Y_PADDING = 10; constexpr float BAR_HEIGHT = 10; - const float bar_position = Options::game.height - BAR_HEIGHT - Y_PADDING; + const float BAR_POSITION = Options::game.height - BAR_HEIGHT - Y_PADDING; Screen::get()->start(); Screen::get()->clearSurface(static_cast(PaletteColor::BLACK)); auto surface = Screen::get()->getRendererSurface(); const float WIRED_BAR_WIDTH = Options::game.width - (X_PADDING * 2); - SDL_FRect rect_wired = {X_PADDING, bar_position, WIRED_BAR_WIDTH, X_PADDING}; + SDL_FRect rect_wired = {X_PADDING, BAR_POSITION, WIRED_BAR_WIDTH, X_PADDING}; surface->drawRectBorder(&rect_wired, static_cast(PaletteColor::WHITE)); const float FULL_BAR_WIDTH = WIRED_BAR_WIDTH * count_.getPercentage(); - SDL_FRect rect_full = {X_PADDING, bar_position, FULL_BAR_WIDTH, X_PADDING}; + SDL_FRect rect_full = {X_PADDING, BAR_POSITION, FULL_BAR_WIDTH, X_PADDING}; surface->fillRect(&rect_full, static_cast(PaletteColor::WHITE)); Screen::get()->render(); diff --git a/source/core/resources/resource.hpp b/source/core/resources/resource.hpp index 4366b70..1122046 100644 --- a/source/core/resources/resource.hpp +++ b/source/core/resources/resource.hpp @@ -91,12 +91,12 @@ struct ResourceAnimation { // Estructura para almacenar ficheros con el mapa de tiles de una habitación y su nombre struct ResourceTileMap { std::string name; // Nombre del mapa de tiles - std::vector tileMap; // Vector con los indices del mapa de tiles + std::vector tile_map; // Vector con los indices del mapa de tiles // Constructor - ResourceTileMap(const std::string& name, const std::vector& tileMap) + ResourceTileMap(const std::string& name, const std::vector& tile_map) : name(name), - tileMap(tileMap) {} + tile_map(tile_map) {} }; // Estructura para almacenar habitaciones y su nombre @@ -131,7 +131,7 @@ struct ResourceCount { } // Obtiene el porcentaje de recursos cargados - float getPercentage() { + float getPercentage() const { return static_cast(loaded) / static_cast(total); } }; @@ -139,7 +139,7 @@ struct ResourceCount { class Resource { private: // [SINGLETON] Objeto resource privado para Don Melitón - static Resource* resource_; + static Resource* resource; std::vector sounds_; // Vector con los sonidos std::vector musics_; // Vector con las musicas @@ -198,8 +198,8 @@ class Resource { // Muestra el progreso de carga void renderProgress(); - // Comprueba los eventos - void checkEvents(); + // Comprueba los eventosstatic + static void checkEvents(); // Actualiza el progreso de carga void updateLoadingProgress(int steps = 5); diff --git a/source/core/system/director.cpp b/source/core/system/director.cpp index 038ecfb..e221eef 100644 --- a/source/core/system/director.cpp +++ b/source/core/system/director.cpp @@ -243,45 +243,45 @@ bool Director::setFileList() { #ifdef MACOS_BUNDLE const std::string prefix = "/../Resources"; #else - const std::string prefix = ""; + const std::string PREFIX; #endif // Texto - Asset::get()->add(prefix + "/data/font/smb2.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/font/smb2.txt", AssetType::FONT); - Asset::get()->add(prefix + "/data/font/debug.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/font/debug.txt", AssetType::FONT); - Asset::get()->add(prefix + "/data/font/gauntlet.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/font/gauntlet.txt", AssetType::FONT); - Asset::get()->add(prefix + "/data/font/subatomic.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/font/subatomic.txt", AssetType::FONT); - Asset::get()->add(prefix + "/data/font/8bithud.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/font/8bithud.txt", AssetType::FONT); + Asset::get()->add(PREFIX + "/data/font/smb2.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/font/smb2.txt", AssetType::FONT); + Asset::get()->add(PREFIX + "/data/font/debug.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/font/debug.txt", AssetType::FONT); + Asset::get()->add(PREFIX + "/data/font/gauntlet.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/font/gauntlet.txt", AssetType::FONT); + Asset::get()->add(PREFIX + "/data/font/subatomic.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/font/subatomic.txt", AssetType::FONT); + Asset::get()->add(PREFIX + "/data/font/8bithud.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/font/8bithud.txt", AssetType::FONT); // Paletas - Asset::get()->add(prefix + "/data/palette/zx-spectrum.pal", AssetType::PALETTE); - Asset::get()->add(prefix + "/data/palette/zx-spectrum-adjusted.pal", AssetType::PALETTE); - Asset::get()->add(prefix + "/data/palette/zxarne-5-2.pal", AssetType::PALETTE); - Asset::get()->add(prefix + "/data/palette/black-and-white.pal", AssetType::PALETTE); - Asset::get()->add(prefix + "/data/palette/green-phosphor.pal", AssetType::PALETTE); - Asset::get()->add(prefix + "/data/palette/orange-screen.pal", AssetType::PALETTE); - Asset::get()->add(prefix + "/data/palette/ruzx-spectrum.pal", AssetType::PALETTE); - Asset::get()->add(prefix + "/data/palette/ruzx-spectrum-revision-2.pal", AssetType::PALETTE); - Asset::get()->add(prefix + "/data/palette/pico-8.pal", AssetType::PALETTE); - Asset::get()->add(prefix + "/data/palette/sweetie-16.pal", AssetType::PALETTE); - Asset::get()->add(prefix + "/data/palette/island-joy-16.pal", AssetType::PALETTE); - Asset::get()->add(prefix + "/data/palette/lost-century.pal", AssetType::PALETTE); - Asset::get()->add(prefix + "/data/palette/na16.pal", AssetType::PALETTE); - Asset::get()->add(prefix + "/data/palette/steam-lords.pal", AssetType::PALETTE); + Asset::get()->add(PREFIX + "/data/palette/zx-spectrum.pal", AssetType::PALETTE); + Asset::get()->add(PREFIX + "/data/palette/zx-spectrum-adjusted.pal", AssetType::PALETTE); + Asset::get()->add(PREFIX + "/data/palette/zxarne-5-2.pal", AssetType::PALETTE); + Asset::get()->add(PREFIX + "/data/palette/black-and-white.pal", AssetType::PALETTE); + Asset::get()->add(PREFIX + "/data/palette/green-phosphor.pal", AssetType::PALETTE); + Asset::get()->add(PREFIX + "/data/palette/orange-screen.pal", AssetType::PALETTE); + Asset::get()->add(PREFIX + "/data/palette/ruzx-spectrum.pal", AssetType::PALETTE); + Asset::get()->add(PREFIX + "/data/palette/ruzx-spectrum-revision-2.pal", AssetType::PALETTE); + Asset::get()->add(PREFIX + "/data/palette/pico-8.pal", AssetType::PALETTE); + Asset::get()->add(PREFIX + "/data/palette/sweetie-16.pal", AssetType::PALETTE); + Asset::get()->add(PREFIX + "/data/palette/island-joy-16.pal", AssetType::PALETTE); + Asset::get()->add(PREFIX + "/data/palette/lost-century.pal", AssetType::PALETTE); + Asset::get()->add(PREFIX + "/data/palette/na16.pal", AssetType::PALETTE); + Asset::get()->add(PREFIX + "/data/palette/steam-lords.pal", AssetType::PALETTE); // Shaders - Asset::get()->add(prefix + "/data/shaders/crtpi_vertex.glsl", AssetType::DATA); - Asset::get()->add(prefix + "/data/shaders/crtpi_fragment.glsl", AssetType::DATA); - Asset::get()->add(prefix + "/data/shaders/crtpi_vertex_es.glsl", AssetType::DATA); - Asset::get()->add(prefix + "/data/shaders/crtpi_fragment_es.glsl", AssetType::DATA); + Asset::get()->add(PREFIX + "/data/shaders/crtpi_vertex.glsl", AssetType::DATA); + Asset::get()->add(PREFIX + "/data/shaders/crtpi_fragment.glsl", AssetType::DATA); + Asset::get()->add(PREFIX + "/data/shaders/crtpi_vertex_es.glsl", AssetType::DATA); + Asset::get()->add(PREFIX + "/data/shaders/crtpi_fragment_es.glsl", AssetType::DATA); // Datos - Asset::get()->add(prefix + "/data/input/gamecontrollerdb.txt", AssetType::DATA); + Asset::get()->add(PREFIX + "/data/input/gamecontrollerdb.txt", AssetType::DATA); // Ficheros de sistema Asset::get()->add(system_folder_ + "/config.txt", AssetType::DATA, false, true); @@ -292,182 +292,182 @@ bool Director::setFileList() { // Tilemaps y Rooms for (int i = 1; i <= 60; ++i) { std::string index = (i < 10 ? "0" : "") + std::to_string(i); - Asset::get()->add(prefix + "/data/room/" + index + ".tmx", AssetType::TILEMAP); - Asset::get()->add(prefix + "/data/room/" + index + ".room", AssetType::ROOM); + Asset::get()->add(PREFIX + "/data/room/" + index + ".tmx", AssetType::TILEMAP); + Asset::get()->add(PREFIX + "/data/room/" + index + ".room", AssetType::ROOM); } // Tilesets - Asset::get()->add(prefix + "/data/tilesets/standard.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/tilesets/standard.gif", AssetType::BITMAP); // Enemigos - Asset::get()->add(prefix + "/data/enemies/abad_bell.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/abad_bell.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/abad.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/abad.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/amstrad_cs.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/amstrad_cs.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/flying_arounder.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/flying_arounder.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/stopped_arounder.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/stopped_arounder.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/walking_arounder.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/walking_arounder.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/arounders_door.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/arounders_door.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/arounders_machine.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/arounders_machine.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/bat.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/bat.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/batman_bell.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/batman_bell.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/batman_fire.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/batman_fire.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/batman.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/batman.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/bell.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/bell.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/bin.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/bin.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/bird.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/bird.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/breakout.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/breakout.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/bry.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/bry.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/chip.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/chip.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/code.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/code.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/congo.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/congo.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/crosshair.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/crosshair.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/demon.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/demon.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/dimallas.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/dimallas.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/floppy.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/floppy.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/dong.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/dong.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/guitar.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/guitar.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/heavy.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/heavy.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/jailer_#1.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/jailer_#1.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/jailer_#2.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/jailer_#2.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/jailer_#3.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/jailer_#3.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/jailbattle_alien.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/jailbattle_alien.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/jailbattle_human.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/jailbattle_human.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/jeannine.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/jeannine.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/lamp.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/lamp.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/lord_abad.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/lord_abad.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/matatunos.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/matatunos.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/mummy.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/mummy.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/paco.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/paco.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/elsa.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/elsa.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/qvoid.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/qvoid.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/robot.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/robot.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/sam.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/sam.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/shock.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/shock.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/sigmasua.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/sigmasua.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/spark.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/spark.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/special/aerojailer.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/special/aerojailer.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/special/arounder.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/special/arounder.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/special/pepe_rosita_job.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/special/pepe_rosita_job.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/special/shooting_star.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/special/shooting_star.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/spider.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/spider.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/tree_thing.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/tree_thing.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/tuno.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/tuno.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/tv_panel.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/tv_panel.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/tv.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/tv.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/upv_student.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/upv_student.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/wave.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/wave.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/enemies/z80.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/enemies/z80.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/abad_bell.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/abad_bell.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/abad.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/abad.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/amstrad_cs.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/amstrad_cs.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/flying_arounder.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/flying_arounder.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/stopped_arounder.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/stopped_arounder.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/walking_arounder.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/walking_arounder.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/arounders_door.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/arounders_door.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/arounders_machine.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/arounders_machine.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/bat.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/bat.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/batman_bell.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/batman_bell.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/batman_fire.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/batman_fire.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/batman.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/batman.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/bell.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/bell.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/bin.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/bin.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/bird.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/bird.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/breakout.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/breakout.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/bry.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/bry.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/chip.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/chip.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/code.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/code.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/congo.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/congo.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/crosshair.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/crosshair.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/demon.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/demon.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/dimallas.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/dimallas.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/floppy.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/floppy.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/dong.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/dong.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/guitar.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/guitar.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/heavy.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/heavy.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/jailer_#1.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/jailer_#1.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/jailer_#2.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/jailer_#2.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/jailer_#3.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/jailer_#3.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/jailbattle_alien.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/jailbattle_alien.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/jailbattle_human.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/jailbattle_human.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/jeannine.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/jeannine.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/lamp.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/lamp.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/lord_abad.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/lord_abad.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/matatunos.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/matatunos.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/mummy.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/mummy.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/paco.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/paco.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/elsa.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/elsa.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/qvoid.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/qvoid.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/robot.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/robot.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/sam.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/sam.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/shock.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/shock.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/sigmasua.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/sigmasua.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/spark.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/spark.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/special/aerojailer.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/special/aerojailer.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/special/arounder.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/special/arounder.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/special/pepe_rosita_job.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/special/pepe_rosita_job.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/special/shooting_star.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/special/shooting_star.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/spider.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/spider.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/tree_thing.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/tree_thing.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/tuno.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/tuno.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/tv_panel.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/tv_panel.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/tv.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/tv.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/upv_student.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/upv_student.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/wave.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/wave.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/enemies/z80.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/enemies/z80.gif", AssetType::BITMAP); // Jugador - Asset::get()->add(prefix + "/data/player/player.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/player/player.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/player/player2.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/player/player2.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/player/player_game_over.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/player/player_game_over.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/player/player.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/player/player.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/player/player2.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/player/player2.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/player/player_game_over.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/player/player_game_over.ani", AssetType::ANIMATION); // Items - Asset::get()->add(prefix + "/data/items/items.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/items/items.gif", AssetType::BITMAP); // Musicas - Asset::get()->add(prefix + "/data/music/title.ogg", AssetType::MUSIC); - Asset::get()->add(prefix + "/data/music/game.ogg", AssetType::MUSIC); - Asset::get()->add(prefix + "/data/music/loading_sound1.ogg", AssetType::MUSIC); - Asset::get()->add(prefix + "/data/music/loading_sound2.ogg", AssetType::MUSIC); - Asset::get()->add(prefix + "/data/music/loading_sound3.ogg", AssetType::MUSIC); - Asset::get()->add(prefix + "/data/music/ending1.ogg", AssetType::MUSIC); - Asset::get()->add(prefix + "/data/music/ending2.ogg", AssetType::MUSIC); - Asset::get()->add(prefix + "/data/music/game_over.ogg", AssetType::MUSIC); + Asset::get()->add(PREFIX + "/data/music/title.ogg", AssetType::MUSIC); + Asset::get()->add(PREFIX + "/data/music/game.ogg", AssetType::MUSIC); + Asset::get()->add(PREFIX + "/data/music/loading_sound1.ogg", AssetType::MUSIC); + Asset::get()->add(PREFIX + "/data/music/loading_sound2.ogg", AssetType::MUSIC); + Asset::get()->add(PREFIX + "/data/music/loading_sound3.ogg", AssetType::MUSIC); + Asset::get()->add(PREFIX + "/data/music/ending1.ogg", AssetType::MUSIC); + Asset::get()->add(PREFIX + "/data/music/ending2.ogg", AssetType::MUSIC); + Asset::get()->add(PREFIX + "/data/music/game_over.ogg", AssetType::MUSIC); // Efectos de sonido - Asset::get()->add(prefix + "/data/sound/item.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/death.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/notify.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/item.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/death.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/notify.wav", AssetType::SOUND); // Efectos de sonido para el salto for (int i = 1; i <= 24; ++i) { std::string jump_index = std::to_string(i); - Asset::get()->add(prefix + "/data/sound/jump" + jump_index + ".wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/jump" + jump_index + ".wav", AssetType::SOUND); } // Logo - Asset::get()->add(prefix + "/data/logo/jailgames.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/logo/since_1998.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/logo/jailgames.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/logo/since_1998.gif", AssetType::BITMAP); // Loading - Asset::get()->add(prefix + "/data/loading/loading_screen_bn.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/loading/loading_screen_color.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/loading/loading_screen_bn.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/loading/loading_screen_color.gif", AssetType::BITMAP); // Title - Asset::get()->add(prefix + "/data/title/title_logo.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/title/title_logo.gif", AssetType::BITMAP); // Ending - Asset::get()->add(prefix + "/data/ending/ending1.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/ending/ending2.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/ending/ending3.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/ending/ending4.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/ending/ending5.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/ending/ending1.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/ending/ending2.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/ending/ending3.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/ending/ending4.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/ending/ending5.gif", AssetType::BITMAP); // Credits - Asset::get()->add(prefix + "/data/credits/shine.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/credits/shine.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/credits/shine.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/credits/shine.ani", AssetType::ANIMATION); return Asset::get()->check(); } @@ -480,8 +480,8 @@ void Director::runLogo() { // Ejecuta la seccion de juego de la pantalla de carga void Director::runLoadingScreen() { - auto loadingScreen = std::make_unique(); - loadingScreen->run(); + auto loading_screen = std::make_unique(); + loading_screen->run(); } // Ejecuta la seccion de juego con el titulo y los menus @@ -516,8 +516,8 @@ void Director::runEnding2() { // Ejecuta la seccion del final de la partida void Director::runGameOver() { - auto gameOver = std::make_unique(); - gameOver->run(); + auto game_over = std::make_unique(); + game_over->run(); } // Ejecuta la seccion de juego donde se juega diff --git a/source/core/system/director.hpp b/source/core/system/director.hpp index 022c561..3ca0099 100644 --- a/source/core/system/director.hpp +++ b/source/core/system/director.hpp @@ -8,25 +8,25 @@ class Director { public: Director(int argc, const char* argv[]); // Constructor ~Director(); // Destructor - int run(); // Bucle principal + static int run(); // Bucle principal private: // --- Variables --- std::string executable_path_; // Path del ejecutable std::string system_folder_; // Carpeta del sistema donde guardar datos - std::string checkProgramArguments(int argc, const char* argv[]); // Comprueba los parametros del programa + static std::string checkProgramArguments(int argc, const char* argv[]); // Comprueba los parametros del programa // --- Funciones --- void createSystemFolder(const std::string& folder); // Crea la carpeta del sistema donde guardar datos - void initInput(); // Inicializa el objeto Input + static void initInput(); // Inicializa el objeto Input bool setFileList(); // Crea el indice de ficheros - void runLogo(); // Ejecuta la seccion de juego con el logo - void runLoadingScreen(); // Ejecuta la seccion de juego de la pantalla de carga - void runTitle(); // Ejecuta la seccion de juego con el titulo y los menus - void runCredits(); // Ejecuta la seccion de los creditos del juego - void runDemo(); // Ejecuta la seccion de la demo, donde se ven pantallas del juego - void runEnding(); // Ejecuta la seccion del final del juego - void runEnding2(); // Ejecuta la seccion del final del juego - void runGameOver(); // Ejecuta la seccion del final de la partida - void runGame(); // Ejecuta la seccion de juego donde se juega + static void runLogo(); // Ejecuta la seccion de juego con el logo + static void runLoadingScreen(); // Ejecuta la seccion de juego de la pantalla de carga + static void runTitle(); // Ejecuta la seccion de juego con el titulo y los menus + static void runCredits(); // Ejecuta la seccion de los creditos del juego + static void runDemo(); // Ejecuta la seccion de la demo, donde se ven pantallas del juego + static void runEnding(); // Ejecuta la seccion del final del juego + static void runEnding2(); // Ejecuta la seccion del final del juego + static void runGameOver(); // Ejecuta la seccion del final de la partida + static void runGame(); // Ejecuta la seccion de juego donde se juega }; \ No newline at end of file diff --git a/source/game/entities/item.cpp b/source/game/entities/item.cpp index a97662c..d1b69c0 100644 --- a/source/game/entities/item.cpp +++ b/source/game/entities/item.cpp @@ -28,8 +28,8 @@ void Item::render() { // Obtiene su ubicación SDL_FPoint Item::getPos() { - const SDL_FPoint p = {sprite_->getX(), sprite_->getY()}; - return p; + const SDL_FPoint P = {sprite_->getX(), sprite_->getY()}; + return P; } // Asigna los colores del objeto diff --git a/source/game/entities/player.cpp b/source/game/entities/player.cpp index 930901a..31f5b37 100644 --- a/source/game/entities/player.cpp +++ b/source/game/entities/player.cpp @@ -69,27 +69,27 @@ void Player::checkInput() { if (!auto_movement_) { // Comprueba las entradas de desplazamiento lateral solo en el caso de no estar enganchado a una superficie automatica if (Input::get()->checkInput(InputAction::LEFT)) { - vx_ = -0.6f; + vx_ = -0.6F; sprite_->setFlip(SDL_FLIP_HORIZONTAL); } else if (Input::get()->checkInput(InputAction::RIGHT)) { - vx_ = 0.6f; + vx_ = 0.6F; sprite_->setFlip(SDL_FLIP_NONE); } else { // No se pulsa ninguna dirección - vx_ = 0.0f; + vx_ = 0.0F; if (isOnAutoSurface()) { // Si deja de moverse sobre una superficie se engancha auto_movement_ = true; } } } else { // El movimiento lo proporciona la superficie - vx_ = 0.6f * room_->getAutoSurfaceDirection(); + vx_ = 0.6F * room_->getAutoSurfaceDirection(); - if (vx_ > 0.0f) { + if (vx_ > 0.0F) { sprite_->setFlip(SDL_FLIP_NONE); } else { sprite_->setFlip(SDL_FLIP_HORIZONTAL); @@ -104,7 +104,7 @@ void Player::checkInput() { if (isOnFloor() || isOnAutoSurface()) { setState(PlayerState::JUMPING); - vy_ = -MAX_VY_; + vy_ = -MAX_VY; jump_init_pos_ = y_; jumping_counter_ = 0; } @@ -118,7 +118,7 @@ void Player::checkBorders() { is_on_border_ = true; } - else if (x_ + WIDTH_ > PLAY_AREA_RIGHT) { + else if (x_ + WIDTH > PLAY_AREA_RIGHT) { border_ = RoomBorder::RIGHT; is_on_border_ = true; } @@ -128,7 +128,7 @@ void Player::checkBorders() { is_on_border_ = true; } - else if (y_ + HEIGHT_ > PLAY_AREA_BOTTOM) { + else if (y_ + HEIGHT > PLAY_AREA_BOTTOM) { border_ = RoomBorder::BOTTOM; is_on_border_ = true; } @@ -142,23 +142,23 @@ void Player::checkBorders() { void Player::checkState() { // Actualiza las variables en función del estado if (state_ == PlayerState::FALLING) { - vx_ = 0.0f; - vy_ = MAX_VY_; + vx_ = 0.0F; + vy_ = MAX_VY; falling_counter_++; playFallSound(); } else if (state_ == PlayerState::STANDING) { - if (previous_state_ == PlayerState::FALLING && falling_counter_ > MAX_FALLING_HEIGHT_) { // Si cae de muy alto, el jugador muere + if (previous_state_ == PlayerState::FALLING && falling_counter_ > MAX_FALLING_HEIGHT) { // Si cae de muy alto, el jugador muere is_alive_ = false; } - vy_ = 0.0f; + vy_ = 0.0F; jumping_counter_ = 0; falling_counter_ = 0; if (!isOnFloor() && !isOnAutoSurface() && !isOnDownSlope()) { setState(PlayerState::FALLING); - vx_ = 0.0f; - vy_ = MAX_VY_; + vx_ = 0.0F; + vy_ = MAX_VY; falling_counter_++; playFallSound(); } @@ -175,7 +175,7 @@ void Player::checkState() { void Player::switchBorders() { switch (border_) { case RoomBorder::TOP: - y_ = PLAY_AREA_BOTTOM - HEIGHT_ - BLOCK; + y_ = PLAY_AREA_BOTTOM - HEIGHT - BLOCK; setState(PlayerState::STANDING); break; @@ -189,7 +189,7 @@ void Player::switchBorders() { break; case RoomBorder::LEFT: - x_ = PLAY_AREA_RIGHT - WIDTH_; + x_ = PLAY_AREA_RIGHT - WIDTH; break; default: @@ -203,15 +203,13 @@ void Player::switchBorders() { // Aplica gravedad al jugador void Player::applyGravity() { - constexpr float GRAVITY_FORCE = 0.035f; + constexpr float GRAVITY_FORCE = 0.035F; // La gravedad solo se aplica cuando el jugador esta saltando // Nunca mientras cae o esta de pie if (state_ == PlayerState::JUMPING) { vy_ += GRAVITY_FORCE; - if (vy_ > MAX_VY_) { - vy_ = MAX_VY_; - } + vy_ = std::min(vy_, MAX_VY); } } @@ -226,12 +224,12 @@ void Player::move() { #endif // Se mueve hacia la izquierda - if (vx_ < 0.0f) { + if (vx_ < 0.0F) { // Crea el rectangulo de proyección en el eje X para ver si colisiona SDL_FRect proj; proj.x = static_cast(x_ + vx_); proj.y = static_cast(y_); - proj.h = HEIGHT_; + proj.h = HEIGHT; proj.w = static_cast(std::ceil(std::fabs(vx_))); // Para evitar que tenga un ancho de 0 pixels #ifdef _DEBUG @@ -252,10 +250,10 @@ void Player::move() { // Si ha tocado alguna rampa mientras camina (sin saltar), asciende if (state_ != PlayerState::JUMPING) { - const LineVertical LEFT_SIDE = {static_cast(x_), static_cast(y_) + static_cast(HEIGHT_) - 2, static_cast(y_) + static_cast(HEIGHT_) - 1}; // Comprueba solo los dos pixels de abajo + const LineVertical LEFT_SIDE = {static_cast(x_), static_cast(y_) + static_cast(HEIGHT) - 2, static_cast(y_) + static_cast(HEIGHT) - 1}; // Comprueba solo los dos pixels de abajo const int LY = room_->checkLeftSlopes(&LEFT_SIDE); if (LY > -1) { - y_ = LY - HEIGHT_; + y_ = LY - HEIGHT; } } @@ -266,12 +264,12 @@ void Player::move() { } // Se mueve hacia la derecha - else if (vx_ > 0.0f) { + else if (vx_ > 0.0F) { // Crea el rectangulo de proyección en el eje X para ver si colisiona SDL_FRect proj; - proj.x = x_ + WIDTH_; + proj.x = x_ + WIDTH; proj.y = y_; - proj.h = HEIGHT_; + proj.h = HEIGHT; proj.w = ceil(vx_); // Para evitar que tenga un ancho de 0 pixels #ifdef _DEBUG @@ -287,15 +285,15 @@ void Player::move() { x_ += vx_; } else { // Si hay colisión lo mueve hasta donde no colisiona - x_ = POS - WIDTH_; + x_ = POS - WIDTH; } // Si ha tocado alguna rampa mientras camina (sin saltar), asciende if (state_ != PlayerState::JUMPING) { - const LineVertical RIGHT_SIDE = {static_cast(x_) + static_cast(WIDTH_) - 1, static_cast(y_) + static_cast(HEIGHT_) - 2, static_cast(y_) + static_cast(HEIGHT_) - 1}; // Comprueba solo los dos pixels de abajo + const LineVertical RIGHT_SIDE = {static_cast(x_) + static_cast(WIDTH) - 1, static_cast(y_) + static_cast(HEIGHT) - 2, static_cast(y_) + static_cast(HEIGHT) - 1}; // Comprueba solo los dos pixels de abajo const int RY = room_->checkRightSlopes(&RIGHT_SIDE); if (RY > -1) { - y_ = RY - HEIGHT_; + y_ = RY - HEIGHT; } } @@ -320,13 +318,13 @@ void Player::move() { } // Se mueve hacia arriba - if (vy_ < 0.0f) { + if (vy_ < 0.0F) { // Crea el rectangulo de proyección en el eje Y para ver si colisiona SDL_FRect proj; proj.x = static_cast(x_); proj.y = static_cast(y_ + vy_); proj.h = static_cast(std::ceil(std::fabs(vy_))); // Para evitar que tenga una altura de 0 pixels - proj.w = WIDTH_; + proj.w = WIDTH; #ifdef _DEBUG debug_rect_y_ = proj; @@ -347,13 +345,13 @@ void Player::move() { } // Se mueve hacia abajo - else if (vy_ > 0.0f) { + else if (vy_ > 0.0F) { // Crea el rectangulo de proyección en el eje Y para ver si colisiona SDL_FRect proj; proj.x = x_; - proj.y = y_ + HEIGHT_; + proj.y = y_ + HEIGHT; proj.h = ceil(vy_); // Para evitar que tenga una altura de 0 pixels - proj.w = WIDTH_; + proj.w = WIDTH; #ifdef _DEBUG debug_rect_y_ = proj; @@ -363,7 +361,7 @@ void Player::move() { const float POS = std::max(room_->checkTopSurfaces(&proj), room_->checkAutoSurfaces(&proj)); if (POS > -1) { // Si hay colisión lo mueve hasta donde no colisiona y pasa a estar sobre la superficie - y_ = POS - HEIGHT_; + y_ = POS - HEIGHT; setState(PlayerState::STANDING); // Deja de estar enganchado a la superficie automatica @@ -378,11 +376,11 @@ void Player::move() { if (POINT > -1) { // No está saltando y hay colisión con una rampa // Calcula la nueva posición - y_ = POINT - HEIGHT_; + y_ = POINT - HEIGHT; setState(PlayerState::STANDING); #ifdef _DEBUG debug_color_ = static_cast(PaletteColor::YELLOW); - debug_point_ = {x_ + (WIDTH_ / 2), POINT}; + debug_point_ = {x_ + (WIDTH / 2), POINT}; #endif } else { // No está saltando y no hay colisón con una rampa @@ -423,7 +421,7 @@ void Player::checkJumpEnd() { if (y_ >= jump_init_pos_) { // Si alcanza la altura de salto inicial, pasa al estado de caída setState(PlayerState::FALLING); - vy_ = MAX_VY_; + vy_ = MAX_VY; jumping_counter_ = 0; } } @@ -467,7 +465,7 @@ bool Player::isOnFloor() { } // Comprueba las rampas - on_slope_l = room_->checkLeftSlopes(&under_feet_[0]); + on_slope_l = room_->checkLeftSlopes(under_feet_.data()); on_slope_r = room_->checkRightSlopes(&under_feet_[1]); #ifdef _DEBUG @@ -519,7 +517,7 @@ bool Player::isOnDownSlope() { under_feet_[1].y += 1; // Comprueba las rampas - on_slope |= room_->checkLeftSlopes(&under_feet_[0]); + on_slope |= room_->checkLeftSlopes(under_feet_.data()); on_slope |= room_->checkRightSlopes(&under_feet_[1]); #ifdef _DEBUG @@ -560,26 +558,26 @@ void Player::setColor() { // Actualiza los puntos de colisión void Player::updateColliderPoints() { - const SDL_FRect rect = getRect(); - collider_points_[0] = {rect.x, rect.y}; - collider_points_[1] = {rect.x + 7, rect.y}; - collider_points_[2] = {rect.x + 7, rect.y + 7}; - collider_points_[3] = {rect.x, rect.y + 7}; - collider_points_[4] = {rect.x, rect.y + 8}; - collider_points_[5] = {rect.x + 7, rect.y + 8}; - collider_points_[6] = {rect.x + 7, rect.y + 15}; - collider_points_[7] = {rect.x, rect.y + 15}; + const SDL_FRect RECT = getRect(); + collider_points_[0] = {RECT.x, RECT.y}; + collider_points_[1] = {RECT.x + 7, RECT.y}; + collider_points_[2] = {RECT.x + 7, RECT.y + 7}; + collider_points_[3] = {RECT.x, RECT.y + 7}; + collider_points_[4] = {RECT.x, RECT.y + 8}; + collider_points_[5] = {RECT.x + 7, RECT.y + 8}; + collider_points_[6] = {RECT.x + 7, RECT.y + 15}; + collider_points_[7] = {RECT.x, RECT.y + 15}; } // Actualiza los puntos de los pies void Player::updateFeet() { - const SDL_FPoint p = {x_, y_}; + const SDL_FPoint P = {x_, y_}; - under_feet_[0] = {p.x, p.y + HEIGHT_}; - under_feet_[1] = {p.x + 7, p.y + HEIGHT_}; + under_feet_[0] = {P.x, P.y + HEIGHT}; + under_feet_[1] = {P.x + 7, P.y + HEIGHT}; - feet_[0] = {p.x, p.y + HEIGHT_ - 1}; - feet_[1] = {p.x + 7, p.y + HEIGHT_ - 1}; + feet_[0] = {P.x, P.y + HEIGHT - 1}; + feet_[1] = {P.x + 7, P.y + HEIGHT - 1}; } // Cambia el estado del jugador @@ -596,11 +594,11 @@ void Player::initSounds() { falling_sound_.clear(); for (int i = 1; i <= 24; ++i) { - std::string soundFile = "jump" + std::to_string(i) + ".wav"; - jumping_sound_.push_back(Resource::get()->getSound(soundFile)); + std::string sound_file = "jump" + std::to_string(i) + ".wav"; + jumping_sound_.push_back(Resource::get()->getSound(sound_file)); if (i >= 11) { - falling_sound_.push_back(Resource::get()->getSound(soundFile)); + falling_sound_.push_back(Resource::get()->getSound(sound_file)); } } } @@ -622,8 +620,8 @@ void Player::initSprite(const std::string& surface_path, const std::string& anim auto animations = Resource::get()->getAnimations(animations_path); sprite_ = std::make_shared(surface, animations); - sprite_->setWidth(WIDTH_); - sprite_->setHeight(HEIGHT_); + sprite_->setWidth(WIDTH); + sprite_->setHeight(HEIGHT); sprite_->setCurrentAnimation("walk"); } @@ -642,10 +640,10 @@ void Player::renderDebugInfo() { surface->drawRectBorder(&rect, static_cast(PaletteColor::BRIGHT_CYAN)); // Pinta el rectangulo de movimiento - if (vx_ != 0.0f) { + if (vx_ != 0.0F) { surface->fillRect(&debug_rect_x_, static_cast(PaletteColor::BRIGHT_RED)); } - if (vy_ != 0.0f) { + if (vy_ != 0.0F) { surface->fillRect(&debug_rect_y_, static_cast(PaletteColor::BRIGHT_RED)); } diff --git a/source/game/entities/player.hpp b/source/game/entities/player.hpp index f302e8f..99398d7 100644 --- a/source/game/entities/player.hpp +++ b/source/game/entities/player.hpp @@ -63,12 +63,12 @@ struct PlayerData { }; class Player { - public: + private: // Constantes - static constexpr int WIDTH_ = 8; // Ancho del jugador - static constexpr int HEIGHT_ = 16; // ALto del jugador - static constexpr int MAX_FALLING_HEIGHT_ = BLOCK * 4; // Altura maxima permitida de caída. - static constexpr float MAX_VY_ = 1.2f; // Velocidad máxima que puede alcanzar al desplazarse en vertical + static constexpr int WIDTH = 8; // Ancho del jugador + static constexpr int HEIGHT = 16; // ALto del jugador + static constexpr int MAX_FALLING_HEIGHT = BLOCK * 4; // Altura maxima permitida de caída. + static constexpr float MAX_VY = 1.2F; // Velocidad máxima que puede alcanzar al desplazarse en vertical // Objetos y punteros std::shared_ptr room_; // Objeto encargado de gestionar cada habitación del juego @@ -170,7 +170,7 @@ class Player { void renderDebugInfo(); #endif - public: +public: // Constructor explicit Player(const PlayerData& player); @@ -184,16 +184,16 @@ class Player { void update(); // Indica si el jugador esta en uno de los cuatro bordes de la pantalla - bool getOnBorder() { return is_on_border_; } + bool getOnBorder() const { return is_on_border_; } // Indica en cual de los cuatro bordes se encuentra - RoomBorder getBorder() { return border_; } + RoomBorder getBorder() const { return border_; } // Cambia al jugador de un borde al opuesto. Util para el cambio de pantalla void switchBorders(); // Obtiene el rectangulo que delimita al jugador - SDL_FRect getRect() { return {x_, y_, WIDTH_, HEIGHT_}; } + SDL_FRect getRect() { return {x_, y_, WIDTH, HEIGHT}; } // Obtiene el rectangulo de colision del jugador SDL_FRect& getCollider() { return collider_box_; } @@ -208,7 +208,7 @@ class Player { void setRoom(std::shared_ptr room) { room_ = room; } // Comprueba si el jugador esta vivo - bool isAlive() { return is_alive_; } + bool isAlive() const { return is_alive_; } // Pone el jugador en modo pausa void setPaused(bool value) { is_paused_ = value; } diff --git a/source/game/gameplay/room.cpp b/source/game/gameplay/room.cpp index 0ff19ce..744af8c 100644 --- a/source/game/gameplay/room.cpp +++ b/source/game/gameplay/room.cpp @@ -385,49 +385,49 @@ void Room::fillMapTexture() { auto surface = Screen::get()->getRendererSurface(); // BottomSurfaces - if (true) { + { for (auto l : bottom_floors_) { surface->drawLine(l.x1, l.y, l.x2, l.y, static_cast(PaletteColor::BLUE)); } } // TopSurfaces - if (true) { + { for (auto l : top_floors_) { surface->drawLine(l.x1, l.y, l.x2, l.y, static_cast(PaletteColor::RED)); } } // LeftSurfaces - if (true) { + { for (auto l : left_walls_) { surface->drawLine(l.x, l.y1, l.x, l.y2, static_cast(PaletteColor::GREEN)); } } // RightSurfaces - if (true) { + { for (auto l : right_walls_) { surface->drawLine(l.x, l.y1, l.x, l.y2, static_cast(PaletteColor::MAGENTA)); } } // LeftSlopes - if (true) { + { for (auto l : left_slopes_) { surface->drawLine(l.x1, l.y1, l.x2, l.y2, static_cast(PaletteColor::CYAN)); } } // RightSlopes - if (true) { + { for (auto l : right_slopes_) { surface->drawLine(l.x1, l.y1, l.x2, l.y2, static_cast(PaletteColor::YELLOW)); } } // AutoSurfaces - if (true) { + { for (auto l : conveyor_belt_floors_) { surface->drawLine(l.x1, l.y, l.x2, l.y, static_cast(PaletteColor::WHITE)); } @@ -540,17 +540,17 @@ TileType Room::getTile(int index) { } // Las filas 18-20 es de tiles t_animated - else if ((tile_map_[index] >= 18 * tile_set_width_) && (tile_map_[index] < 21 * tile_set_width_)) { + if ((tile_map_[index] >= 18 * tile_set_width_) && (tile_map_[index] < 21 * tile_set_width_)) { return TileType::ANIMATED; } // La fila 21 es de tiles t_slope_r - else if ((tile_map_[index] >= 21 * tile_set_width_) && (tile_map_[index] < 22 * tile_set_width_)) { + if ((tile_map_[index] >= 21 * tile_set_width_) && (tile_map_[index] < 22 * tile_set_width_)) { return TileType::SLOPE_R; } // La fila 22 es de tiles t_slope_l - else if ((tile_map_[index] >= 22 * tile_set_width_) && (tile_map_[index] < 23 * tile_set_width_)) { + if ((tile_map_[index] >= 22 * tile_set_width_) && (tile_map_[index] < 23 * tile_set_width_)) { return TileType::SLOPE_L; } diff --git a/source/game/gameplay/stats.cpp b/source/game/gameplay/stats.cpp index 9038148..3c139ff 100644 --- a/source/game/gameplay/stats.cpp +++ b/source/game/gameplay/stats.cpp @@ -75,10 +75,10 @@ void Stats::addVisit(const std::string& name) { } // Busca una entrada en la lista por nombre -int Stats::findByName(const std::string& name, const std::vector& list_) { +int Stats::findByName(const std::string& name, const std::vector& list) { int i = 0; - for (const auto& l : list_) { + for (const auto& l : list) { if (l.name == name) { return i; } @@ -89,8 +89,8 @@ int Stats::findByName(const std::string& name, const std::vector& lis } // Carga las estadisticas desde un fichero -bool Stats::loadFromFile(const std::string& file_path, std::vector& list_) { - list_.clear(); +bool Stats::loadFromFile(const std::string& file_path, std::vector& list) { + list.clear(); // Indicador de éxito en la carga bool success = true; @@ -121,7 +121,7 @@ bool Stats::loadFromFile(const std::string& file_path, std::vector& l getline(ss, tmp, ';'); stat.died = std::stoi(tmp); - list_.push_back(stat); + list.push_back(stat); } } @@ -132,20 +132,20 @@ bool Stats::loadFromFile(const std::string& file_path, std::vector& l // El fichero no existe else { // Crea el fichero con los valores por defecto - saveToFile(file_path, list_); + saveToFile(file_path, list); } return success; } // Guarda las estadisticas en un fichero -void Stats::saveToFile(const std::string& file_path, const std::vector& list_) { +void Stats::saveToFile(const std::string& file_path, const std::vector& list) { // Crea y abre el fichero de texto std::ofstream file(file_path); // Escribe en el fichero file << "# ROOM NAME;VISITS;DEATHS" << std::endl; - for (const auto& item : list_) { + for (const auto& item : list) { file << item.name << ";" << item.visited << ";" << item.died << std::endl; } diff --git a/source/game/gameplay/stats.hpp b/source/game/gameplay/stats.hpp index 3083e1f..2956d27 100644 --- a/source/game/gameplay/stats.hpp +++ b/source/game/gameplay/stats.hpp @@ -27,7 +27,7 @@ class Stats { static int findByName(const std::string& name, const std::vector& list); // Carga las estadisticas desde un fichero - bool loadFromFile(const std::string& file_path, std::vector& list); + static bool loadFromFile(const std::string& file_path, std::vector& list); // Guarda las estadisticas en un fichero static void saveToFile(const std::string& file_path, const std::vector& list); diff --git a/source/game/scenes/ending2.cpp b/source/game/scenes/ending2.cpp index 2c534a4..51a7024 100644 --- a/source/game/scenes/ending2.cpp +++ b/source/game/scenes/ending2.cpp @@ -304,28 +304,28 @@ void Ending2::updateTexts() { // Dibuja los sprites void Ending2::renderSprites() { - const Uint8 colorA = static_cast(PaletteColor::RED); + const Uint8 COLOR_A = static_cast(PaletteColor::RED); for (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) { - sprite->render(1, colorA); + sprite->render(1, COLOR_A); } } // Pinta el ultimo elemento de otro color - const Uint8 colorB = static_cast(PaletteColor::WHITE); - sprites_.back()->render(1, colorB); + const Uint8 COLOR_B = static_cast(PaletteColor::WHITE); + sprites_.back()->render(1, COLOR_B); } // Dibuja los sprites con el texto void Ending2::renderSpriteTexts() { - const Uint8 color = static_cast(PaletteColor::WHITE); + const Uint8 COLOR = static_cast(PaletteColor::WHITE); for (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) { - sprite->render(1, color); + sprite->render(1, COLOR); } } } @@ -345,7 +345,7 @@ void Ending2::renderTexts() { void Ending2::placeSprites() { for (int i = 0; i < static_cast(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::get()->getText("smb2")->getCharacterSize() + DIST_SPRITE_SPRITE) + Options::game.height + 40; + const float Y = ((i / 1) * (sprite_max_height_ + DIST_SPRITE_TEXT + Resource::get()->getText("smb2")->getCharacterSize() + DIST_SPRITE_SPRITE)) + Options::game.height + 40; const float W = sprites_.at(i)->getWidth(); const float H = sprites_.at(i)->getHeight(); const float DX = -(W / 2); @@ -357,7 +357,7 @@ void Ending2::placeSprites() { // Recoloca el sprite del jugador, que es el último de la lista const float X = (Options::game.width - sprites_.back()->getWidth()) / 2; - const float Y = sprites_.back()->getPosY() + sprite_max_height_ * 2; + const float Y = sprites_.back()->getPosY() + (sprite_max_height_ * 2); sprites_.back()->setPos(X, Y); sprites_.back()->setCurrentAnimation("walk"); } @@ -433,7 +433,7 @@ void Ending2::createTexts() { // Crea los últimos textos // El primer texto va a continuación del ultimo spriteText - const int START = sprite_texts_.back()->getPosY() + text->getCharacterSize() * 15; + const int START = sprite_texts_.back()->getPosY() + (text->getCharacterSize() * 15); list.clear(); list.push_back("THANK YOU"); list.push_back("FOR PLAYING!"); @@ -469,7 +469,7 @@ void Ending2::updateFinalFade() { } // Actualiza el volumen de la musica -void Ending2::updateMusicVolume() { +void Ending2::updateMusicVolume() const { // Constante para la duración en milisegundos constexpr Uint32 VOLUME_FADE_DURATION = 3000; diff --git a/source/game/scenes/ending2.hpp b/source/game/scenes/ending2.hpp index 8a993c6..25ddbe5 100644 --- a/source/game/scenes/ending2.hpp +++ b/source/game/scenes/ending2.hpp @@ -81,10 +81,10 @@ class Ending2 { void render(); // Comprueba el manejador de eventos - void checkEvents(); + static void checkEvents(); // Comprueba las entradas - void checkInput(); + static void checkInput(); // Actualiza el estado void updateState(); @@ -126,7 +126,7 @@ class Ending2 { void updateFinalFade(); // Actualiza el volumen de la musica - void updateMusicVolume(); + void updateMusicVolume() const; public: // Constructor diff --git a/source/game/scenes/game.cpp b/source/game/scenes/game.cpp index 3ad62ee..fa23609 100644 --- a/source/game/scenes/game.cpp +++ b/source/game/scenes/game.cpp @@ -180,9 +180,9 @@ void Game::render() { #ifdef _DEBUG // Pasa la información de debug void Game::updateDebugInfo() { - Debug::get()->add("X = " + std::to_string(static_cast(player_->x_)) + ", Y = " + std::to_string(static_cast(player_->y_))); - Debug::get()->add("VX = " + std::to_string(player_->vx_).substr(0, 4) + ", VY = " + std::to_string(player_->vy_).substr(0, 4)); - Debug::get()->add("STATE = " + std::to_string(static_cast(player_->state_))); + //Debug::get()->add("X = " + std::to_string(static_cast(player_->x_)) + ", Y = " + std::to_string(static_cast(player_->y_))); + //Debug::get()->add("VX = " + std::to_string(player_->vx_).substr(0, 4) + ", VY = " + std::to_string(player_->vy_).substr(0, 4)); + //Debug::get()->add("STATE = " + std::to_string(static_cast(player_->state_))); } // Pone la información de debug en pantalla @@ -216,7 +216,7 @@ void Game::renderDebugInfo() { // Comprueba los eventos void Game::checkDebugEvents(const SDL_Event& event) { - if (event.type == SDL_EVENT_KEY_DOWN && event.key.repeat == 0) { + if (event.type == SDL_EVENT_KEY_DOWN && static_cast(event.key.repeat) == 0) { switch (event.key.key) { case SDL_SCANCODE_G: Debug::get()->toggleEnabled(); diff --git a/source/game/scenes/game.hpp b/source/game/scenes/game.hpp index 0c08e1b..c106b6c 100644 --- a/source/game/scenes/game.hpp +++ b/source/game/scenes/game.hpp @@ -79,7 +79,7 @@ class Game { void updateDebugInfo(); // Pone la información de debug en pantalla - void renderDebugInfo(); + static void renderDebugInfo(); // Comprueba los eventos void checkDebugEvents(const SDL_Event& event); diff --git a/source/game/ui/notifier.cpp b/source/game/ui/notifier.cpp index 86fb197..25d63c1 100644 --- a/source/game/ui/notifier.cpp +++ b/source/game/ui/notifier.cpp @@ -54,8 +54,8 @@ void Notifier::update() { for (auto& notification : notifications_) { // Si la notificación anterior está "saliendo", no hagas nada if (!notifications_.empty() && ¬ification != ¬ifications_.front()) { - const auto& PREVIOUS_NOTIFICATION = *(std::prev(¬ification)); - if (PREVIOUS_NOTIFICATION.state == NotificationStatus::RISING) { + const auto& previous_notification = *(std::prev(¬ification)); + if (previous_notification.state == NotificationStatus::RISING) { break; } } @@ -135,13 +135,13 @@ void Notifier::show(std::vector texts, NotificationText text_is, Ui } // Inicializa variables - const int text_size = 6; - const auto PADDING_IN_H = text_size; - const auto PADDING_IN_V = text_size / 2; + const int TEXT_SIZE = 6; + const auto PADDING_IN_H = TEXT_SIZE; + const auto PADDING_IN_V = TEXT_SIZE / 2; const int ICON_SPACE = icon >= 0 ? ICON_SIZE + PADDING_IN_H : 0; text_is = ICON_SPACE > 0 ? NotificationText::LEFT : text_is; const float WIDTH = Options::game.width - (PADDING_OUT * 2); - const float HEIGHT = (text_size * texts.size()) + (PADDING_IN_V * 2); + const float HEIGHT = (TEXT_SIZE * texts.size()) + (PADDING_IN_V * 2); const auto SHAPE = NotificationShape::SQUARED; // Posición horizontal @@ -170,7 +170,7 @@ void Notifier::show(std::vector texts, NotificationText text_is, Ui // Offset const auto TRAVEL_DIST = HEIGHT + PADDING_OUT; const int TRAVEL_MOD = (Options::notifications.getVerticalPosition() == Options::NotificationPosition::TOP) ? 1 : -1; - const int OFFSET = !notifications_.empty() ? notifications_.back().y + TRAVEL_MOD * notifications_.back().travel_dist : DESP_V; + const int OFFSET = !notifications_.empty() ? notifications_.back().y + (TRAVEL_MOD * notifications_.back().travel_dist) : DESP_V; // Crea la notificacion Notification n; @@ -229,10 +229,10 @@ void Notifier::show(std::vector texts, NotificationText text_is, Ui for (const auto& text : texts) { switch (text_is) { case NotificationText::LEFT: - text_->writeColored(PADDING_IN_H + ICON_SPACE, PADDING_IN_V + iterator * (text_size + 1), text, COLOR); + text_->writeColored(PADDING_IN_H + ICON_SPACE, PADDING_IN_V + (iterator * (TEXT_SIZE + 1)), text, COLOR); break; case NotificationText::CENTER: - text_->writeDX(TEXT_CENTER | TEXT_COLOR, WIDTH / 2, PADDING_IN_V + iterator * (text_size + 1), text, 1, COLOR); + text_->writeDX(TEXT_CENTER | TEXT_COLOR, WIDTH / 2, PADDING_IN_V + (iterator * (TEXT_SIZE + 1)), text, 1, COLOR); break; default: break; diff --git a/source/utils/utils.cpp b/source/utils/utils.cpp index a71b976..6604bf2 100644 --- a/source/utils/utils.cpp +++ b/source/utils/utils.cpp @@ -42,29 +42,29 @@ bool checkCollision(const Circle& a, const Circle& b) { bool checkCollision(const Circle& a, const SDL_FRect& rect) { SDL_Rect b = toSDLRect(rect); // Closest point on collision box - int cX; - int cY; + int c_x; + int c_y; // Find closest x offset if (a.x < b.x) { - cX = b.x; + c_x = b.x; } else if (a.x > b.x + b.w) { - cX = b.x + b.w; + c_x = b.x + b.w; } else { - cX = a.x; + c_x = a.x; } // Find closest y offset if (a.y < b.y) { - cY = b.y; + c_y = b.y; } else if (a.y > b.y + b.h) { - cY = b.y + b.h; + c_y = b.y + b.h; } else { - cY = a.y; + c_y = a.y; } // If the closest point is inside the circle_t - if (distanceSquared(a.x, a.y, cX, cY) < a.r * a.r) { + if (distanceSquared(a.x, a.y, c_x, c_y) < a.r * a.r) { // This box and the circle_t have collided return true; }