diff --git a/source/cheevos.cpp b/source/cheevos.cpp index c258ef1..e2d3d12 100644 --- a/source/cheevos.cpp +++ b/source/cheevos.cpp @@ -89,7 +89,7 @@ void Cheevos::unlock(int id) // Marcar el logro como completado cheevos_list_.at(index).completed = true; // Mostrar notificación en la pantalla - Notifier::get()->show("ACHIEVEMENT UNLOCKED!", cheevos_list_.at(index).caption, cheevos_list_.at(index).icon); + Notifier::get()->show({"ACHIEVEMENT UNLOCKED!", cheevos_list_.at(index).caption}, cheevos_list_.at(index).icon); // Guardar el estado de los logros saveToFile(); } diff --git a/source/credits.cpp b/source/credits.cpp index 33e6fe9..1c6fcd6 100644 --- a/source/credits.cpp +++ b/source/credits.cpp @@ -7,7 +7,7 @@ #include // Para min #include // Para char_traits, basic_ostream, operator<< #include "animated_sprite.h" // Para AnimatedSprite -#include "const.h" // Para GAMECANVAS_HEIGHT, GAMECANVAS_WIDTH +#include "defines.h" // Para GAMECANVAS_HEIGHT, GAMECANVAS_WIDTH #include "input.h" // Para Input, REPEAT_FALSE, inputs_e #include "resource.h" // Para Resource #include "screen.h" // Para Screen @@ -27,7 +27,7 @@ Credits::Credits() input_(Input::get()) { // Reserva memoria para los punteros - text_ = resource_->getText("smb2.txt"); + text_ = resource_->getText("smb2"); sprite_ = std::make_shared(resource_->getTexture("shine.png"), resource_->getAnimation("shine.ani")); // Inicializa variables diff --git a/source/const.h b/source/defines.h similarity index 100% rename from source/const.h rename to source/defines.h diff --git a/source/demo.cpp b/source/demo.cpp index 704af59..6505dc0 100644 --- a/source/demo.cpp +++ b/source/demo.cpp @@ -3,7 +3,7 @@ #include // Para SDL_GetTicks #include // Para basic_ostream, basic_ios, operator<<, cout #include "asset.h" // Para Asset -#include "const.h" // Para BLOCK, PLAY_AREA_WIDTH, SECTION_DEMO +#include "defines.h" // Para BLOCK, PLAY_AREA_WIDTH, SECTION_DEMO #include "input.h" // Para Input, REPEAT_FALSE, inputs_e #include "item_tracker.h" // Para ItemTracker #include "resource.h" // Para Resource @@ -40,8 +40,8 @@ Demo::Demo() currentRoom = rooms[roomIndex]; // Crea los objetos - itemTracker = std::make_unique(); - scoreboard = std::make_unique(&board); + itemTracker = std::make_shared(); + scoreboard = std::make_shared(&board); room = std::make_shared(resource->getRoom(currentRoom), itemTracker, &board.items, false); text = resource->getText("smb2.txt"); @@ -177,7 +177,7 @@ bool Demo::changeRoom(std::string file) { // En las habitaciones los limites tienen la cadena del fichero o un 0 en caso de no limitar con nada if (file != "0") - { + { // Verifica que exista el fichero que se va a cargar if (asset->get(file) != "") { diff --git a/source/demo.h b/source/demo.h index 0b82cb9..3ded99b 100644 --- a/source/demo.h +++ b/source/demo.h @@ -7,6 +7,7 @@ #include // Para vector #include // Para shared_ptr #include "scoreboard.h" // Para board_t +#include "room.h" class Asset; class Debug; class Input; @@ -30,8 +31,8 @@ private: Debug *debug; // Objeto para gestionar la información de debug std::shared_ptr room; // Objeto encargado de gestionar cada habitación del juego std::shared_ptr text; // Objeto para los textos del juego - std::unique_ptr scoreboard; // Objeto encargado de gestionar el marcador - std::unique_ptr itemTracker; // Lleva el control de los objetos recogidos + std::shared_ptr scoreboard; // Objeto encargado de gestionar el marcador + std::shared_ptr itemTracker; // Lleva el control de los objetos recogidos // Variables Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa diff --git a/source/director.cpp b/source/director.cpp index 2a31372..2e261e4 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -20,7 +20,7 @@ #include // Para vector #include // Para std::make_unique #include "asset.h" // Para Asset, assetType -#include "const.h" // Para Section::LOGO, Section::TITLE +#include "defines.h" // Para Section::LOGO, Section::TITLE #include "debug.h" // Para Debug #include "credits.h" // Para Credits #include "demo.h" // Para Demo @@ -81,7 +81,7 @@ Director::Director(int argc, const char *argv[]) Screen::init(window_, renderer_); Screen::get()->setBorderColor(borderColor); Resource::init(); - Notifier::init(Asset::get()->get("notify.png"), Asset::get()->get("smb2.png"), Asset::get()->get("smb2.txt"), Asset::get()->get("notify.wav")); + Notifier::init(Asset::get()->get("notify.png"), Resource::get()->getText("smb2")); Input::init(Asset::get()->get("gamecontrollerdb.txt")); initInput(); Debug::init(); diff --git a/source/ending.cpp b/source/ending.cpp index 18ac84d..a0e446a 100644 --- a/source/ending.cpp +++ b/source/ending.cpp @@ -7,7 +7,7 @@ #include // Para min #include // Para basic_ostream, operator<<, basic_ios #include "asset.h" // Para Asset -#include "const.h" // Para GAMECANVAS_HEIGHT, GAMECANVAS_WIDTH +#include "defines.h" // Para GAMECANVAS_HEIGHT, GAMECANVAS_WIDTH #include "input.h" // Para Input, REPEAT_FALSE, inputs_e #include "jail_audio.h" // Para JA_SetVolume, JA_DeleteMusic, JA_Loa... #include "resource.h" // Para Resource diff --git a/source/ending2.cpp b/source/ending2.cpp index 00066ef..409bf5d 100644 --- a/source/ending2.cpp +++ b/source/ending2.cpp @@ -4,7 +4,7 @@ #include // for max, min, replace #include "animated_sprite.h" // for AnimatedSprite #include "asset.h" // for Asset -#include "const.h" // for GAMECANVAS_HEIGHT, GAMECANVAS_CENTER_X +#include "defines.h" // for GAMECANVAS_HEIGHT, GAMECANVAS_CENTER_X #include "input.h" // for Input, REPEAT_FALSE, inputs_e #include "jail_audio.h" // for JA_SetVolume, JA_DeleteMusic, JA_Loa... #include "moving_sprite.h" // for MovingSprite @@ -319,7 +319,7 @@ void Ending2::loadSprites() // Carga los sprites for (auto sl : spriteList) { - sprites.emplace_back(std::make_shared(renderer, resource->getAnimation(sl + ".ani"))); + sprites.emplace_back(std::make_shared(resource->getTexture(sl + ".png"), resource->getAnimation(sl + ".ani"))); maxSpriteWidth = std::max(sprites.back()->getWidth(), maxSpriteWidth); maxSpriteHeight = std::max(sprites.back()->getHeight(), maxSpriteHeight); } diff --git a/source/enemy.cpp b/source/enemy.cpp index db5d7c2..710c87d 100644 --- a/source/enemy.cpp +++ b/source/enemy.cpp @@ -4,21 +4,22 @@ #include // Para min #include "animated_sprite.h" // Para AnimatedSprite #include "texture.h" // Para Texture +#include "resource.h" // Para Resource +#include "options.h" // Para options // Constructor -Enemy::Enemy(enemy_t enemy) +Enemy::Enemy(EnemyData enemy) { // Crea objetos - sprite_ = std::make_shared(falta_la_textura, enemy.animation); + sprite_ = std::make_shared(Resource::get()->getTexture(enemy.texture_path), Resource::get()->getAnimation(enemy.animation_path)); // Obten el resto de valores x1_ = enemy.x1; x2_ = enemy.x2; y1_ = enemy.y1; y2_ = enemy.y2; - palette_ = enemy.palette; color_string_ = enemy.color; - color_ = stringToColor(palette_, color_string_); + setPalette(options.video.palette); sprite_->setPosX(enemy.x); sprite_->setPosY(enemy.y); sprite_->setVelX(enemy.vx); @@ -130,6 +131,5 @@ void Enemy::reLoadTexture() // Asigna la paleta void Enemy::setPalette(Palette pal) { - palette_ = pal; - color_ = stringToColor(palette_, color_string_); + color_ = stringToColor(pal, color_string_); } \ No newline at end of file diff --git a/source/enemy.h b/source/enemy.h index 2bd33e7..135d429 100644 --- a/source/enemy.h +++ b/source/enemy.h @@ -5,30 +5,27 @@ #include // Para basic_string, string #include "utils.h" // Para palette_e, color_t #include // Para shared_ptr -class AnimatedSprite; -struct animatedSprite_t; +#include "animated_sprite.h" // Para AnimatedSprite // Estructura para pasar los datos de un enemigo -struct enemy_t +struct EnemyData { - SDL_Renderer *renderer; // El renderizador de la ventana - animatedSprite_t *animation; // Puntero a las animaciones del enemigo - std::string animation_path; // Ruta al fichero con la animación - int w; // Anchura del enemigo - int h; // Altura del enemigo - float x; // Posición inicial en el eje X - float y; // Posición inicial en el eje Y - float vx; // Velocidad en el eje X - float vy; // Velocidad en el eje Y - int x1; // Limite izquierdo de la ruta en el eje X - int x2; // Limite derecho de la ruta en el eje X - int y1; // Limite superior de la ruta en el eje Y - int y2; // Limite inferior de la ruta en el eje Y - bool flip; // Indica si el enemigo hace flip al terminar su ruta - bool mirror; // Indica si el enemigo está volteado verticalmente - int frame; // Frame inicial para la animación del enemigo - std::string color; // Color del enemigo - Palette palette; // Paleta de colores + std::string texture_path; // Ruta al fichero con la textura + std::string animation_path; // Ruta al fichero con la animación + int w; // Anchura del enemigo + int h; // Altura del enemigo + float x; // Posición inicial en el eje X + float y; // Posición inicial en el eje Y + float vx; // Velocidad en el eje X + float vy; // Velocidad en el eje Y + int x1; // Limite izquierdo de la ruta en el eje X + int x2; // Limite derecho de la ruta en el eje X + int y1; // Limite superior de la ruta en el eje Y + int y2; // Limite inferior de la ruta en el eje Y + bool flip; // Indica si el enemigo hace flip al terminar su ruta + bool mirror; // Indica si el enemigo está volteado verticalmente + int frame; // Frame inicial para la animación del enemigo + std::string color; // Color del enemigo }; class Enemy @@ -40,7 +37,6 @@ private: // Variables Color color_; // Color del enemigo std::string color_string_; // Color del enemigo en formato texto - Palette palette_; // Paleta de colores int x1_; // Limite izquierdo de la ruta en el eje X int x2_; // Limite derecho de la ruta en el eje X int y1_; // Limite superior de la ruta en el eje Y @@ -54,7 +50,7 @@ private: public: // Constructor - Enemy(enemy_t enemy); + Enemy(EnemyData enemy); // Destructor ~Enemy() = default; diff --git a/source/game.cpp b/source/game.cpp index 7660660..0f00c73 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -8,7 +8,7 @@ #include // for vector #include "asset.h" // for Asset #include "cheevos.h" // for Cheevos -#include "const.h" // for PLAY_AREA_HEIGHT, GAMECANVAS_WIDTH +#include "defines.h" // for PLAY_AREA_HEIGHT, GAMECANVAS_WIDTH #include "debug.h" // for Debug #include "input.h" // for Input, REPEAT_FALSE, inputs_e #include "item_tracker.h" // for ItemTracker diff --git a/source/game.h b/source/game.h index 376eaa6..7f4aa9a 100644 --- a/source/game.h +++ b/source/game.h @@ -7,6 +7,7 @@ #include // Para string, basic_string #include "player.h" // Para playerSpawn_t #include "scoreboard.h" // Para board_t +#include "room.h" class Asset; class Cheevos; class Debug; diff --git a/source/game_over.cpp b/source/game_over.cpp index 9604566..2764a46 100644 --- a/source/game_over.cpp +++ b/source/game_over.cpp @@ -4,7 +4,7 @@ #include // Para basic_string, operator+, to_string, char... #include "animated_sprite.h" // Para AnimatedSprite #include "asset.h" // Para Asset -#include "const.h" // Para GAMECANVAS_CENTER_X, SECTION_GAME_OVER +#include "defines.h" // Para GAMECANVAS_CENTER_X, SECTION_GAME_OVER #include "input.h" // Para Input, REPEAT_FALSE, inputs_e #include "jail_audio.h" // Para JA_DeleteMusic, JA_LoadMusic, JA_PlayMusic #include "resource.h" // Para Resource diff --git a/source/global_inputs.cpp b/source/global_inputs.cpp index be3f36b..8ff0967 100644 --- a/source/global_inputs.cpp +++ b/source/global_inputs.cpp @@ -69,7 +69,7 @@ namespace globalInputs else if (Input::get()->checkInput(input_toggle_shaders, REPEAT_FALSE)) { Screen::get()->toggleShaders(); - Notifier::get()->show("HOLA"); + Notifier::get()->show({"HOLA"}); } else if (Input::get()->checkInput(input_toggle_palette, REPEAT_FALSE)) diff --git a/source/loading_screen.cpp b/source/loading_screen.cpp index 1a963c4..597f481 100644 --- a/source/loading_screen.cpp +++ b/source/loading_screen.cpp @@ -2,7 +2,7 @@ #include // for SDL_GetTicks #include // for rand #include "asset.h" // for Asset -#include "const.h" // for SECTION_LOADING_SCREEN, SECTION_QUIT +#include "defines.h" // for SECTION_LOADING_SCREEN, SECTION_QUIT #include "input.h" // for Input, REPEAT_FALSE, inputs_e #include "jail_audio.h" // for JA_DeleteMusic, JA_LoadMusic, JA_PlayMusic #include "resource.h" // for Resource @@ -33,8 +33,8 @@ LoadingScreen::LoadingScreen() mono_loading_screen_texture_ = resource_->getTexture("loading_screen_bn_zxarne.png"); color_loading_screen_texture_ = resource_->getTexture("loading_screen_color_zxarne.png"); } - mono_loading_screen_sprite_ = std::make_shared(0, 0, mono_loading_screen_texture_->getWidth(), mono_loading_screen_texture_->getHeight(), mono_loading_screen_texture_, renderer_); - color_loading_screen_sprite_ = std::make_shared(0, 0, color_loading_screen_texture_->getWidth(), color_loading_screen_texture_->getHeight(), color_loading_screen_texture_, renderer_); + mono_loading_screen_sprite_ = std::make_shared(mono_loading_screen_texture_, 0, 0, mono_loading_screen_texture_->getWidth(), mono_loading_screen_texture_->getHeight()); + color_loading_screen_sprite_ = std::make_shared(color_loading_screen_texture_, 0, 0, color_loading_screen_texture_->getWidth(), color_loading_screen_texture_->getHeight()); loading_sound1_ = resource_->getMusic("loading_sound1.ogg"); loading_sound2_ = resource_->getMusic("loading_sound2.ogg"); loading_sound3_ = resource_->getMusic("loading_sound3.ogg"); diff --git a/source/logo.cpp b/source/logo.cpp index 8db5eca..0faded0 100644 --- a/source/logo.cpp +++ b/source/logo.cpp @@ -1,7 +1,7 @@ #include "logo.h" #include // for SDL_GetTicks #include // for basic_string, string -#include "const.h" // for SECTION_LOGO, SECTION_TITLE, SUBSECTION_... +#include "defines.h" // for SECTION_LOGO, SECTION_TITLE, SUBSECTION_... #include "input.h" // for Input, REPEAT_FALSE, inputs_e #include "jail_audio.h" // for JA_StopMusic #include "resource.h" // for Resource @@ -26,14 +26,14 @@ Logo::Logo() // Reserva memoria para los punteros jailgames_texture_ = resource_->getTexture("jailgames.png"); since_1998_texture_ = resource_->getTexture("since_1998.png"); - since_1998_sprite_ = std::make_shared((256 - since_1998_texture_->getWidth()) / 2, 83 + jailgames_texture_->getHeight() + 5, since_1998_texture_->getWidth(), since_1998_texture_->getHeight(), since_1998_texture_, renderer_); + since_1998_sprite_ = std::make_shared(since_1998_texture_, (256 - since_1998_texture_->getWidth()) / 2, 83 + jailgames_texture_->getHeight() + 5, since_1998_texture_->getWidth(), since_1998_texture_->getHeight()); since_1998_sprite_->setClip(0, 0, since_1998_texture_->getWidth(), since_1998_texture_->getHeight()); since_1998_texture_->setColor(0, 0, 0); // Crea los sprites de cada linea for (int i = 0; i < jailgames_texture_->getHeight(); ++i) { - jailgames_sprite_.push_back(std::make_shared(0, i, jailgames_texture_->getWidth(), 1, jailgames_texture_, renderer_)); + jailgames_sprite_.push_back(std::make_shared(jailgames_texture_, 0, i, jailgames_texture_->getWidth(), 1)); jailgames_sprite_.back()->setClip(0, i, jailgames_texture_->getWidth(), 1); if (i % 2 == 0) { diff --git a/source/moving_sprite.h b/source/moving_sprite.h index 8010031..52e7408 100644 --- a/source/moving_sprite.h +++ b/source/moving_sprite.h @@ -4,6 +4,8 @@ #include // Para SDL_RendererFlip #include // Para shared_ptr #include "sprite.h" // Para Sprite +#include +#include class Texture; // lines 8-8 // Clase MovingSprite. Añade movimiento y efectos de rotación, zoom y flip al sprite diff --git a/source/notifier.cpp b/source/notifier.cpp index 021a4bb..da97758 100644 --- a/source/notifier.cpp +++ b/source/notifier.cpp @@ -198,20 +198,20 @@ void Notifier::show(std::vector texts, int icon, const std::string } else if (options.notifications.getHorizontalPosition() == "CENTER") { - desp_h = ((param.game.width / 2) - (width / 2)); + desp_h = ((options.game.width / 2) - (width / 2)); } else { - desp_h = param.game.width - width - padding_out; + desp_h = options.game.width - width - padding_out; } // Posición vertical - const int desp_v = (param.notification.pos_v == NotifyPosition::TOP) ? padding_out : (param.game.height - height - padding_out); + const int desp_v = (options.notifications.getVerticalPosition() == "TOP") ? padding_out : (options.game.height - height - padding_out); // Offset const auto travel_dist = height + padding_out; auto offset = 0; - if (param.notification.pos_v == NotifyPosition::TOP) + if (options.notifications.getVerticalPosition() == "TOP") { offset = !notifications_.empty() ? notifications_.back().y + travel_dist : desp_v; } @@ -229,7 +229,7 @@ void Notifier::show(std::vector texts, int icon, const std::string n.travel_dist = travel_dist; n.texts = texts; n.shape = shape; - auto y_pos = offset + (param.notification.pos_v == NotifyPosition::TOP ? -travel_dist : travel_dist); + int y_pos = offset + ((options.notifications.getVerticalPosition() == "TOP") ? -travel_dist : travel_dist); n.rect = {desp_h, y_pos, width, height}; // Crea la textura @@ -268,7 +268,7 @@ void Notifier::show(std::vector texts, int icon, const std::string { auto sp = std::make_unique(icon_texture_, (SDL_Rect){0, 0, icon_size, icon_size}); sp->setPosition({padding_in_h, padding_in_v, icon_size, icon_size}); - sp->setSpriteClip({icon_size * (icon % 10), icon_size * (icon / 10), icon_size, icon_size}); + sp->setClip({icon_size * (icon % 10), icon_size * (icon / 10), icon_size, icon_size}); sp->render(); } diff --git a/source/options.cpp b/source/options.cpp index 66c5d52..2da12be 100644 --- a/source/options.cpp +++ b/source/options.cpp @@ -1,10 +1,10 @@ #include "options.h" -#include "const.h" +#include "defines.h" #include "screen.h" -#include // Para basic_ofstream, basic_ifstream -#include // Para basic_ostream, operator<<, cout +#include // Para basic_ofstream, basic_ifstream +#include // Para basic_ostream, operator<<, cout #include // Para unordered_map -#include // Para std::function +#include // Para std::function // Variables Options options; @@ -149,24 +149,37 @@ bool saveOptionsToFile(const std::string &file_path) } // Establece las opciones -bool setOptions(const std::string &var, const std::string &value) { +bool setOptions(const std::string &var, const std::string &value) +{ static const std::unordered_map> optionHandlers = { - {"version", [](std::string v) { options.version = v; }}, - {"keys", [](std::string v) { options.keys = static_cast(safeStoi(v, static_cast(ControlScheme::CURSOR))); }}, - {"video.mode", [](std::string v) { options.video.mode = safeStoi(v, 0); }}, - {"window.zoom", [](std::string v) { options.window.zoom = safeStoi(v, 1); }}, - {"video.shaders", [](std::string v) { options.video.shaders = stringToBool(v); }}, - {"video.vertical_sync", [](std::string v) { options.video.vertical_sync = stringToBool(v); }}, - {"video.integer_scale", [](std::string v) { options.video.integer_scale = stringToBool(v); }}, - {"video.keep_aspect", [](std::string v) { options.video.keep_aspect = stringToBool(v); }}, - {"video.border.enabled", [](std::string v) { options.video.border.enabled = stringToBool(v); }}, - {"video.border.width", [](std::string v) { options.video.border.width = safeStoi(v, 32); }}, - {"video.border.height", [](std::string v) { options.video.border.height = safeStoi(v, 24); }}, - {"video.palette", [](std::string v) { options.video.palette = static_cast(safeStoi(v, static_cast(DEFAULT_PALETTE))); }} - }; - + {"version", [](std::string v) + { options.version = v; }}, + {"keys", [](std::string v) + { options.keys = static_cast(safeStoi(v, static_cast(ControlScheme::CURSOR))); }}, + {"video.mode", [](std::string v) + { options.video.mode = safeStoi(v, 0); }}, + {"window.zoom", [](std::string v) + { options.window.zoom = safeStoi(v, 1); }}, + {"video.shaders", [](std::string v) + { options.video.shaders = stringToBool(v); }}, + {"video.vertical_sync", [](std::string v) + { options.video.vertical_sync = stringToBool(v); }}, + {"video.integer_scale", [](std::string v) + { options.video.integer_scale = stringToBool(v); }}, + {"video.keep_aspect", [](std::string v) + { options.video.keep_aspect = stringToBool(v); }}, + {"video.border.enabled", [](std::string v) + { options.video.border.enabled = stringToBool(v); }}, + {"video.border.width", [](std::string v) + { options.video.border.width = safeStoi(v, 32); }}, + {"video.border.height", [](std::string v) + { options.video.border.height = safeStoi(v, 24); }}, + {"video.palette", [](std::string v) + { options.video.palette = static_cast(safeStoi(v, static_cast(DEFAULT_PALETTE))); }}}; + auto it = optionHandlers.find(var); - if (it != optionHandlers.end()) { + if (it != optionHandlers.end()) + { it->second(value); return true; } diff --git a/source/player.cpp b/source/player.cpp index 381e5fd..482f4d4 100644 --- a/source/player.cpp +++ b/source/player.cpp @@ -5,7 +5,7 @@ #include // Para ceil, abs #include "animated_sprite.h" // Para AnimatedSprite #include "asset.h" // Para Asset -#include "const.h" // Para BORDER_TOP, BLOCK, BORDER_BOTTOM, BORDER... +#include "defines.h" // Para BORDER_TOP, BLOCK, BORDER_BOTTOM, BORDER... #include "debug.h" // Para Debug #include "input.h" // Para Input, inputs_e #include "jail_audio.h" // Para JA_LoadSound, JA_Sound_t, JA_PlaySound @@ -21,11 +21,11 @@ Player::Player(player_t player) input_(Input::get()), resource_(Resource::get()), asset_(Asset::get()), - room_(player.room), - debug_(Debug::get()) + debug_(Debug::get()), + room_(player.room) { // Crea objetos - sprite_ = std::make_shared(resource_->getAnimation(player.animation)); + sprite_ = std::make_shared(resource_->getTexture(player.png), resource_->getAnimation(player.animation)); // Inicializa variables reLoadPalette(); @@ -538,7 +538,7 @@ void Player::move() // Comprueba la colisión con las superficies normales y las automáticas const int 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 - h_; setState(s_standing); @@ -547,7 +547,7 @@ void Player::move() auto_movement_ = false; } else - { + { // Si no hay colisión con los muros, comprueba la colisión con las rampas if (state_ != s_jumping) { // Las rampas no se miran si se está saltando @@ -555,7 +555,7 @@ void Player::move() v_line_t rightSide = {proj.x + proj.w - 1, proj.y, proj.y + proj.h - 1}; const int p = std::max(room_->checkRightSlopes(&rightSide), room_->checkLeftSlopes(&leftSide)); if (p > -1) - { + { // No está saltando y hay colisión con una rampa // Calcula la nueva posición y_ = p - h_; @@ -566,7 +566,7 @@ void Player::move() #endif } else - { + { // No está saltando y no hay colisón con una rampa // Calcula la nueva posición y_ += vy_; @@ -576,7 +576,7 @@ void Player::move() } } else - { + { // Esta saltando y no hay colisión con los muros // Calcula la nueva posición y_ += vy_; @@ -611,7 +611,7 @@ void Player::checkJumpEnd() if (vy_ > 0) { if (y_ >= jump_init_pos_) - { + { // Si alcanza la altura de salto inicial, pasa al estado de caída setState(s_falling); vy_ = MAX_VY_; diff --git a/source/player.h b/source/player.h index 63c2960..f9157a7 100644 --- a/source/player.h +++ b/source/player.h @@ -6,6 +6,8 @@ #include // Para vector #include // Para shared_ptr #include "utils.h" // Para color_t +#include "defines.h" // Para BLOCK +#include "room.h" class AnimatedSprite; class Asset; class Debug; @@ -44,8 +46,8 @@ class Player { public: // Constantes - static const int MAX_FALLING_HEIGHT_ = BLOCK * 4; // Altura maxima permitida de caída. - static const float MAX_VY_ = 1.2f; // Velocidad máxima que puede alcanzar al desplazarse en vertical + 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 SDL_Renderer *renderer_; // El renderizador de la ventana diff --git a/source/resource_old.cpp b/source/resource_old.cpp deleted file mode 100644 index 8e51a04..0000000 --- a/source/resource_old.cpp +++ /dev/null @@ -1,360 +0,0 @@ -#include "resource.h" -#include // Para basic_ostream, operator<<, cout, endl -#include "animated_sprite.h" // Para animatedSprite_t, loadAnimationFromFile -#include "asset.h" // Para Asset -#include "enemy.h" // Para enemy_t -#include "item.h" // Para item_t -#include "room.h" // Para room_t, loadRoomFile, loadRoomTileFile -#include "text.h" // Para textFile_t, LoadTextFile -#include "texture.h" // Para Texture -#include "utils.h" // Para options_t -#include "screen.h" -#include "options.h" - -// [SINGLETON] -Resource *Resource::resource_ = nullptr; - -// [SINGLETON] Crearemos el objeto con esta función estática -void Resource::init() -{ - Resource::resource_ = new Resource(); -} - -// [SINGLETON] Destruiremos el objeto con esta función estática -void Resource::destroy() -{ - delete Resource::resource_; -} - -// [SINGLETON] Con este método obtenemos el objeto y podemos trabajar con él -Resource *Resource::get() -{ - return Resource::resource_; -} - -// Carga las texturas de una lista -void Resource::loadTextures(std::vector list) -{ - for (auto l : list) - { - if (options.console) - { - std::cout << "\nLOAD TEXTURE: " << l << std::endl; - std::cout << "png: " << Asset::get()->get(l) << std::endl; - } - - res_texture_t t; - t.name = l; - t.texture = std::make_shared(Screen::get()->getRenderer(), Asset::get()->get(t.name), options.console); - textures_.push_back(t); - } -} - -// Vuelve a cargar las texturas -void Resource::reLoadTextures() -{ - for (auto texture : textures_) - { - texture.texture->reLoad(); - } -} - -// Carga las animaciones desde una lista -void Resource::loadAnimations(std::vector list) -{ - for (auto l : list) - { - // Extrae el nombre del fichero sin la extension para crear el nombre del fichero de la textura - const std::string pngFile = l.substr(0, l.find_last_of(".")) + ".png"; - - if (options.console) - { - std::cout << "\nLOAD ANIMATION: " << l << std::endl; - std::cout << "png: " << Asset::get()->get(pngFile) << std::endl; - std::cout << "ani: " << Asset::get()->get(l) << std::endl; - } - - res_animation_t as; - as.name = l; - as.animation = std::make_shared(loadAnimationFromFile(getTexture(pngFile), Asset::get()->get(as.name), options.console)); - animations_.push_back(as); - } -} - -// Vuelve a cargar las animaciones -void Resource::reLoadAnimations() -{ - // reLoadTextures(); - - for (auto &a : animations_) - { - // Extrae el nombre del fichero sin la extension para crear el nombre del fichero de la textura - const std::string pngFile = a.name.substr(0, a.name.find_last_of(".")) + ".png"; - delete a.animation; - a.animation = std::make_shared(loadAnimationFromFile(getTexture(pngFile), Asset::get()->get(a.name), options.console)); - } -} - -// Carga los offsets desde una lista -void Resource::loadOffsets(std::vector list) -{ - for (auto l : list) - { - res_textOffset_t to; - to.name = l; - to.textFile = std::make_shared(LoadTextFile(Asset::get()->get(l), options.console)); - offsets_.push_back(to); - } -} - -// Vuelve a cargar los offsets -void Resource::reLoadOffsets() -{ - for (auto &o : offsets_) - { - delete o.textFile; - o.textFile = std::make_shared(LoadTextFile(Asset::get()->get(o.name), options.console)); - } -} - -// Carga los mapas de tiles desde una lista -void Resource::loadTileMaps(std::vector list) -{ - for (auto l : list) - { - res_tileMap_t tm; - tm.name = l; - tm.tileMap = new std::vector(loadRoomTileFile(Asset::get()->get(l), options.console)); - tile_maps_.push_back(tm); - } -} - -// Vuelve a cargar los mapas de tiles -void Resource::reLoadTileMaps() -{ - for (auto &tm : tile_maps_) - { - delete tm.tileMap; - tm.tileMap = new std::vector(loadRoomTileFile(Asset::get()->get(tm.name), options.console)); - } -} - -// Carga las habitaciones desde una lista -void Resource::loadRooms(std::vector list) -{ - for (auto l : list) - { - res_room_t r; - r.name = l; - r.room = new room_t(loadRoomFile(Asset::get()->get(l), options.console)); - r.room->tileMap = getTileMap(r.room->tileMapFile); - for (auto &e : r.room->enemies) - { - e.animation = getAnimation(e.animationString); - } - for (auto &i : r.room->items) - { - i.texture = getTexture(i.tileSetFile); - } - r.room->textureA = getTexture("standard.png"); - r.room->textureB = getTexture("standard_zxarne.png"); - rooms_.push_back(r); - } -} - -// Vuelve a cargar las habitaciones -void Resource::reLoadRooms() -{ - reLoadTileMaps(); - - for (auto &r : rooms_) - { - delete r.room; - r.room = new room_t(loadRoomFile(Asset::get()->get(r.name))); - r.room->tileMap = getTileMap(r.room->tileMapFile); - for (auto &e : r.room->enemies) - { - e.animation = getAnimation(e.animationString); - } - for (auto &i : r.room->items) - { - i.texture = getTexture(i.tileSetFile); - } - r.room->textureA = getTexture("standard.png"); - r.room->textureB = getTexture("standard_zxarne.png"); - } -} - -// Vuelve a cargar todos los recursos -void Resource::reLoad() -{ - reLoadAnimations(); - reLoadOffsets(); - reLoadRooms(); -} - -// Libera las texturas -void Resource::freeTextures() -{ - for (auto texture : textures_) - { - delete texture.texture; - } - textures_.clear(); -} - -// Libera las animaciones -void Resource::freeAnimations() -{ - for (auto a : animations_) - { - delete a.animation; - } - animations_.clear(); -} - -// Libera los offsets -void Resource::freeOffsets() -{ - for (auto o : offsets_) - { - delete o.textFile; - } - offsets_.clear(); -} - -// Libera los mapas de tiles -void Resource::freeTileMaps() -{ - for (auto t : tile_maps_) - { - delete t.tileMap; - } - tile_maps_.clear(); -} - -// Libera las habitaciones -void Resource::freeRooms() -{ - for (auto r : rooms_) - { - delete r.room; - } - rooms_.clear(); -} - -// Libera todos los recursos -void Resource::free() -{ - freeTextures(); - freeAnimations(); - freeOffsets(); - freeTileMaps(); - freeRooms(); -} - -// Obtiene una textura -Texture *Resource::getTexture(std::string name) -{ - for (auto texture : textures_) - { - // if (texture.name.find(name) != std::string::npos) - if (texture.name == name) - { - // std::cout << "\nTEXTURE REQUESTED: " << name << std::endl; - // std::cout << "served: " << texture.name << std::endl; - - return texture.texture; - } - } - - if (options.console) - { - std::cout << "NOT FOUND ON CACHE: " << name << std::endl; - } - return nullptr; -} - -// Obtiene una animación -animatedSprite_t *Resource::getAnimation(std::string name) -{ - for (auto animation : animations_) - { - // if (animation.name.find(name) != std::string::npos) - if (animation.name == name) - { - // std::cout << "\nANIMATION REQUESTED: " << name << std::endl; - // std::cout << "served: " << animation.name << std::endl; - return animation.animation; - } - } - - if (options.console) - { - std::cout << "NOT FOUND ON CACHE: " << name << std::endl; - } - return nullptr; -} - -// Obtiene un offset -textFile_t *Resource::getOffset(std::string name) -{ - for (auto offset : offsets_) - { - // if (offset.name.find(name) != std::string::npos) - if (offset.name == name) - { - return offset.textFile; - } - } - - if (options.console) - { - std::cout << "NOT FOUND ON CACHE: " << name << std::endl; - } - return nullptr; -} - -// Obtiene un mapa de tiles -std::vector *Resource::getTileMap(std::string name) -{ - for (auto tileMap : tile_maps_) - { - // if (tileMap.name.find(name) != std::string::npos) - if (tileMap.name == name) - { - return tileMap.tileMap; - } - } - - if (options.console) - { - std::cout << "NOT FOUND ON CACHE: " << name << std::endl; - } - return nullptr; -} - -// Obtiene una habitacion -room_t *Resource::getRoom(std::string name) -{ - for (auto room : rooms_) - { - // if (room.name.find(name) != std::string::npos) - if (room.name == name) - { - return room.room; - } - } - - if (options.console) - { - std::cout << "NOT FOUND ON CACHE: " << name << std::endl; - } - return nullptr; -} - -// Obtiene todas las habitaciones -std::vector *Resource::getAllRooms() -{ - return &rooms_; -} \ No newline at end of file diff --git a/source/resource_old.h b/source/resource_old.h deleted file mode 100644 index 1f9fa00..0000000 --- a/source/resource_old.h +++ /dev/null @@ -1,142 +0,0 @@ -#pragma once - -#include // Para SDL_Renderer -#include // Para string, basic_string -#include // Para vector -#include // Para shared_ptr -class Asset; -class Texture; -struct animatedSprite_t; -struct Options; -struct room_t; -struct textFile_t; - -struct res_texture_t -{ - std::string name; // Nombre de la textura - std::shared_ptr texture; // La textura -}; - -struct res_animation_t -{ - std::string name; // Nombre de la textura - std::shared_ptr animation; // La animación -}; - -struct res_textOffset_t -{ - std::string name; // Nombre del offset - std::shared_ptr textFile; // Los offsets de la fuente -}; - -struct res_tileMap_t -{ - std::string name; // Nombre del mapa de tiles - std::vector *tileMap; // Vector con los indices del mapa de tiles -}; - -struct res_room_t -{ - std::string name; // Nombre de la habitación - std::shared_ptr room; // Vector con las habitaciones -}; - -// Clase Resource. Almacena recursos de disco en memoria -class Resource -{ -private: - // [SINGLETON] Objeto privado - static Resource *resource_; - - // Variables - std::vector textures_; - std::vector animations_; - std::vector offsets_; - std::vector tile_maps_; - std::vector rooms_; - - // Constructor - Resource() = default; - - // Destructor - ~Resource() = default; - -public: - // [SINGLETON] Crearemos el objeto con esta función estática - static void init(); - - // [SINGLETON] Destruiremos el objeto con esta función estática - static void destroy(); - - // [SINGLETON] Con este método obtenemos el objeto y podemos trabajar con él - static Resource *get(); - - // Carga las texturas de una lista - void loadTextures(std::vector list); - - // Vuelve a cargar las texturas - void reLoadTextures(); - - // Carga las animaciones desde una lista - void loadAnimations(std::vector list); - - // Vuelve a cargar las animaciones - void reLoadAnimations(); - - // Carga los offsets desde una lista - void loadOffsets(std::vector list); - - // Vuelve a cargar los offsets - void reLoadOffsets(); - - // Carga los mapas de tiles desde una lista - void loadTileMaps(std::vector list); - - // Vuelve a cargar los mapas de tiles - void reLoadTileMaps(); - - // Carga las habitaciones desde una lista - void loadRooms(std::vector list); - - // Vuelve a cargar las habitaciones - void reLoadRooms(); - - // Vuelve a cargar todos los recursos - void reLoad(); - - // Libera las texturas - void freeTextures(); - - // Libera las animaciones - void freeAnimations(); - - // Libera los offsets - void freeOffsets(); - - // Libera los mapas de tiles - void freeTileMaps(); - - // Libera las habitaciones - void freeRooms(); - - // Libera todos los recursos - void free(); - - // Obtiene una textura - std::shared_ptr getTexture(std::string name); - - // Obtiene una animación - std::shared_ptr getAnimation(std::string name); - - // Obtiene un offset - textFile_t *getOffset(std::string name); - - // Obtiene un mapa de tiles - std::vector *getTileMap(std::string name); - - // Obtiene una habitacion - room_t *getRoom(std::string name); - - // Obtiene todas las habitaciones - std::vector *getAllRooms(); -}; \ No newline at end of file diff --git a/source/room.cpp b/source/room.cpp index 0aefca4..7064450 100644 --- a/source/room.cpp +++ b/source/room.cpp @@ -7,7 +7,7 @@ #include // Para cout #include // Para basic_stringstream #include "asset.h" // Para Asset -#include "const.h" // Para BLOCK, PLAY_AREA_HEIGHT, PLAY_AREA_W... +#include "defines.h" // Para BLOCK, PLAY_AREA_HEIGHT, PLAY_AREA_W... #include "debug.h" // Para Debug #include "item_tracker.h" // Para ItemTracker #include "jail_audio.h" // Para JA_DeleteSound, JA_LoadSound, JA_Pla... @@ -91,11 +91,10 @@ room_t loadRoomFile(std::string file_path, bool verbose) // Si la linea contiene el texto [enemy] se realiza el proceso de carga de un enemigo if (line == "[enemy]") { - enemy_t enemy; + EnemyData enemy; enemy.flip = false; enemy.mirror = false; enemy.frame = -1; - enemy.palette = Palette::ZXSPECTRUM; do { @@ -268,12 +267,17 @@ bool setVars(room_t *room, std::string var, std::string value) } // Asigna variables a una estructura enemy_t -bool setEnemy(enemy_t *enemy, std::string var, std::string value) +bool setEnemy(EnemyData *enemy, std::string var, std::string value) { // Indicador de éxito en la asignación bool success = true; - if (var == "animation") + if (var == "tileSetFile") + { + enemy->texture_path = value; + } + + else if (var == "animation") { enemy->animation_path = value; } @@ -440,11 +444,9 @@ Room::Room(std::shared_ptr room, std::shared_ptr itemTracke counter = 0; // Crea los enemigos - for (auto &enemy : room->enemies) + for (auto &enemy_data : room->enemies) { - enemy.renderer = renderer; - enemy.palette = options.video.palette; - enemies.push_back(new Enemy(enemy)); + enemies.emplace_back(std::make_shared(enemy_data)); } // Crea los items @@ -457,7 +459,7 @@ Room::Room(std::shared_ptr room, std::shared_ptr itemTracke item.renderer = renderer; item.color1 = stringToColor(options.video.palette, itemColor1); item.color2 = stringToColor(options.video.palette, itemColor2); - items.push_back(new Item(item)); + items.emplace_back(std::make_shared(item)); } } @@ -504,23 +506,7 @@ Room::Room(std::shared_ptr room, std::shared_ptr itemTracke Room::~Room() { // Reclama la memoria utilizada por los objetos - JA_DeleteSound(itemSound); SDL_DestroyTexture(mapTexture); - - for (auto enemy : enemies) - { - delete enemy; - } - - for (auto item : items) - { - delete item; - } - - for (auto a : aTile) - { - delete a.sprite; - } } // Devuelve el nombre de la habitación @@ -835,7 +821,6 @@ bool Room::itemCollision(SDL_Rect &rect) if (checkCollision(rect, items[i]->getCollider())) { itemTracker->addItem(name, items[i]->getPos()); - delete items[i]; items.erase(items.begin() + i); JA_PlaySound(itemSound); *itemsPicked = *itemsPicked + 1; @@ -1316,7 +1301,7 @@ void Room::setAnimatedTiles() const int yc = (tileMap[i] / tileSetWidth) * tileSize; aTile_t at; - at.sprite = new Sprite(x, y, 8, 8, texture, renderer); + at.sprite = std::make_shared(texture, x, y, 8, 8); at.sprite->setClip(xc, yc, 8, 8); at.xcOrig = xc; aTile.push_back(at); @@ -1535,7 +1520,6 @@ void Room::openTheJail() if (name == "THE JAIL") { // Elimina el último enemigo (Bry debe ser el ultimo enemigo definido en el fichero) - delete enemies.back(); enemies.pop_back(); // Abre las puertas diff --git a/source/room.h b/source/room.h index ab569da..de01752 100644 --- a/source/room.h +++ b/source/room.h @@ -7,10 +7,10 @@ #include "enemy.h" // Para enemy_t #include "item.h" // Para item_t #include "utils.h" // Para h_line_t, color_t, d_line_t, v_line_t +#include "item_tracker.h" // Para ItemTracker #include // Para shared_ptr class Asset; class Debug; -class ItemTracker; class Screen; class Sprite; class Texture; @@ -49,7 +49,7 @@ struct room_t std::string tileMapFile; // Fichero con el mapa de indices de tile std::vector tileMap; // Indice de los tiles a dibujar en la habitación int autoSurfaceDirection; // Sentido en el que arrastran las superficies automáticas de la habitación - std::vector enemies; // Listado con los enemigos de la habitación + std::vector enemies; // Listado con los enemigos de la habitación std::vector items; // Listado con los items que hay en la habitación std::shared_ptr textureA; // Textura con los graficos de la habitación std::shared_ptr textureB; // Textura con los graficos de la habitación @@ -65,7 +65,7 @@ std::vector loadRoomTileFile(std::string file_path, bool verbose = false); bool setVars(room_t *room, std::string var, std::string value); // Asigna variables a una estructura enemy_t -bool setEnemy(enemy_t *enemy, std::string var, std::string value); +bool setEnemy(EnemyData *enemy, std::string var, std::string value); // Asigna variables a una estructura item_t bool setItem(item_t *item, std::string var, std::string value); @@ -74,18 +74,18 @@ class Room { private: // Objetos y punteros - Screen *screen; // Objeto encargado de dibujar en pantalla - SDL_Renderer *renderer; // El renderizador de la ventana - Asset *asset; // Objeto con la ruta a todos los ficheros de recursos - Debug *debug; // Objeto para gestionar la información de debug - std::vector enemies; // Listado con los enemigos de la habitación - std::vector items; // Listado con los items que hay en la habitación - std::shared_ptr texture; // Textura con los graficos de la habitación - std::shared_ptr textureA; // Textura con los graficos de la habitación - std::shared_ptr textureB; // Textura con los graficos de la habitación - std::shared_ptr itemTracker; // Lleva el control de los objetos recogidos - SDL_Texture *mapTexture; // Textura para dibujar el mapa de la habitación - int *itemsPicked; // Puntero a la cantidad de items recogidos que lleva el juego + Screen *screen; // Objeto encargado de dibujar en pantalla + SDL_Renderer *renderer; // El renderizador de la ventana + Asset *asset; // Objeto con la ruta a todos los ficheros de recursos + Debug *debug; // Objeto para gestionar la información de debug + std::vector> enemies; // Listado con los enemigos de la habitación + std::vector> items; // Listado con los items que hay en la habitación + std::shared_ptr texture; // Textura con los graficos de la habitación + std::shared_ptr textureA; // Textura con los graficos de la habitación + std::shared_ptr textureB; // Textura con los graficos de la habitación + std::shared_ptr itemTracker; // Lleva el control de los objetos recogidos + SDL_Texture *mapTexture; // Textura para dibujar el mapa de la habitación + int *itemsPicked; // Puntero a la cantidad de items recogidos que lleva el juego // Variables std::string number; // Numero de la habitación diff --git a/source/scoreboard.cpp b/source/scoreboard.cpp index 160b55e..ee07913 100644 --- a/source/scoreboard.cpp +++ b/source/scoreboard.cpp @@ -2,7 +2,7 @@ #include // Para SDL_Rect #include // Para SDL_GetTicks #include "animated_sprite.h" // Para AnimatedSprite -#include "const.h" // Para BLOCK, PLAY_AREA_HEIGHT, PLAY_AREA_WIDTH +#include "defines.h" // Para BLOCK, PLAY_AREA_HEIGHT, PLAY_AREA_WIDTH #include "resource.h" // Para Resource #include "text.h" // Para Text #include "texture.h" // Para Texture @@ -21,10 +21,11 @@ Scoreboard::Scoreboard(board_t *board) { // Reserva memoria para los objetos itemTexture = resource->getTexture("items.png"); + const std::string playerJPG = options.cheats.alternate_skin == Cheat::CheatState::ENABLED ? "player2.jpg" : "player.jpg"; const std::string playerANI = options.cheats.alternate_skin == Cheat::CheatState::ENABLED ? "player2.ani" : "player.ani"; - sprite = std::make_shared(falta_la_textura, resource->getAnimation(playerANI)); + sprite = std::make_shared(resource->getTexture(playerJPG), resource->getAnimation(playerANI)); sprite->setCurrentAnimation("walk_menu"); - text = Resource::get()->getText("smb2.txt"); + text = resource->getText("smb2.txt"); // Inicializa las variables counter = 0; @@ -99,7 +100,7 @@ void Scoreboard::update() updateItemsColor(); if (!paused) - { + { // Si está en pausa no se actualiza el reloj clock = getTime(); } diff --git a/source/scoreboard.h b/source/scoreboard.h index 46098bb..a1b8942 100644 --- a/source/scoreboard.h +++ b/source/scoreboard.h @@ -35,10 +35,10 @@ private: }; // Objetos y punteros - SDL_Renderer *renderer; // El renderizador de la ventana - Resource *resource; // Objeto con los recursos - Asset *asset; // Objeto con la ruta a todos los ficheros de recursos - Text *text; // Objeto para escribir texto + SDL_Renderer *renderer; // El renderizador de la ventana + Resource *resource; // Objeto con los recursos + Asset *asset; // Objeto con la ruta a todos los ficheros de recursos + std::shared_ptr text; // Objeto para escribir texto std::shared_ptr sprite; // Sprite para mostrar las vidas en el marcador std::shared_ptr itemTexture; // Textura con los graficos para las vidas std::shared_ptr board; // Contiene las variables a mostrar en el marcador diff --git a/source/title.cpp b/source/title.cpp index e6e92d7..a86e13f 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -7,7 +7,7 @@ #include // Para basic_ostream, operator<<, basic_ios #include "asset.h" // Para Asset #include "cheevos.h" // Para cheevos_t, Cheevos -#include "const.h" // Para PLAY_AREA_CENTER_X, GAMECANVAS_WIDTH +#include "defines.h" // Para PLAY_AREA_CENTER_X, GAMECANVAS_WIDTH #include "input.h" // Para Input, inputs_e, REPEAT_FALSE, REPEA... #include "resource.h" // Para Resource #include "screen.h" // Para Screen @@ -35,7 +35,7 @@ Title::Title() { texture_ = resource_->getTexture("title_logo.png"); } - sprite_ = std::make_shared(0, 0, texture_->getWidth(), texture_->getHeight(), texture_, renderer_); + sprite_ = std::make_shared(texture_, 0, 0, texture_->getWidth(), texture_->getHeight()); text_ = resource_->getText("smb2.txt"); info_text_ = resource_->getText("subatomic.txt"); @@ -438,7 +438,7 @@ void Title::createCheevosTexture() } // Crea el sprite para el listado de logros - cheevos_sprite_ = std::make_shared((GAMECANVAS_WIDTH - cheevos_texture_->getWidth()) / 2, cheevosTexturePosY, cheevos_texture_->getWidth(), cheevos_texture_->getHeight(), cheevos_texture_, renderer_); + cheevos_sprite_ = std::make_shared(cheevos_texture_, (GAMECANVAS_WIDTH - cheevos_texture_->getWidth()) / 2, cheevosTexturePosY, cheevos_texture_->getWidth(), cheevos_texture_->getHeight()); cheevos_texture_view_ = {0, 0, cheevos_texture_->getWidth(), cheevosTextureViewHeight}; cheevos_sprite_->setClip(cheevos_texture_view_); }