Compare commits
5 Commits
2026.05.17
...
02bc4de6d5
| Author | SHA1 | Date | |
|---|---|---|---|
| 02bc4de6d5 | |||
| 5349c60c39 | |||
| 25a6832351 | |||
| 28fc8456e0 | |||
| 6b6d5f1f6d |
+2
-2
@@ -232,7 +232,7 @@ target_link_libraries(${PROJECT_NAME} PRIVATE SDL3::SDL3)
|
||||
|
||||
# --- 4. CONFIGURACIÓN PLATAFORMAS Y COMPILADOR ---
|
||||
# Configuración de flags de compilación
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE -Wall)
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic)
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE $<$<CONFIG:RELEASE>:-Os -ffunction-sections -fdata-sections>)
|
||||
|
||||
# Definir _DEBUG en modo Debug
|
||||
@@ -393,7 +393,7 @@ if(NOT EMSCRIPTEN)
|
||||
source/core/resources/resource_pack.cpp
|
||||
)
|
||||
target_include_directories(pack_resources PRIVATE "${CMAKE_SOURCE_DIR}/source")
|
||||
target_compile_options(pack_resources PRIVATE -Wall)
|
||||
target_compile_options(pack_resources PRIVATE -Wall -Wextra -Wpedantic)
|
||||
|
||||
# Regeneració automàtica de resources.pack en cada build si canvia data/.
|
||||
file(GLOB_RECURSE DATA_FILES CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/data/*")
|
||||
|
||||
@@ -64,7 +64,7 @@ class GamepadConfigManager {
|
||||
// Escribir al archivo
|
||||
std::ofstream file(filename);
|
||||
if (!file.is_open()) {
|
||||
return false; // NOLINT(readability-simplify-boolean-expr)
|
||||
return false;
|
||||
}
|
||||
|
||||
file << j.dump(4); // Formato con indentación de 4 espacios
|
||||
@@ -92,7 +92,7 @@ class GamepadConfigManager {
|
||||
configs.clear();
|
||||
|
||||
if (!j.contains("gamepads") || !j["gamepads"].is_array()) {
|
||||
return false; // NOLINT(readability-simplify-boolean-expr)
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const auto& gamepad_json : j["gamepads"]) {
|
||||
|
||||
@@ -20,11 +20,11 @@ class PauseManager {
|
||||
|
||||
// --- Operadores friend ---
|
||||
friend auto operator|(Source a, Source b) -> Source {
|
||||
return static_cast<Source>(static_cast<uint8_t>(a) | static_cast<uint8_t>(b)); // NOLINT(readability-redundant-casting)
|
||||
return static_cast<Source>(static_cast<uint8_t>(a) | static_cast<uint8_t>(b));
|
||||
}
|
||||
|
||||
friend auto operator&(Source a, Source b) -> Source {
|
||||
return static_cast<Source>(static_cast<uint8_t>(a) & static_cast<uint8_t>(b)); // NOLINT(readability-redundant-casting)
|
||||
return static_cast<Source>(static_cast<uint8_t>(a) & static_cast<uint8_t>(b));
|
||||
}
|
||||
|
||||
friend auto operator~(Source a) -> uint8_t {
|
||||
|
||||
@@ -83,11 +83,11 @@ void Background::initializeSprites() {
|
||||
const float TOP_CLOUDS_Y = base_ - 165;
|
||||
const float BOTTOM_CLOUDS_Y = base_ - 101;
|
||||
|
||||
top_clouds_sprite_a_ = std::make_unique<MovingSprite>(top_clouds_texture_, (SDL_FRect){.x = 0, .y = TOP_CLOUDS_Y, .w = rect_.w, .h = static_cast<float>(top_clouds_texture_->getHeight())});
|
||||
top_clouds_sprite_b_ = std::make_unique<MovingSprite>(top_clouds_texture_, (SDL_FRect){.x = rect_.w, .y = TOP_CLOUDS_Y, .w = rect_.w, .h = static_cast<float>(top_clouds_texture_->getHeight())});
|
||||
top_clouds_sprite_a_ = std::make_unique<MovingSprite>(top_clouds_texture_, SDL_FRect{.x = 0, .y = TOP_CLOUDS_Y, .w = rect_.w, .h = static_cast<float>(top_clouds_texture_->getHeight())});
|
||||
top_clouds_sprite_b_ = std::make_unique<MovingSprite>(top_clouds_texture_, SDL_FRect{.x = rect_.w, .y = TOP_CLOUDS_Y, .w = rect_.w, .h = static_cast<float>(top_clouds_texture_->getHeight())});
|
||||
|
||||
bottom_clouds_sprite_a_ = std::make_unique<MovingSprite>(bottom_clouds_texture_, (SDL_FRect){.x = 0, .y = BOTTOM_CLOUDS_Y, .w = rect_.w, .h = static_cast<float>(bottom_clouds_texture_->getHeight())});
|
||||
bottom_clouds_sprite_b_ = std::make_unique<MovingSprite>(bottom_clouds_texture_, (SDL_FRect){.x = rect_.w, .y = BOTTOM_CLOUDS_Y, .w = rect_.w, .h = static_cast<float>(bottom_clouds_texture_->getHeight())});
|
||||
bottom_clouds_sprite_a_ = std::make_unique<MovingSprite>(bottom_clouds_texture_, SDL_FRect{.x = 0, .y = BOTTOM_CLOUDS_Y, .w = rect_.w, .h = static_cast<float>(bottom_clouds_texture_->getHeight())});
|
||||
bottom_clouds_sprite_b_ = std::make_unique<MovingSprite>(bottom_clouds_texture_, SDL_FRect{.x = rect_.w, .y = BOTTOM_CLOUDS_Y, .w = rect_.w, .h = static_cast<float>(bottom_clouds_texture_->getHeight())});
|
||||
|
||||
buildings_sprite_ = std::make_unique<Sprite>(buildings_texture_);
|
||||
gradient_sprite_ = std::make_unique<Sprite>(gradients_texture_, 0, 0, rect_.w, rect_.h);
|
||||
|
||||
@@ -68,7 +68,7 @@ void Fade::render() {
|
||||
}
|
||||
|
||||
// Actualiza las variables internas
|
||||
void Fade::update(float delta_time) {
|
||||
void Fade::update(float /*delta_time*/) {
|
||||
switch (state_) {
|
||||
case State::PRE:
|
||||
updatePreState();
|
||||
|
||||
@@ -141,7 +141,7 @@ namespace GIF {
|
||||
}
|
||||
|
||||
// Procesa el Image Descriptor y retorna el vector de datos sin comprimir.
|
||||
auto processImageDescriptor(const uint8_t *&buffer, const std::vector<RGB> &gct, int resolution_bits) -> std::vector<uint8_t> {
|
||||
auto processImageDescriptor(const uint8_t *&buffer, const std::vector<RGB> & /*gct*/, int /*resolution_bits*/) -> std::vector<uint8_t> {
|
||||
ImageDescriptor image_descriptor;
|
||||
readBytes(buffer, &image_descriptor, sizeof(ImageDescriptor));
|
||||
|
||||
|
||||
@@ -218,7 +218,7 @@ void Screen::handleCanvasResized() {
|
||||
|
||||
// Registra los callbacks nativos de Emscripten que restauran el canvas cuando
|
||||
// SDL3 no emite los events equivalentes. Fuera de Emscripten es un no-op.
|
||||
void Screen::registerEmscriptenEventCallbacks() { // NOLINT(readability-convert-member-functions-to-static)
|
||||
void Screen::registerEmscriptenEventCallbacks() {
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_set_fullscreenchange_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, nullptr, EM_TRUE, onEmFullscreenChange);
|
||||
emscripten_set_orientationchange_callback(nullptr, EM_TRUE, onEmOrientationChange);
|
||||
|
||||
@@ -429,7 +429,7 @@ namespace Rendering {
|
||||
return shader;
|
||||
}
|
||||
|
||||
auto SDL3GPUShader::createShaderSPIRV(SDL_GPUDevice* device, // NOLINT(readability-convert-member-functions-to-static)
|
||||
auto SDL3GPUShader::createShaderSPIRV(SDL_GPUDevice* device,
|
||||
const uint8_t* spv_code,
|
||||
size_t spv_size,
|
||||
const char* entrypoint,
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace Rendering {
|
||||
const std::string& fragment_source) -> bool override;
|
||||
|
||||
void render() override;
|
||||
void setTextureSize(float width, float height) override {}
|
||||
void setTextureSize(float /*width*/, float /*height*/) override {}
|
||||
void cleanup() final;
|
||||
void destroy();
|
||||
[[nodiscard]] auto isHardwareAccelerated() const -> bool override { return is_initialized_; }
|
||||
@@ -117,8 +117,40 @@ namespace Rendering {
|
||||
SDL_GPUTransferBuffer* upload_buffer_ = nullptr;
|
||||
SDL_GPUSampler* sampler_ = nullptr;
|
||||
|
||||
PostFXUniforms uniforms_{.vignette_strength = 0.6F, .chroma_min = 0.15F, .scanline_strength = 0.7F, .screen_height = 192.0F, .pixel_scale = 1.0F, .chroma_max = 0.15F, .scan_dark_ratio = 0.333F, .scan_dark_floor = 0.42F, .scan_edge_soft = 1.0F};
|
||||
CrtPiUniforms crtpi_uniforms_{.scanline_weight = 6.0F, .scanline_gap_brightness = 0.12F, .bloom_factor = 3.5F, .input_gamma = 2.4F, .output_gamma = 2.2F, .mask_brightness = 0.80F, .curvature_x = 0.05F, .curvature_y = 0.10F, .mask_type = 2, .enable_scanlines = 1, .enable_multisample = 1, .enable_gamma = 1};
|
||||
PostFXUniforms uniforms_{
|
||||
.vignette_strength = 0.6F,
|
||||
.chroma_min = 0.15F,
|
||||
.scanline_strength = 0.7F,
|
||||
.screen_height = 192.0F,
|
||||
.mask_strength = 0.0F,
|
||||
.gamma_strength = 0.0F,
|
||||
.curvature = 0.0F,
|
||||
.bleeding = 0.0F,
|
||||
.pixel_scale = 1.0F,
|
||||
.time = 0.0F,
|
||||
.flicker = 0.0F,
|
||||
.chroma_max = 0.15F,
|
||||
.scan_dark_ratio = 0.333F,
|
||||
.scan_dark_floor = 0.42F,
|
||||
.scan_edge_soft = 1.0F,
|
||||
.pad3 = 0.0F};
|
||||
CrtPiUniforms crtpi_uniforms_{
|
||||
.scanline_weight = 6.0F,
|
||||
.scanline_gap_brightness = 0.12F,
|
||||
.bloom_factor = 3.5F,
|
||||
.input_gamma = 2.4F,
|
||||
.output_gamma = 2.2F,
|
||||
.mask_brightness = 0.80F,
|
||||
.curvature_x = 0.05F,
|
||||
.curvature_y = 0.10F,
|
||||
.mask_type = 2,
|
||||
.enable_scanlines = 1,
|
||||
.enable_multisample = 1,
|
||||
.enable_gamma = 1,
|
||||
.enable_curvature = 0,
|
||||
.enable_sharper = 0,
|
||||
.texture_width = 0.0F,
|
||||
.texture_height = 0.0F};
|
||||
ShaderType active_shader_ = ShaderType::POSTFX;
|
||||
|
||||
int game_width_ = 0;
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
// Constructor
|
||||
Sprite::Sprite(std::shared_ptr<Texture> texture, float pos_x, float pos_y, float width, float height)
|
||||
: textures_{std::move(texture)},
|
||||
pos_((SDL_FRect){.x = pos_x, .y = pos_y, .w = width, .h = height}),
|
||||
sprite_clip_((SDL_FRect){.x = 0, .y = 0, .w = pos_.w, .h = pos_.h}) {}
|
||||
pos_(SDL_FRect{.x = pos_x, .y = pos_y, .w = width, .h = height}),
|
||||
sprite_clip_(SDL_FRect{.x = 0, .y = 0, .w = pos_.w, .h = pos_.h}) {}
|
||||
|
||||
Sprite::Sprite(std::shared_ptr<Texture> texture, SDL_FRect rect)
|
||||
: textures_{std::move(texture)},
|
||||
pos_(rect),
|
||||
sprite_clip_((SDL_FRect){.x = 0, .y = 0, .w = pos_.w, .h = pos_.h}) {}
|
||||
sprite_clip_(SDL_FRect{.x = 0, .y = 0, .w = pos_.w, .h = pos_.h}) {}
|
||||
|
||||
Sprite::Sprite(std::shared_ptr<Texture> texture)
|
||||
: textures_{std::move(texture)},
|
||||
|
||||
@@ -32,7 +32,7 @@ Text::Text(const std::shared_ptr<Texture>& texture, const std::string& text_file
|
||||
}
|
||||
|
||||
// Crea los objetos
|
||||
sprite_ = std::make_unique<Sprite>(texture, (SDL_FRect){.x = 0, .y = 0, .w = static_cast<float>(box_width_), .h = static_cast<float>(box_height_)});
|
||||
sprite_ = std::make_unique<Sprite>(texture, SDL_FRect{.x = 0, .y = 0, .w = static_cast<float>(box_width_), .h = static_cast<float>(box_height_)});
|
||||
|
||||
// Inicializa variables
|
||||
fixed_width_ = false;
|
||||
@@ -50,7 +50,7 @@ Text::Text(const std::shared_ptr<Texture>& texture, const std::shared_ptr<Text::
|
||||
}
|
||||
|
||||
// Crea los objetos
|
||||
sprite_ = std::make_unique<Sprite>(texture, (SDL_FRect){.x = 0, .y = 0, .w = static_cast<float>(box_width_), .h = static_cast<float>(box_height_)});
|
||||
sprite_ = std::make_unique<Sprite>(texture, SDL_FRect{.x = 0, .y = 0, .w = static_cast<float>(box_width_), .h = static_cast<float>(box_height_)});
|
||||
|
||||
// Inicializa variables
|
||||
fixed_width_ = false;
|
||||
@@ -71,8 +71,8 @@ Text::Text(const std::shared_ptr<Texture>& texture, const std::shared_ptr<Textur
|
||||
}
|
||||
|
||||
// Crea los objetos
|
||||
sprite_ = std::make_unique<Sprite>(texture, (SDL_FRect){.x = 0, .y = 0, .w = static_cast<float>(box_width_), .h = static_cast<float>(box_height_)});
|
||||
white_sprite_ = std::make_unique<Sprite>(white_texture, (SDL_FRect){.x = 0, .y = 0, .w = static_cast<float>(box_width_), .h = static_cast<float>(box_height_)});
|
||||
sprite_ = std::make_unique<Sprite>(texture, SDL_FRect{.x = 0, .y = 0, .w = static_cast<float>(box_width_), .h = static_cast<float>(box_height_)});
|
||||
white_sprite_ = std::make_unique<Sprite>(white_texture, SDL_FRect{.x = 0, .y = 0, .w = static_cast<float>(box_width_), .h = static_cast<float>(box_height_)});
|
||||
|
||||
// Inicializa variables
|
||||
fixed_width_ = false;
|
||||
@@ -90,8 +90,8 @@ Text::Text(const std::shared_ptr<Texture>& texture, const std::shared_ptr<Textur
|
||||
}
|
||||
|
||||
// Crea los objetos
|
||||
sprite_ = std::make_unique<Sprite>(texture, (SDL_FRect){.x = 0, .y = 0, .w = static_cast<float>(box_width_), .h = static_cast<float>(box_height_)});
|
||||
white_sprite_ = std::make_unique<Sprite>(white_texture, (SDL_FRect){.x = 0, .y = 0, .w = static_cast<float>(box_width_), .h = static_cast<float>(box_height_)});
|
||||
sprite_ = std::make_unique<Sprite>(texture, SDL_FRect{.x = 0, .y = 0, .w = static_cast<float>(box_width_), .h = static_cast<float>(box_height_)});
|
||||
white_sprite_ = std::make_unique<Sprite>(white_texture, SDL_FRect{.x = 0, .y = 0, .w = static_cast<float>(box_width_), .h = static_cast<float>(box_height_)});
|
||||
|
||||
// Inicializa variables
|
||||
fixed_width_ = false;
|
||||
@@ -137,7 +137,7 @@ void Text::write2X(int x, int y, const std::string& text, int kerning, int lengt
|
||||
}
|
||||
|
||||
// Escribe el texto en una textura
|
||||
auto Text::writeToTexture(const std::string& text, int zoom, int kerning, int length) -> std::shared_ptr<Texture> {
|
||||
auto Text::writeToTexture(const std::string& text, int zoom, int kerning, int /*length*/) -> std::shared_ptr<Texture> {
|
||||
auto* renderer = Screen::get()->getRenderer();
|
||||
auto texture = std::make_shared<Texture>(renderer);
|
||||
auto width = Text::length(text, kerning) * zoom;
|
||||
@@ -342,7 +342,7 @@ void Text::writeDX(Uint8 flags, int x, int y, const std::string& text, int kerni
|
||||
}
|
||||
|
||||
// Escribe texto a partir de un TextStyle
|
||||
void Text::writeStyle(int x, int y, const std::string& text, const Style& style, int length) {
|
||||
void Text::writeStyle(int x, int y, const std::string& text, const Style& style, int /*length*/) {
|
||||
writeDX(style.flags, x, y, text, style.kerning, style.text_color, style.shadow_distance, style.shadow_color);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <SDL3/SDL.h> // Para SDL_LogError, SDL_LogCategory, Uint8, SDL_...
|
||||
|
||||
#include <cstdint> // Para uint32_t
|
||||
#include <cstring> // Para memcpy
|
||||
#include <fstream> // Para basic_ifstream, basic_istream, basic_ios
|
||||
#include <iostream> // Para std::cout
|
||||
#include <sstream> // Para basic_istringstream
|
||||
@@ -259,12 +258,7 @@ auto Texture::loadSurface(const std::string& file_path) -> std::shared_ptr<Surfa
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Si el constructor de Surface espera un std::shared_ptr<Uint8[]>:
|
||||
size_t pixel_count = raw_pixels.size();
|
||||
auto pixels = std::shared_ptr<Uint8[]>(new Uint8[pixel_count], std::default_delete<Uint8[]>()); // NOLINT(modernize-avoid-c-arrays)
|
||||
std::memcpy(pixels.get(), raw_pixels.data(), pixel_count);
|
||||
|
||||
auto surface = std::make_shared<Surface>(w, h, pixels);
|
||||
auto surface = std::make_shared<Surface>(w, h, std::move(raw_pixels));
|
||||
|
||||
// Actualizar las dimensiones
|
||||
width_ = w;
|
||||
|
||||
@@ -16,11 +16,11 @@ using Palette = std::array<Uint32, 256>;
|
||||
|
||||
// Definición de Surface para imágenes con paleta
|
||||
struct Surface {
|
||||
std::shared_ptr<Uint8[]> data; // NOLINT(modernize-avoid-c-arrays)
|
||||
std::vector<Uint8> data;
|
||||
Uint16 w, h;
|
||||
|
||||
// Constructor
|
||||
Surface(Uint16 width, Uint16 height, std::shared_ptr<Uint8[]> pixels) // NOLINT(modernize-avoid-c-arrays)
|
||||
Surface(Uint16 width, Uint16 height, std::vector<Uint8> pixels)
|
||||
: data(std::move(pixels)),
|
||||
w(width),
|
||||
h(height) {}
|
||||
|
||||
@@ -50,7 +50,7 @@ TiledBG::~TiledBG() {
|
||||
// Rellena la textura con el contenido
|
||||
void TiledBG::fillTexture() {
|
||||
// Crea los objetos para pintar en la textura de fondo
|
||||
auto tile = std::make_unique<Sprite>(Resource::get()->getTexture("title_bg_tile.png"), (SDL_FRect){.x = 0, .y = 0, .w = TILE_WIDTH, .h = TILE_HEIGHT});
|
||||
auto tile = std::make_unique<Sprite>(Resource::get()->getTexture("title_bg_tile.png"), SDL_FRect{.x = 0, .y = 0, .w = TILE_WIDTH, .h = TILE_HEIGHT});
|
||||
|
||||
// Prepara para dibujar sobre la textura
|
||||
auto* temp = SDL_GetRenderTarget(renderer_);
|
||||
|
||||
@@ -155,7 +155,7 @@ auto ResourcePack::addFile(const std::string& filename, const std::string& filep
|
||||
auto ResourcePack::addDirectory(const std::string& directory) -> bool {
|
||||
if (!std::filesystem::exists(directory)) {
|
||||
std::cerr << "Error: Directory does not exist: " << directory << '\n';
|
||||
return false; // NOLINT(readability-simplify-boolean-expr)
|
||||
return false;
|
||||
}
|
||||
|
||||
return std::ranges::all_of(std::filesystem::recursive_directory_iterator(directory),
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace SystemShutdown {
|
||||
return shutdownSystem(config);
|
||||
}
|
||||
|
||||
auto shutdownSystem(const ShutdownConfig& config) -> ShutdownResult {
|
||||
auto shutdownSystem([[maybe_unused]] const ShutdownConfig& config) -> ShutdownResult {
|
||||
#ifdef _WIN32
|
||||
// Windows: Usar CreateProcess
|
||||
STARTUPINFOA si = {0};
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace SystemUtils {
|
||||
|
||||
// Función auxiliar para crear una carpeta individual
|
||||
auto createSingleFolder(const std::string& path, int permissions) -> Result {
|
||||
struct stat st = {.st_dev = 0};
|
||||
struct stat st{};
|
||||
|
||||
// Verificar si ya existe
|
||||
if (stat(path.c_str(), &st) == 0) {
|
||||
@@ -131,7 +131,7 @@ namespace SystemUtils {
|
||||
}
|
||||
|
||||
auto folderExists(const std::string& path) -> bool {
|
||||
struct stat st = {.st_dev = 0};
|
||||
struct stat st{};
|
||||
return (stat(path.c_str(), &st) == 0 && S_ISDIR(st.st_mode));
|
||||
}
|
||||
|
||||
|
||||
@@ -890,7 +890,7 @@ void Player::shiftColliders() {
|
||||
}
|
||||
|
||||
// Pone las texturas del jugador
|
||||
void Player::setPlayerTextures(const std::vector<std::shared_ptr<Texture>>& texture) { // NOLINT(readability-named-parameter)
|
||||
void Player::setPlayerTextures(const std::vector<std::shared_ptr<Texture>>& texture) {
|
||||
player_sprite_->setTexture(texture[0]);
|
||||
power_sprite_->setTexture(texture[1]);
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ class Player {
|
||||
void setAnimation(float delta_time); // Establece la animación según el estado (time-based)
|
||||
|
||||
// --- Texturas y animaciones ---
|
||||
void setPlayerTextures(const std::vector<std::shared_ptr<Texture>>& texture); // NOLINT(readability-avoid-const-params-in-decls) Cambia las texturas del jugador
|
||||
void setPlayerTextures(const std::vector<std::shared_ptr<Texture>>& texture);
|
||||
|
||||
// --- Gameplay: Puntuación y power-ups ---
|
||||
void addScore(int score, int lowest_hi_score_entry); // Añade puntos
|
||||
|
||||
@@ -114,7 +114,9 @@ void BalloonManager::deployRandomFormation(int stage) {
|
||||
.size = balloon.size,
|
||||
.vel_x = balloon.vel_x,
|
||||
.game_tempo = balloon_speed_,
|
||||
.creation_counter = creation_time_enabled_ ? balloon.creation_counter : 0.0F};
|
||||
.creation_counter = creation_time_enabled_ ? balloon.creation_counter : 0.0F,
|
||||
.animation = {},
|
||||
.sound = {}};
|
||||
createBalloon(config);
|
||||
}
|
||||
|
||||
@@ -135,7 +137,9 @@ void BalloonManager::deployFormation(int formation_id) {
|
||||
.size = balloon.size,
|
||||
.vel_x = balloon.vel_x,
|
||||
.game_tempo = balloon_speed_,
|
||||
.creation_counter = balloon.creation_counter};
|
||||
.creation_counter = balloon.creation_counter,
|
||||
.animation = {},
|
||||
.sound = {}};
|
||||
createBalloon(config);
|
||||
}
|
||||
}
|
||||
@@ -151,7 +155,9 @@ void BalloonManager::deployFormation(int formation_id, float y) {
|
||||
.size = balloon.size,
|
||||
.vel_x = balloon.vel_x,
|
||||
.game_tempo = balloon_speed_,
|
||||
.creation_counter = balloon.creation_counter};
|
||||
.creation_counter = balloon.creation_counter,
|
||||
.animation = {},
|
||||
.sound = {}};
|
||||
createBalloon(config);
|
||||
}
|
||||
}
|
||||
@@ -213,7 +219,9 @@ void BalloonManager::createChildBalloon(const std::shared_ptr<Balloon>& parent_b
|
||||
.size = static_cast<Balloon::Size>(static_cast<int>(parent_balloon->getSize()) - 1),
|
||||
.vel_x = direction == "LEFT" ? Balloon::VELX_NEGATIVE : Balloon::VELX_POSITIVE,
|
||||
.game_tempo = balloon_speed_,
|
||||
.creation_counter = 0};
|
||||
.creation_counter = 0,
|
||||
.animation = {},
|
||||
.sound = {}};
|
||||
|
||||
// Crea el globo hijo
|
||||
auto child_balloon = createBalloon(config);
|
||||
@@ -267,6 +275,8 @@ void BalloonManager::createPowerBall() {
|
||||
.texture = balloon_textures_.at(4),
|
||||
.animation = balloon_animations_.at(4),
|
||||
.sound = {
|
||||
.bouncing_file = {},
|
||||
.popping_file = {},
|
||||
.bouncing_enabled = bouncing_sound_enabled_,
|
||||
.poping_enabled = poping_sound_enabled_,
|
||||
.enabled = sound_enabled_}};
|
||||
|
||||
@@ -679,7 +679,7 @@ namespace Options {
|
||||
// --- PRIMERA PASADA: Intenta asignar mandos basándose en la ruta guardada ---
|
||||
void GamepadManager::assignGamepadsByPath(
|
||||
const std::array<std::string, MAX_PLAYERS>& desired_paths,
|
||||
const std::vector<std::shared_ptr<Input::Gamepad>>& physical_gamepads, // NOLINT(readability-named-parameter)
|
||||
const std::vector<std::shared_ptr<Input::Gamepad>>& physical_gamepads,
|
||||
std::vector<std::shared_ptr<Input::Gamepad>>& assigned_instances) {
|
||||
for (size_t i = 0; i < MAX_PLAYERS; ++i) {
|
||||
const std::string& desired_path = desired_paths[i];
|
||||
@@ -705,7 +705,7 @@ namespace Options {
|
||||
// refrescamos el path guardado al del dispositivo físico actual.
|
||||
void GamepadManager::assignGamepadsByName(
|
||||
const std::array<std::string, MAX_PLAYERS>& desired_names,
|
||||
const std::vector<std::shared_ptr<Input::Gamepad>>& physical_gamepads, // NOLINT(readability-named-parameter)
|
||||
const std::vector<std::shared_ptr<Input::Gamepad>>& physical_gamepads,
|
||||
std::vector<std::shared_ptr<Input::Gamepad>>& assigned_instances) {
|
||||
for (size_t i = 0; i < MAX_PLAYERS; ++i) {
|
||||
if (gamepads_[i].instance != nullptr) {
|
||||
@@ -731,7 +731,7 @@ namespace Options {
|
||||
|
||||
// --- TERCERA PASADA: Asigna los mandos físicos restantes a los jugadores libres ---
|
||||
void GamepadManager::assignRemainingGamepads(
|
||||
const std::vector<std::shared_ptr<Input::Gamepad>>& physical_gamepads, // NOLINT(readability-named-parameter)
|
||||
const std::vector<std::shared_ptr<Input::Gamepad>>& physical_gamepads,
|
||||
std::vector<std::shared_ptr<Input::Gamepad>>& assigned_instances) {
|
||||
for (size_t i = 0; i < MAX_PLAYERS; ++i) {
|
||||
if (gamepads_[i].instance != nullptr) {
|
||||
@@ -763,7 +763,7 @@ namespace Options {
|
||||
|
||||
auto GamepadManager::isGamepadAssigned(
|
||||
const std::shared_ptr<Input::Gamepad>& physical_gamepad,
|
||||
const std::vector<std::shared_ptr<Input::Gamepad>>& assigned_instances) -> bool { // NOLINT(readability-named-parameter)
|
||||
const std::vector<std::shared_ptr<Input::Gamepad>>& assigned_instances) -> bool {
|
||||
return std::ranges::any_of(assigned_instances,
|
||||
[&physical_gamepad](const auto& assigned) -> auto {
|
||||
return assigned == physical_gamepad;
|
||||
|
||||
@@ -262,7 +262,7 @@ namespace Options {
|
||||
void clearPlayers() { players_.clear(); } // Limpia la lista de jugadores
|
||||
|
||||
// Asigna el mando a un jugador
|
||||
void assignTo(const Input::Gamepad& gamepad, Player::Id player_id) {
|
||||
void assignTo(const Input::Gamepad& /*gamepad*/, Player::Id /*player_id*/) {
|
||||
}
|
||||
|
||||
// Asigna los mandos físicos basándose en la configuración actual de nombres.
|
||||
@@ -296,19 +296,19 @@ namespace Options {
|
||||
|
||||
void assignGamepadsByPath(
|
||||
const std::array<std::string, MAX_PLAYERS>& desired_paths,
|
||||
const std::vector<std::shared_ptr<Input::Gamepad>>& physical_gamepads, // NOLINT(readability-avoid-const-params-in-decls)
|
||||
const std::vector<std::shared_ptr<Input::Gamepad>>& physical_gamepads,
|
||||
std::vector<std::shared_ptr<Input::Gamepad>>& assigned_instances);
|
||||
void assignGamepadsByName(
|
||||
const std::array<std::string, MAX_PLAYERS>& desired_names,
|
||||
const std::vector<std::shared_ptr<Input::Gamepad>>& physical_gamepads, // NOLINT(readability-avoid-const-params-in-decls)
|
||||
const std::vector<std::shared_ptr<Input::Gamepad>>& physical_gamepads,
|
||||
std::vector<std::shared_ptr<Input::Gamepad>>& assigned_instances);
|
||||
void assignRemainingGamepads(
|
||||
const std::vector<std::shared_ptr<Input::Gamepad>>& physical_gamepads, // NOLINT(readability-avoid-const-params-in-decls)
|
||||
const std::vector<std::shared_ptr<Input::Gamepad>>& physical_gamepads,
|
||||
std::vector<std::shared_ptr<Input::Gamepad>>& assigned_instances);
|
||||
void clearUnassignedGamepadSlots();
|
||||
[[nodiscard]] static auto isGamepadAssigned(
|
||||
const std::shared_ptr<Input::Gamepad>& physical_gamepad,
|
||||
const std::vector<std::shared_ptr<Input::Gamepad>>& assigned_instances) -> bool; // NOLINT(readability-avoid-const-params-in-decls)
|
||||
const std::vector<std::shared_ptr<Input::Gamepad>>& assigned_instances) -> bool;
|
||||
};
|
||||
|
||||
struct Keyboard {
|
||||
|
||||
@@ -800,7 +800,7 @@ void Game::renderPathSprites() {
|
||||
}
|
||||
|
||||
// Acciones a realizar cuando el jugador colisiona con un globo
|
||||
void Game::handlePlayerCollision(std::shared_ptr<Player>& player, const std::shared_ptr<Balloon>& balloon) {
|
||||
void Game::handlePlayerCollision(std::shared_ptr<Player>& player, const std::shared_ptr<Balloon>& /*balloon*/) {
|
||||
if (!player->isPlaying() || player->isInvulnerable()) {
|
||||
return; // Si no está jugando o tiene inmunidad, no hace nada
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ void Instructions::iniSprites() {
|
||||
// Inicializa los sprites
|
||||
for (int i = 0; std::cmp_less(i, item_textures_.size()); ++i) {
|
||||
auto sprite = std::make_unique<Sprite>(item_textures_[i], 0, 0, Item::WIDTH, Item::HEIGHT);
|
||||
sprite->setPosition((SDL_FPoint){.x = sprite_pos_.x, .y = sprite_pos_.y + ((Item::HEIGHT + item_space_) * i)});
|
||||
sprite->setPosition(SDL_FPoint{.x = sprite_pos_.x, .y = sprite_pos_.y + ((Item::HEIGHT + item_space_) * i)});
|
||||
sprites_.push_back(std::move(sprite));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,11 +39,11 @@ class MenuOption {
|
||||
|
||||
[[nodiscard]] virtual auto getBehavior() const -> Behavior = 0;
|
||||
[[nodiscard]] virtual auto getValueAsString() const -> std::string { return ""; }
|
||||
virtual void adjustValue(bool adjust_up) {}
|
||||
virtual void adjustValue(bool /*adjust_up*/) {}
|
||||
[[nodiscard]] virtual auto getTargetGroup() const -> ServiceMenu::SettingsGroup { return ServiceMenu::SettingsGroup::MAIN; }
|
||||
virtual void executeAction() {}
|
||||
|
||||
virtual auto getMaxValueWidth(Text* text_renderer) const -> int { return 0; } // Método virtual para que cada opción calcule el ancho de su valor más largo
|
||||
virtual auto getMaxValueWidth(Text* /*text_renderer*/) const -> int { return 0; } // Método virtual para que cada opción calcule el ancho de su valor más largo
|
||||
|
||||
protected:
|
||||
// --- Variables ---
|
||||
|
||||
@@ -45,7 +45,7 @@ void MenuRenderer::ShowHideAnimation::stop() {
|
||||
elapsed = 0.0F;
|
||||
}
|
||||
|
||||
MenuRenderer::MenuRenderer(const ServiceMenu* menu_state, std::shared_ptr<Text> element_text, std::shared_ptr<Text> title_text)
|
||||
MenuRenderer::MenuRenderer(const ServiceMenu* /*menu_state*/, std::shared_ptr<Text> element_text, std::shared_ptr<Text> title_text)
|
||||
: element_text_(std::move(element_text)),
|
||||
title_text_(std::move(title_text)) {
|
||||
initializeMaxSizes();
|
||||
@@ -145,7 +145,7 @@ void MenuRenderer::render(const ServiceMenu* menu_state) {
|
||||
}
|
||||
}
|
||||
|
||||
void MenuRenderer::update(const ServiceMenu* menu_state, float delta_time) {
|
||||
void MenuRenderer::update(const ServiceMenu* /*menu_state*/, float delta_time) {
|
||||
updateAnimations(delta_time);
|
||||
|
||||
if (visible_) {
|
||||
@@ -380,7 +380,7 @@ void MenuRenderer::updatePosition() {
|
||||
|
||||
// Resto de métodos (sin cambios significativos)
|
||||
|
||||
void MenuRenderer::precalculateMenuWidths(const std::vector<std::unique_ptr<MenuOption>>& all_options, const ServiceMenu* menu_state) { // NOLINT(readability-named-parameter)
|
||||
void MenuRenderer::precalculateMenuWidths(const std::vector<std::unique_ptr<MenuOption>>& all_options, const ServiceMenu* menu_state) {
|
||||
std::ranges::fill(group_menu_widths_, ServiceMenu::MIN_WIDTH);
|
||||
for (int group = 0; group < 5; ++group) {
|
||||
auto sg = static_cast<ServiceMenu::SettingsGroup>(group);
|
||||
|
||||
@@ -140,7 +140,7 @@ class MenuRenderer {
|
||||
void updateSwapAnimation(float delta_time);
|
||||
void updatePosition();
|
||||
|
||||
void precalculateMenuWidths(const std::vector<std::unique_ptr<MenuOption>>& all_options, const ServiceMenu* menu_state); // NOLINT(readability-avoid-const-params-in-decls)
|
||||
void precalculateMenuWidths(const std::vector<std::unique_ptr<MenuOption>>& all_options, const ServiceMenu* menu_state);
|
||||
[[nodiscard]] auto getMenuWidthForGroup(ServiceMenu::SettingsGroup group) const -> int;
|
||||
[[nodiscard]] auto getAnimatedSelectedColor() const -> Color;
|
||||
void updateColorCounter();
|
||||
|
||||
@@ -259,7 +259,7 @@ void Notifier::show(std::vector<std::string> texts, int icon, const std::string&
|
||||
|
||||
// Dibuja el icono de la notificación
|
||||
if (has_icons_ && icon >= 0 && texts.size() >= 2) {
|
||||
auto sp = std::make_unique<Sprite>(icon_texture_, (SDL_FRect){.x = 0, .y = 0, .w = ICON_SIZE, .h = ICON_SIZE});
|
||||
auto sp = std::make_unique<Sprite>(icon_texture_, SDL_FRect{.x = 0, .y = 0, .w = ICON_SIZE, .h = ICON_SIZE});
|
||||
sp->setPosition({.x = PADDING_IN_H, .y = PADDING_IN_V, .w = ICON_SIZE, .h = ICON_SIZE});
|
||||
sp->setSpriteClip(SDL_FRect{
|
||||
.x = static_cast<float>(ICON_SIZE * (icon % 10)),
|
||||
|
||||
@@ -1,109 +1,96 @@
|
||||
#include "core/resources/resource_pack.hpp"
|
||||
#include "../../build/version.h" // Para Version::APP_NAME
|
||||
#include <iostream>
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
void showHelp() {
|
||||
std::cout << Version::APP_NAME << " - Resource Packer" << std::endl;
|
||||
std::cout << "===============================================" << std::endl;
|
||||
std::cout << "Usage: pack_resources [options] [input_dir] [output_file]" << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << "Options:" << std::endl;
|
||||
std::cout << " --help Show this help message" << std::endl;
|
||||
std::cout << " --list List contents of an existing pack file" << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << "Arguments:" << std::endl;
|
||||
std::cout << " input_dir Directory to pack (default: data)" << std::endl;
|
||||
std::cout << " output_file Pack file name (default: resources.pack)" << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << "Examples:" << std::endl;
|
||||
std::cout << " pack_resources # Pack 'data' to 'resources.pack'" << std::endl;
|
||||
std::cout << " pack_resources mydata # Pack 'mydata' to 'resources.pack'" << std::endl;
|
||||
std::cout << " pack_resources data my.pack # Pack 'data' to 'my.pack'" << std::endl;
|
||||
std::cout << " pack_resources --list my.pack # List contents of 'my.pack'" << std::endl;
|
||||
}
|
||||
#include "core/resources/resource_pack.hpp"
|
||||
#include "../../build/version.h" // Version::APP_NAME
|
||||
|
||||
void listPackContents(const std::string& packFile) {
|
||||
ResourcePack pack;
|
||||
if (!pack.loadPack(packFile)) {
|
||||
std::cerr << "Error: Cannot open pack file: " << packFile << std::endl;
|
||||
return;
|
||||
namespace {
|
||||
|
||||
void showHelp() {
|
||||
std::cout << Version::APP_NAME << " - Resource Packer\n";
|
||||
std::cout << "==============================================\n";
|
||||
std::cout << "Usage: pack_resources [options] [input_dir] [output_file]\n\n";
|
||||
std::cout << "Options:\n";
|
||||
std::cout << " --help Show this help message\n";
|
||||
std::cout << " --list List contents of an existing pack file\n\n";
|
||||
std::cout << "Arguments:\n";
|
||||
std::cout << " input_dir Directory to pack (default: data)\n";
|
||||
std::cout << " output_file Pack file name (default: resources.pack)\n";
|
||||
}
|
||||
|
||||
auto resources = pack.getResourceList();
|
||||
std::cout << "Pack file: " << packFile << std::endl;
|
||||
std::cout << "Resources: " << resources.size() << std::endl;
|
||||
std::cout << "Contents:" << std::endl;
|
||||
|
||||
for (const auto& resource : resources) {
|
||||
std::cout << " " << resource << std::endl;
|
||||
void listPackContents(const std::string& pack_file) {
|
||||
ResourcePack pack;
|
||||
if (!pack.loadPack(pack_file)) {
|
||||
std::cerr << "Error: cannot open pack file: " << pack_file << '\n';
|
||||
return;
|
||||
}
|
||||
auto resources = pack.getResourceList();
|
||||
std::cout << "Pack file: " << pack_file << '\n';
|
||||
std::cout << "Resources: " << resources.size() << '\n';
|
||||
for (const auto& r : resources) { std::cout << " " << r << '\n'; }
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
std::string dataDir = "data";
|
||||
std::string outputFile = "resources.pack";
|
||||
bool listMode = false;
|
||||
bool dataDirSet = false;
|
||||
std::string data_dir = "data";
|
||||
std::string output_file = "resources.pack";
|
||||
bool list_mode = false;
|
||||
bool data_dir_set = false;
|
||||
|
||||
// Parse arguments
|
||||
for (int i = 1; i < argc; i++) {
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
std::string arg = argv[i];
|
||||
if (arg == "--help" || arg == "-h") {
|
||||
showHelp();
|
||||
return 0;
|
||||
} else if (arg == "--list") {
|
||||
listMode = true;
|
||||
if (i + 1 < argc) {
|
||||
outputFile = argv[++i]; // Next argument is pack file to list
|
||||
}
|
||||
} else if (!arg.empty() && arg[0] != '-') {
|
||||
if (!dataDirSet) {
|
||||
dataDir = arg;
|
||||
dataDirSet = true;
|
||||
}
|
||||
if (arg == "--list") {
|
||||
list_mode = true;
|
||||
if (i + 1 < argc) { output_file = argv[++i]; }
|
||||
continue;
|
||||
}
|
||||
if (!arg.empty() && arg[0] != '-') {
|
||||
if (!data_dir_set) {
|
||||
data_dir = arg;
|
||||
data_dir_set = true;
|
||||
} else {
|
||||
outputFile = arg;
|
||||
output_file = arg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (listMode) {
|
||||
listPackContents(outputFile);
|
||||
if (list_mode) {
|
||||
listPackContents(output_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::cout << Version::APP_NAME << " - Resource Packer" << std::endl;
|
||||
std::cout << "===============================================" << std::endl;
|
||||
std::cout << "Input directory: " << dataDir << std::endl;
|
||||
std::cout << "Output file: " << outputFile << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << Version::APP_NAME << " - Resource Packer\n";
|
||||
std::cout << "==============================================\n";
|
||||
std::cout << "Input directory: " << data_dir << '\n';
|
||||
std::cout << "Output file: " << output_file << '\n';
|
||||
|
||||
if (!std::filesystem::exists(dataDir)) {
|
||||
std::cerr << "Error: Input directory does not exist: " << dataDir << std::endl;
|
||||
if (!std::filesystem::exists(data_dir)) {
|
||||
std::cerr << "Error: input directory does not exist: " << data_dir << '\n';
|
||||
return 1;
|
||||
}
|
||||
|
||||
ResourcePack pack;
|
||||
std::cout << "Scanning and packing resources...\n";
|
||||
if (!pack.addDirectory(data_dir)) {
|
||||
std::cerr << "Error: failed to add directory to pack\n";
|
||||
return 1;
|
||||
}
|
||||
std::cout << "Found " << pack.getResourceCount() << " resources\n";
|
||||
|
||||
std::cout << "Scanning and packing resources..." << std::endl;
|
||||
if (!pack.addDirectory(dataDir)) {
|
||||
std::cerr << "Error: Failed to add directory to pack" << std::endl;
|
||||
std::cout << "Saving pack file...\n";
|
||||
if (!pack.savePack(output_file)) {
|
||||
std::cerr << "Error: failed to save pack file\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::cout << "Found " << pack.getResourceCount() << " resources" << std::endl;
|
||||
|
||||
std::cout << "Saving pack file..." << std::endl;
|
||||
if (!pack.savePack(outputFile)) {
|
||||
std::cerr << "Error: Failed to save pack file" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::filesystem::path packPath(outputFile);
|
||||
auto fileSize = std::filesystem::file_size(packPath);
|
||||
|
||||
std::cout << "Pack file created successfully!" << std::endl;
|
||||
std::cout << "File size: " << (fileSize / 1024.0 / 1024.0) << " MB" << std::endl;
|
||||
|
||||
auto file_size = std::filesystem::file_size(std::filesystem::path(output_file));
|
||||
std::cout << "Pack file created: " << output_file << " ("
|
||||
<< (static_cast<double>(file_size) / 1024.0 / 1024.0) << " MB)\n";
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user