From 342177a751e45c74a52e6392d749f76f0f61b822 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sun, 26 Oct 2025 14:56:56 +0100 Subject: [PATCH] renombrades les clases SSprite a SurfaceSprite --- .../rendering/surface_animated_sprite.cpp | 28 ++++++------ .../rendering/surface_animated_sprite.hpp | 12 ++--- .../core/rendering/surface_moving_sprite.cpp | 38 ++++++++-------- .../core/rendering/surface_moving_sprite.hpp | 10 ++--- source/core/rendering/surface_sprite.cpp | 16 +++---- source/core/rendering/surface_sprite.hpp | 12 ++--- source/core/rendering/text.cpp | 4 +- source/core/rendering/text.hpp | 2 +- source/game/entities/enemy.cpp | 2 +- source/game/entities/enemy.hpp | 8 ++-- source/game/entities/item.cpp | 2 +- source/game/entities/item.hpp | 4 +- source/game/entities/player.cpp | 4 +- source/game/entities/player.hpp | 4 +- source/game/gameplay/room.cpp | 4 +- source/game/gameplay/room.hpp | 6 +-- source/game/gameplay/scoreboard.cpp | 4 +- source/game/gameplay/scoreboard.hpp | 18 ++++---- source/game/scenes/credits.cpp | 7 ++- source/game/scenes/credits.hpp | 14 +++--- source/game/scenes/ending.cpp | 13 +++--- source/game/scenes/ending.hpp | 22 +++++----- source/game/scenes/ending2.cpp | 10 ++--- source/game/scenes/ending2.hpp | 10 ++--- source/game/scenes/game_over.cpp | 9 ++-- source/game/scenes/game_over.hpp | 10 ++--- source/game/scenes/loading_screen.cpp | 9 ++-- source/game/scenes/loading_screen.hpp | 16 +++---- source/game/scenes/logo.cpp | 44 +++++++++++-------- source/game/scenes/logo.hpp | 23 +++++----- source/game/scenes/title.cpp | 11 +++-- source/game/scenes/title.hpp | 24 +++++----- source/game/ui/notifier.cpp | 6 +-- source/game/ui/notifier.hpp | 40 ++++++++--------- 34 files changed, 225 insertions(+), 221 deletions(-) diff --git a/source/core/rendering/surface_animated_sprite.cpp b/source/core/rendering/surface_animated_sprite.cpp index d061a16..92136e1 100644 --- a/source/core/rendering/surface_animated_sprite.cpp +++ b/source/core/rendering/surface_animated_sprite.cpp @@ -31,8 +31,8 @@ Animations loadAnimationsFromFile(const std::string& file_path) { } // Constructor -SAnimatedSprite::SAnimatedSprite(std::shared_ptr surface, const std::string& file_path) - : SMovingSprite(surface) { +SurfaceAnimatedSprite::SurfaceAnimatedSprite(std::shared_ptr surface, const std::string& file_path) + : SurfaceMovingSprite(surface) { // Carga las animaciones if (!file_path.empty()) { Animations v = loadAnimationsFromFile(file_path); @@ -41,15 +41,15 @@ SAnimatedSprite::SAnimatedSprite(std::shared_ptr surface, const std::st } // Constructor -SAnimatedSprite::SAnimatedSprite(std::shared_ptr surface, const Animations& animations) - : SMovingSprite(surface) { +SurfaceAnimatedSprite::SurfaceAnimatedSprite(std::shared_ptr surface, const Animations& animations) + : SurfaceMovingSprite(surface) { if (!animations.empty()) { setAnimations(animations); } } // Obtiene el indice de la animación a partir del nombre -int SAnimatedSprite::getIndex(const std::string& name) { +int SurfaceAnimatedSprite::getIndex(const std::string& name) { auto index = -1; for (const auto& a : animations_) { @@ -63,7 +63,7 @@ int SAnimatedSprite::getIndex(const std::string& name) { } // Calcula el frame correspondiente a la animación -void SAnimatedSprite::animate() { +void SurfaceAnimatedSprite::animate() { if (animations_[current_animation_].speed == 0) { return; } @@ -93,12 +93,12 @@ void SAnimatedSprite::animate() { } // Comprueba si ha terminado la animación -bool SAnimatedSprite::animationIsCompleted() { +bool SurfaceAnimatedSprite::animationIsCompleted() { return animations_[current_animation_].completed; } // Establece la animacion actual -void SAnimatedSprite::setCurrentAnimation(const std::string& name) { +void SurfaceAnimatedSprite::setCurrentAnimation(const std::string& name) { const auto new_animation = getIndex(name); if (current_animation_ != new_animation) { current_animation_ = new_animation; @@ -110,7 +110,7 @@ void SAnimatedSprite::setCurrentAnimation(const std::string& name) { } // Establece la animacion actual -void SAnimatedSprite::setCurrentAnimation(int index) { +void SurfaceAnimatedSprite::setCurrentAnimation(int index) { const auto new_animation = index; if (current_animation_ != new_animation) { current_animation_ = new_animation; @@ -122,20 +122,20 @@ void SAnimatedSprite::setCurrentAnimation(int index) { } // Actualiza las variables del objeto -void SAnimatedSprite::update() { +void SurfaceAnimatedSprite::update() { animate(); - SMovingSprite::update(); + SurfaceMovingSprite::update(); } // Reinicia la animación -void SAnimatedSprite::resetAnimation() { +void SurfaceAnimatedSprite::resetAnimation() { animations_[current_animation_].current_frame = 0; animations_[current_animation_].counter = 0; animations_[current_animation_].completed = false; } // Carga la animación desde un vector de cadenas -void SAnimatedSprite::setAnimations(const Animations& animations) { +void SurfaceAnimatedSprite::setAnimations(const Animations& animations) { float frame_width = 1.0F; float frame_height = 1.0F; int frames_per_row = 1; @@ -221,7 +221,7 @@ void SAnimatedSprite::setAnimations(const Animations& animations) { } // Establece el frame actual de la animación -void SAnimatedSprite::setCurrentAnimationFrame(int num) { +void SurfaceAnimatedSprite::setCurrentAnimationFrame(int num) { // Descarta valores fuera de rango if (num < 0 || num >= static_cast(animations_[current_animation_].frames.size())) { num = 0; diff --git a/source/core/rendering/surface_animated_sprite.hpp b/source/core/rendering/surface_animated_sprite.hpp index 5645a4f..63983aa 100644 --- a/source/core/rendering/surface_animated_sprite.hpp +++ b/source/core/rendering/surface_animated_sprite.hpp @@ -32,7 +32,7 @@ using Animations = std::vector; // Carga las animaciones en un vector(Animations) desde un fichero Animations loadAnimationsFromFile(const std::string& file_path); -class SAnimatedSprite : public SMovingSprite { +class SurfaceAnimatedSprite : public SurfaceMovingSprite { protected: // Variables std::vector animations_; // Vector con las diferentes animaciones @@ -46,13 +46,13 @@ class SAnimatedSprite : public SMovingSprite { public: // Constructor - SAnimatedSprite(std::shared_ptr surface, const std::string& file_path); - SAnimatedSprite(std::shared_ptr surface, const Animations& animations); - explicit SAnimatedSprite(std::shared_ptr surface) - : SMovingSprite(surface) {} + SurfaceAnimatedSprite(std::shared_ptr surface, const std::string& file_path); + SurfaceAnimatedSprite(std::shared_ptr surface, const Animations& animations); + explicit SurfaceAnimatedSprite(std::shared_ptr surface) + : SurfaceMovingSprite(surface) {} // Destructor - virtual ~SAnimatedSprite() override = default; + virtual ~SurfaceAnimatedSprite() override = default; // Actualiza las variables del objeto void update() override; diff --git a/source/core/rendering/surface_moving_sprite.cpp b/source/core/rendering/surface_moving_sprite.cpp index 89ca088..49d6c32 100644 --- a/source/core/rendering/surface_moving_sprite.cpp +++ b/source/core/rendering/surface_moving_sprite.cpp @@ -3,26 +3,26 @@ #include "core/rendering/surface.hpp" // Para Surface // Constructor -SMovingSprite::SMovingSprite(std::shared_ptr surface, SDL_FRect pos, SDL_FlipMode flip) - : SSprite(surface, pos), +SurfaceMovingSprite::SurfaceMovingSprite(std::shared_ptr surface, SDL_FRect pos, SDL_FlipMode flip) + : SurfaceSprite(surface, pos), x_(pos.x), y_(pos.y), - flip_(flip) { SSprite::pos_ = pos; } + flip_(flip) { SurfaceSprite::pos_ = pos; } -SMovingSprite::SMovingSprite(std::shared_ptr surface, SDL_FRect pos) - : SSprite(surface, pos), +SurfaceMovingSprite::SurfaceMovingSprite(std::shared_ptr surface, SDL_FRect pos) + : SurfaceSprite(surface, pos), x_(pos.x), y_(pos.y), - flip_(SDL_FLIP_NONE) { SSprite::pos_ = pos; } + flip_(SDL_FLIP_NONE) { SurfaceSprite::pos_ = pos; } -SMovingSprite::SMovingSprite(std::shared_ptr surface) - : SSprite(surface), +SurfaceMovingSprite::SurfaceMovingSprite(std::shared_ptr surface) + : SurfaceSprite(surface), x_(0.0f), y_(0.0f), - flip_(SDL_FLIP_NONE) { SSprite::clear(); } + flip_(SDL_FLIP_NONE) { SurfaceSprite::clear(); } // Reinicia todas las variables -void SMovingSprite::clear() { +void SurfaceMovingSprite::clear() { x_ = 0.0f; // Posición en el eje X y_ = 0.0f; // Posición en el eje Y @@ -34,11 +34,11 @@ void SMovingSprite::clear() { flip_ = SDL_FLIP_NONE; // Establece como se ha de voltear el sprite - SSprite::clear(); + SurfaceSprite::clear(); } // Mueve el sprite -void SMovingSprite::move() { +void SurfaceMovingSprite::move() { x_ += vx_; y_ += vy_; @@ -50,22 +50,22 @@ void SMovingSprite::move() { } // Actualiza las variables internas del objeto -void SMovingSprite::update() { +void SurfaceMovingSprite::update() { move(); } // Muestra el sprite por pantalla -void SMovingSprite::render() { +void SurfaceMovingSprite::render() { surface_->render(pos_.x, pos_.y, &clip_, flip_); } // Muestra el sprite por pantalla -void SMovingSprite::render(Uint8 source_color, Uint8 target_color) { +void SurfaceMovingSprite::render(Uint8 source_color, Uint8 target_color) { surface_->renderWithColorReplace(pos_.x, pos_.y, source_color, target_color, &clip_, flip_); } // Establece la posición y_ el tamaño del objeto -void SMovingSprite::setPos(SDL_FRect rect) { +void SurfaceMovingSprite::setPos(SDL_FRect rect) { x_ = static_cast(rect.x); y_ = static_cast(rect.y); @@ -73,7 +73,7 @@ void SMovingSprite::setPos(SDL_FRect rect) { } // Establece el valor de las variables -void SMovingSprite::setPos(float x, float y) { +void SurfaceMovingSprite::setPos(float x, float y) { x_ = x; y_ = y; @@ -82,13 +82,13 @@ void SMovingSprite::setPos(float x, float y) { } // Establece el valor de la variable -void SMovingSprite::setPosX(float value) { +void SurfaceMovingSprite::setPosX(float value) { x_ = value; pos_.x = static_cast(x_); } // Establece el valor de la variable -void SMovingSprite::setPosY(float value) { +void SurfaceMovingSprite::setPosY(float value) { y_ = value; pos_.y = static_cast(y_); } \ No newline at end of file diff --git a/source/core/rendering/surface_moving_sprite.hpp b/source/core/rendering/surface_moving_sprite.hpp index 3fa79cd..918653e 100644 --- a/source/core/rendering/surface_moving_sprite.hpp +++ b/source/core/rendering/surface_moving_sprite.hpp @@ -8,7 +8,7 @@ class Surface; // lines 8-8 // Clase SMovingSprite. Añade movimiento y flip al sprite -class SMovingSprite : public SSprite { +class SurfaceMovingSprite : public SurfaceSprite { public: protected: float x_; // Posición en el eje X @@ -27,12 +27,12 @@ class SMovingSprite : public SSprite { public: // Constructor - SMovingSprite(std::shared_ptr surface, SDL_FRect pos, SDL_FlipMode flip); - SMovingSprite(std::shared_ptr surface, SDL_FRect pos); - explicit SMovingSprite(std::shared_ptr surface); + SurfaceMovingSprite(std::shared_ptr surface, SDL_FRect pos, SDL_FlipMode flip); + SurfaceMovingSprite(std::shared_ptr surface, SDL_FRect pos); + explicit SurfaceMovingSprite(std::shared_ptr surface); // Destructor - virtual ~SMovingSprite() override = default; + virtual ~SurfaceMovingSprite() override = default; // Actualiza las variables internas del objeto virtual void update(); diff --git a/source/core/rendering/surface_sprite.cpp b/source/core/rendering/surface_sprite.cpp index 42d88cf..05c0994 100644 --- a/source/core/rendering/surface_sprite.cpp +++ b/source/core/rendering/surface_sprite.cpp @@ -3,44 +3,44 @@ #include "core/rendering/surface.hpp" // Para Surface // Constructor -SSprite::SSprite(std::shared_ptr surface, float x, float y, float w, float h) +SurfaceSprite::SurfaceSprite(std::shared_ptr surface, float x, float y, float w, float h) : surface_(surface), pos_((SDL_FRect){x, y, w, h}), clip_((SDL_FRect){0.0F, 0.0F, pos_.w, pos_.h}) {} -SSprite::SSprite(std::shared_ptr surface, SDL_FRect rect) +SurfaceSprite::SurfaceSprite(std::shared_ptr surface, SDL_FRect rect) : surface_(surface), pos_(rect), clip_((SDL_FRect){0, 0, pos_.w, pos_.h}) {} -SSprite::SSprite(std::shared_ptr surface) +SurfaceSprite::SurfaceSprite(std::shared_ptr surface) : surface_(surface), pos_((SDL_FRect){0.0F, 0.0F, surface_->getWidth(), surface_->getHeight()}), clip_(pos_) {} // Muestra el sprite por pantalla -void SSprite::render() { +void SurfaceSprite::render() { surface_->render(pos_.x, pos_.y, &clip_); } -void SSprite::render(Uint8 source_color, Uint8 target_color) { +void SurfaceSprite::render(Uint8 source_color, Uint8 target_color) { surface_->renderWithColorReplace(pos_.x, pos_.y, source_color, target_color, &clip_); } // Establece la posición del objeto -void SSprite::setPosition(float x, float y) { +void SurfaceSprite::setPosition(float x, float y) { pos_.x = x; pos_.y = y; } // Establece la posición del objeto -void SSprite::setPosition(SDL_FPoint p) { +void SurfaceSprite::setPosition(SDL_FPoint p) { pos_.x = p.x; pos_.y = p.y; } // Reinicia las variables a cero -void SSprite::clear() { +void SurfaceSprite::clear() { pos_ = {0, 0, 0, 0}; clip_ = {0, 0, 0, 0}; } \ No newline at end of file diff --git a/source/core/rendering/surface_sprite.hpp b/source/core/rendering/surface_sprite.hpp index e0d1943..5f69f5e 100644 --- a/source/core/rendering/surface_sprite.hpp +++ b/source/core/rendering/surface_sprite.hpp @@ -5,8 +5,8 @@ #include // Para shared_ptr class Surface; // lines 5-5 -// Clase SSprite -class SSprite { +// Clase SurfaceSprite +class SurfaceSprite { protected: // Variables std::shared_ptr surface_; // Surface donde estan todos los dibujos del sprite @@ -15,12 +15,12 @@ class SSprite { public: // Constructor - SSprite(std::shared_ptr, float x, float y, float w, float h); - SSprite(std::shared_ptr, SDL_FRect rect); - explicit SSprite(std::shared_ptr); + SurfaceSprite(std::shared_ptr, float x, float y, float w, float h); + SurfaceSprite(std::shared_ptr, SDL_FRect rect); + explicit SurfaceSprite(std::shared_ptr); // Destructor - virtual ~SSprite() = default; + virtual ~SurfaceSprite() = default; // Muestra el sprite por pantalla virtual void render(); diff --git a/source/core/rendering/text.cpp b/source/core/rendering/text.cpp index 4fe5a74..a5dbbb5 100644 --- a/source/core/rendering/text.cpp +++ b/source/core/rendering/text.cpp @@ -88,7 +88,7 @@ Text::Text(std::shared_ptr surface, const std::string& text_file) { } // Crea los objetos - sprite_ = std::make_unique(surface, (SDL_FRect){0.0F, 0.0F, static_cast(box_width_), static_cast(box_height_)}); + sprite_ = std::make_unique(surface, (SDL_FRect){0.0F, 0.0F, static_cast(box_width_), static_cast(box_height_)}); // Inicializa variables fixed_width_ = false; @@ -106,7 +106,7 @@ Text::Text(std::shared_ptr surface, std::shared_ptr text_file } // Crea los objetos - sprite_ = std::make_unique(surface, (SDL_FRect){0.0F, 0.0F, static_cast(box_width_), static_cast(box_height_)}); + sprite_ = std::make_unique(surface, (SDL_FRect){0.0F, 0.0F, static_cast(box_width_), static_cast(box_height_)}); // Inicializa variables fixed_width_ = false; diff --git a/source/core/rendering/text.hpp b/source/core/rendering/text.hpp index 0ac7e1b..d7d0b6b 100644 --- a/source/core/rendering/text.hpp +++ b/source/core/rendering/text.hpp @@ -30,7 +30,7 @@ std::shared_ptr loadTextFile(const std::string& file_path); class Text { private: // Objetos y punteros - std::unique_ptr sprite_ = nullptr; // Objeto con los graficos para el texto + std::unique_ptr sprite_ = nullptr; // Objeto con los graficos para el texto // Variables int box_width_ = 0; // Anchura de la caja de cada caracter en el png diff --git a/source/game/entities/enemy.cpp b/source/game/entities/enemy.cpp index 614cb18..ab1bcde 100644 --- a/source/game/entities/enemy.cpp +++ b/source/game/entities/enemy.cpp @@ -9,7 +9,7 @@ // Constructor Enemy::Enemy(const EnemyData& enemy) - : sprite_(std::make_shared(Resource::get()->getSurface(enemy.surface_path), Resource::get()->getAnimations(enemy.animation_path))), + : sprite_(std::make_shared(Resource::get()->getSurface(enemy.surface_path), Resource::get()->getAnimations(enemy.animation_path))), color_string_(enemy.color), x1_(enemy.x1), x2_(enemy.x2), diff --git a/source/game/entities/enemy.hpp b/source/game/entities/enemy.hpp index 7f668dd..036e932 100644 --- a/source/game/entities/enemy.hpp +++ b/source/game/entities/enemy.hpp @@ -2,9 +2,9 @@ #include -#include // Para shared_ptr -#include // Para string -class SAnimatedSprite; // lines 7-7 +#include // Para shared_ptr +#include // Para string +class SurfaceAnimatedSprite; // lines 7-7 // Estructura para pasar los datos de un enemigo struct EnemyData { @@ -29,7 +29,7 @@ struct EnemyData { class Enemy { private: // Objetos y punteros - std::shared_ptr sprite_; // Sprite del enemigo + std::shared_ptr sprite_; // Sprite del enemigo // Variables Uint8 color_; // Color del enemigo diff --git a/source/game/entities/item.cpp b/source/game/entities/item.cpp index 809d9b8..4247778 100644 --- a/source/game/entities/item.cpp +++ b/source/game/entities/item.cpp @@ -5,7 +5,7 @@ // Constructor Item::Item(ItemData item) - : sprite_(std::make_shared(Resource::get()->getSurface(item.tile_set_file), item.x, item.y, ITEM_SIZE_, ITEM_SIZE_)), + : sprite_(std::make_shared(Resource::get()->getSurface(item.tile_set_file), item.x, item.y, ITEM_SIZE_, ITEM_SIZE_)), change_color_speed(4) { // Inicia variables sprite_->setClip((item.tile % 10) * ITEM_SIZE_, (item.tile / 10) * ITEM_SIZE_, ITEM_SIZE_, ITEM_SIZE_); diff --git a/source/game/entities/item.hpp b/source/game/entities/item.hpp index e1c21fe..95b27ea 100644 --- a/source/game/entities/item.hpp +++ b/source/game/entities/item.hpp @@ -5,7 +5,7 @@ #include // Para shared_ptr #include // Para string #include // Para vector -class SSprite; +class SurfaceSprite; struct ItemData { std::string tile_set_file; // Ruta al fichero con los gráficos del item @@ -32,7 +32,7 @@ class Item { static constexpr float ITEM_SIZE_ = 8; // Objetos y punteros - std::shared_ptr sprite_; // SSprite del objeto + std::shared_ptr sprite_; // SSprite del objeto // Variables std::vector color_; // Vector con los colores del objeto diff --git a/source/game/entities/player.cpp b/source/game/entities/player.cpp index ed45046..7fb6a20 100644 --- a/source/game/entities/player.cpp +++ b/source/game/entities/player.cpp @@ -9,8 +9,8 @@ #include "core/resources/resource.hpp" // Para Resource #include "core/system/debug.hpp" // Para Debug #include "external/jail_audio.h" // Para JA_PlaySound -#include "game/options.hpp" // Para Cheat, Options, options #include "game/gameplay/room.hpp" // Para Room, TileType +#include "game/options.hpp" // Para Cheat, Options, options #include "utils/defines.hpp" // Para RoomBorder::BOTTOM, RoomBorder::LEFT, RoomBorder::RIGHT // Constructor @@ -621,7 +621,7 @@ void Player::initSprite(const std::string& surface_path, const std::string& anim auto surface = Resource::get()->getSurface(surface_path); auto animations = Resource::get()->getAnimations(animations_path); - sprite_ = std::make_shared(surface, animations); + sprite_ = std::make_shared(surface, animations); sprite_->setWidth(WIDTH_); sprite_->setHeight(HEIGHT_); sprite_->setCurrentAnimation("walk"); diff --git a/source/game/entities/player.hpp b/source/game/entities/player.hpp index b0cccfc..690931b 100644 --- a/source/game/entities/player.hpp +++ b/source/game/entities/player.hpp @@ -71,8 +71,8 @@ class Player { 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 - std::shared_ptr sprite_; // Sprite del jugador + std::shared_ptr room_; // Objeto encargado de gestionar cada habitación del juego + std::shared_ptr sprite_; // Sprite del jugador // Variables float x_; // Posición del jugador en el eje X diff --git a/source/game/gameplay/room.cpp b/source/game/gameplay/room.cpp index 1273921..6c15758 100644 --- a/source/game/gameplay/room.cpp +++ b/source/game/gameplay/room.cpp @@ -12,8 +12,8 @@ #include "core/system/debug.hpp" // Para Debug #include "external/jail_audio.h" // Para JA_PlaySound #include "game/gameplay/item_tracker.hpp" // Para ItemTracker -#include "game/options.hpp" // Para Options, OptionsStats, options #include "game/gameplay/scoreboard.hpp" // Para ScoreboardData +#include "game/options.hpp" // Para Options, OptionsStats, options #include "utils/defines.hpp" // Para BLOCK, PLAY_AREA_HEIGHT, PLAY_AREA_WIDTH #include "utils/utils.hpp" // Para LineHorizontal, LineDiagonal, LineVertical @@ -931,7 +931,7 @@ void Room::setAnimatedTiles() { const int yc = (tile_map_[i] / tile_set_width_) * TILE_SIZE_; AnimatedTile at; - at.sprite = std::make_shared(surface_, x, y, 8, 8); + at.sprite = std::make_shared(surface_, x, y, 8, 8); at.sprite->setClip(xc, yc, 8, 8); at.x_orig = xc; animated_tiles_.push_back(at); diff --git a/source/game/gameplay/room.hpp b/source/game/gameplay/room.hpp index a0654c0..25aeaf6 100644 --- a/source/game/gameplay/room.hpp +++ b/source/game/gameplay/room.hpp @@ -9,7 +9,7 @@ #include "game/entities/enemy.hpp" // Para EnemyData #include "game/entities/item.hpp" // Para ItemData #include "utils/utils.hpp" // Para LineHorizontal, LineDiagonal, LineVertical -class SSprite; // lines 12-12 +class SurfaceSprite; // lines 12-12 class Surface; // lines 13-13 struct ScoreboardData; // lines 15-15 @@ -31,8 +31,8 @@ enum class RoomBorder : int { }; struct AnimatedTile { - std::shared_ptr sprite; // SSprite para dibujar el tile - int x_orig; // Poicion X donde se encuentra el primer tile de la animacion en la tilesheet + std::shared_ptr sprite; // SSprite para dibujar el tile + int x_orig; // Poicion X donde se encuentra el primer tile de la animacion en la tilesheet }; struct RoomData { diff --git a/source/game/gameplay/scoreboard.cpp b/source/game/gameplay/scoreboard.cpp index c752670..d6317a9 100644 --- a/source/game/gameplay/scoreboard.cpp +++ b/source/game/gameplay/scoreboard.cpp @@ -7,7 +7,7 @@ #include "core/rendering/surface_animated_sprite.hpp" // Para SAnimatedSprite #include "core/rendering/text.hpp" // Para Text #include "core/resources/resource.hpp" // Para Resource -#include "game/options.hpp" // Para Options, options, Cheat, OptionsGame +#include "game/options.hpp" // Para Options, options, Cheat, OptionsGame #include "utils/defines.hpp" // Para BLOCK #include "utils/utils.hpp" // Para stringToColor @@ -22,7 +22,7 @@ Scoreboard::Scoreboard(std::shared_ptr data) // Reserva memoria para los objetos auto player_texture = Resource::get()->getSurface(Options::cheats.alternate_skin == Options::Cheat::State::ENABLED ? "player2.gif" : "player.gif"); auto player_animations = Resource::get()->getAnimations(Options::cheats.alternate_skin == Options::Cheat::State::ENABLED ? "player2.ani" : "player.ani"); - player_sprite_ = std::make_shared(player_texture, player_animations); + player_sprite_ = std::make_shared(player_texture, player_animations); player_sprite_->setCurrentAnimation("walk_menu"); surface_ = std::make_shared(SURFACE_WIDTH_, SURFACE_HEIGHT_); diff --git a/source/game/gameplay/scoreboard.hpp b/source/game/gameplay/scoreboard.hpp index 9fc5212..898546a 100644 --- a/source/game/gameplay/scoreboard.hpp +++ b/source/game/gameplay/scoreboard.hpp @@ -2,11 +2,11 @@ #include -#include // Para shared_ptr -#include // Para string, basic_string -#include // Para vector -class SAnimatedSprite; // lines 10-10 -class Surface; // lines 11-11 +#include // Para shared_ptr +#include // Para string, basic_string +#include // Para vector +class SurfaceAnimatedSprite; // lines 10-10 +class Surface; // lines 11-11 struct ScoreboardData { int items; // Lleva la cuenta de los objetos recogidos @@ -62,10 +62,10 @@ class Scoreboard { }; // Objetos y punteros - std::shared_ptr player_sprite_; // Sprite para mostrar las vidas en el marcador - std::shared_ptr item_surface_; // Surface con los graficos para los elementos del marcador - std::shared_ptr data_; // Contiene las variables a mostrar en el marcador - std::shared_ptr surface_; // Surface donde dibujar el marcador; + std::shared_ptr player_sprite_; // Sprite para mostrar las vidas en el marcador + std::shared_ptr item_surface_; // Surface con los graficos para los elementos del marcador + std::shared_ptr data_; // Contiene las variables a mostrar en el marcador + std::shared_ptr surface_; // Surface donde dibujar el marcador; // Variables std::vector color_; // Vector con los colores del objeto diff --git a/source/game/scenes/credits.cpp b/source/game/scenes/credits.cpp index a8048f6..d225f3e 100644 --- a/source/game/scenes/credits.cpp +++ b/source/game/scenes/credits.cpp @@ -1,5 +1,3 @@ -#include "game/scene_manager.hpp" // Para SceneManager - #include "game/scenes/credits.hpp" #include @@ -12,14 +10,15 @@ #include "core/rendering/surface_animated_sprite.hpp" // Para SAnimatedSprite #include "core/rendering/text.hpp" // Para Text, TEXT_CENTER, TEXT_COLOR #include "core/resources/resource.hpp" // Para Resource -#include "game/options.hpp" // Para Options, options, OptionsGame, Sectio... +#include "game/options.hpp" // Para Options, options, OptionsGame, Sectio... +#include "game/scene_manager.hpp" // Para SceneManager #include "utils/defines.hpp" // Para GAME_SPEED, PLAY_AREA_CENTER_X, PLAY_... #include "utils/global_events.hpp" // Para check #include "utils/utils.hpp" // Para PaletteColor // Constructor Credits::Credits() - : shining_sprite_(std::make_shared(Resource::get()->getSurface("shine.gif"), Resource::get()->getAnimations("shine.ani"))) { + : shining_sprite_(std::make_shared(Resource::get()->getSurface("shine.gif"), Resource::get()->getAnimations("shine.ani"))) { // Inicializa variables SceneManager::current = SceneManager::Scene::CREDITS; SceneManager::options = SceneManager::Options::NONE; diff --git a/source/game/scenes/credits.hpp b/source/game/scenes/credits.hpp index 1a43004..24e06bc 100644 --- a/source/game/scenes/credits.hpp +++ b/source/game/scenes/credits.hpp @@ -2,10 +2,10 @@ #include -#include // Para shared_ptr -#include // Para string -#include // Para vector -class SAnimatedSprite; // lines 11-11 +#include // Para shared_ptr +#include // Para string +#include // Para vector +class SurfaceAnimatedSprite; // lines 11-11 class Surface; class Credits { @@ -16,9 +16,9 @@ class Credits { }; // Objetos y punteros - std::shared_ptr text_surface_; // Textura para dibujar el texto - std::shared_ptr cover_surface_; // Textura para cubrir el texto - std::shared_ptr shining_sprite_; // Sprite para el brillo del corazón + std::shared_ptr text_surface_; // Textura para dibujar el texto + std::shared_ptr cover_surface_; // Textura para cubrir el texto + std::shared_ptr shining_sprite_; // Sprite para el brillo del corazón // Variables int counter_ = 0; // Contador diff --git a/source/game/scenes/ending.cpp b/source/game/scenes/ending.cpp index 67fcf0a..5a9d249 100644 --- a/source/game/scenes/ending.cpp +++ b/source/game/scenes/ending.cpp @@ -1,5 +1,3 @@ -#include "game/scene_manager.hpp" // Para SceneManager - #include "game/scenes/ending.hpp" #include @@ -13,7 +11,8 @@ #include "core/rendering/text.hpp" // Para Text, TEXT_STROKE #include "core/resources/resource.hpp" // Para Resource #include "external/jail_audio.h" // Para JA_SetVolume, JA_PlayMusic, JA_StopMusic -#include "game/options.hpp" // Para Options, options, OptionsGame, SectionS... +#include "game/options.hpp" // Para Options, options, OptionsGame, SectionS... +#include "game/scene_manager.hpp" // Para SceneManager #include "utils/defines.hpp" // Para GAME_SPEED #include "utils/global_events.hpp" // Para check #include "utils/utils.hpp" // Para PaletteColor @@ -168,7 +167,7 @@ void Ending::iniTexts() { text->writeDX(TEXT_STROKE, 2, 2, txt.caption, 1, text_color, 2, shadow_color); // Crea el sprite - st.image_sprite = std::make_shared(st.image_surface, 0, 0, st.image_surface->getWidth(), st.image_surface->getHeight()); + st.image_sprite = std::make_shared(st.image_surface, 0, 0, st.image_surface->getWidth(), st.image_surface->getHeight()); st.image_sprite->setPosition((Options::game.width - st.image_surface->getWidth()) / 2, txt.pos); // Crea la cover_surface @@ -196,7 +195,7 @@ void Ending::iniTexts() { surface->fillRect(&rect, color); // Crea el sprite - st.cover_sprite = std::make_shared(st.cover_surface, 0, 0, st.cover_surface->getWidth(), st.cover_surface->getHeight() - 8); + st.cover_sprite = std::make_shared(st.cover_surface, 0, 0, st.cover_surface->getWidth(), st.cover_surface->getHeight() - 8); st.cover_sprite->setPosition((Options::game.width - st.cover_surface->getWidth()) / 2, txt.pos); st.cover_sprite->setClip(0, 8, st.cover_surface->getWidth(), st.cover_surface->getHeight()); @@ -233,7 +232,7 @@ void Ending::iniPics() { const float HEIGHT = sp.image_surface->getHeight(); // Crea el sprite - sp.image_sprite = std::make_shared(sp.image_surface, 0, 0, WIDTH, HEIGHT); + sp.image_sprite = std::make_shared(sp.image_surface, 0, 0, WIDTH, HEIGHT); sp.image_sprite->setPosition((Options::game.width - WIDTH) / 2, pic.pos); // Crea la cover_surface @@ -262,7 +261,7 @@ void Ending::iniPics() { surface->fillRect(&rect, color); // Crea el sprite - sp.cover_sprite = std::make_shared(sp.cover_surface, 0, 0, sp.cover_surface->getWidth(), sp.cover_surface->getHeight() - 8); + sp.cover_sprite = std::make_shared(sp.cover_surface, 0, 0, sp.cover_surface->getWidth(), sp.cover_surface->getHeight() - 8); sp.cover_sprite->setPosition((Options::game.width - sp.cover_surface->getWidth()) / 2, pic.pos); sp.cover_sprite->setClip(0, 8, sp.cover_surface->getWidth(), sp.cover_surface->getHeight()); diff --git a/source/game/scenes/ending.hpp b/source/game/scenes/ending.hpp index 1a0d362..6993782 100644 --- a/source/game/scenes/ending.hpp +++ b/source/game/scenes/ending.hpp @@ -2,23 +2,23 @@ #include -#include // Para shared_ptr -#include // Para string -#include // Para vector -class SSprite; // lines 8-8 -class Surface; // lines 9-9 +#include // Para shared_ptr +#include // Para string +#include // Para vector +class SurfaceSprite; // lines 8-8 +class Surface; // lines 9-9 class Ending { private: // Estructuras struct EndingSurface // Estructura con dos texturas y sprites, uno para mostrar y el otro hace de cortinilla { - std::shared_ptr image_surface; // Surface a mostrar - std::shared_ptr image_sprite; // SSprite para mostrar la textura - std::shared_ptr cover_surface; // Surface que cubre a la otra textura - std::shared_ptr cover_sprite; // SSprite para mostrar la textura que cubre a la otra textura - int cover_clip_desp; // Desplazamiento del spriteClip de la textura de cobertura - int cover_clip_height; // Altura del spriteClip de la textura de cobertura + std::shared_ptr image_surface; // Surface a mostrar + std::shared_ptr image_sprite; // SSprite para mostrar la textura + std::shared_ptr cover_surface; // Surface que cubre a la otra textura + std::shared_ptr cover_sprite; // SSprite para mostrar la textura que cubre a la otra textura + int cover_clip_desp; // Desplazamiento del spriteClip de la textura de cobertura + int cover_clip_height; // Altura del spriteClip de la textura de cobertura }; struct TextAndPosition // Estructura con un texto y su posición en el eje Y diff --git a/source/game/scenes/ending2.cpp b/source/game/scenes/ending2.cpp index c589663..27826a1 100644 --- a/source/game/scenes/ending2.cpp +++ b/source/game/scenes/ending2.cpp @@ -12,7 +12,7 @@ #include "core/rendering/text.hpp" // Para Text #include "core/resources/resource.hpp" // Para Resource #include "external/jail_audio.h" // Para JA_SetVolume, JA_PlayMusic, JA_StopMusic -#include "game/options.hpp" // Para Options, options, OptionsGame, Sectio... +#include "game/options.hpp" // Para Options, options, OptionsGame, Sectio... #include "game/scene_manager.hpp" // Para SceneManager #include "utils/defines.hpp" // Para GAMECANVAS_CENTER_X, GAMECANVAS_CENTER_Y #include "utils/global_events.hpp" // Para check @@ -275,7 +275,7 @@ void Ending2::loadSprites() { // Carga los sprites for (const auto& file : sprite_list_) { - sprites_.emplace_back(std::make_shared(Resource::get()->getSurface(file + ".gif"), Resource::get()->getAnimations(file + ".ani"))); + sprites_.emplace_back(std::make_shared(Resource::get()->getSurface(file + ".gif"), Resource::get()->getAnimations(file + ".ani"))); sprite_max_width_ = std::max(sprites_.back()->getWidth(), sprite_max_width_); sprite_max_height_ = std::max(sprites_.back()->getHeight(), sprite_max_height_); } @@ -395,7 +395,7 @@ void Ending2::createSpriteTexts() { // Crea el sprite SDL_FRect pos = {X, Y, W, H}; - sprite_texts_.emplace_back(std::make_shared(surface, pos)); + sprite_texts_.emplace_back(std::make_shared(surface, pos)); sprite_texts_.back()->setVelY(SPRITE_DESP_SPEED_); Screen::get()->setRendererSurface(previuos_renderer); } @@ -426,7 +426,7 @@ void Ending2::createTexts() { // Crea el sprite SDL_FRect pos = {X + DX, Y, W, H}; - texts_.emplace_back(std::make_shared(surface, pos)); + texts_.emplace_back(std::make_shared(surface, pos)); texts_.back()->setVelY(SPRITE_DESP_SPEED_); Screen::get()->setRendererSurface(previuos_renderer); } @@ -455,7 +455,7 @@ void Ending2::createTexts() { // Crea el sprite SDL_FRect pos = {X + DX, Y, W, H}; - texts_.emplace_back(std::make_shared(surface, pos)); + texts_.emplace_back(std::make_shared(surface, pos)); texts_.back()->setVelY(SPRITE_DESP_SPEED_); Screen::get()->setRendererSurface(previuos_renderer); } diff --git a/source/game/scenes/ending2.hpp b/source/game/scenes/ending2.hpp index 057196c..bcd632e 100644 --- a/source/game/scenes/ending2.hpp +++ b/source/game/scenes/ending2.hpp @@ -7,8 +7,8 @@ #include // Para vector #include "utils/defines.hpp" // Para GAMECANVAS_WIDTH, GAMECANVAS_FIRST_QUAR... -class SAnimatedSprite; // lines 9-9 -class SMovingSprite; // lines 10-10 +class SurfaceAnimatedSprite; // lines 9-9 +class SurfaceMovingSprite; // lines 10-10 class Ending2 { private: @@ -62,9 +62,9 @@ class Ending2 { static constexpr int STATE_FADE_DURATION_ = 5000; // Objetos y punteros - std::vector> sprites_; // Vector con todos los sprites a dibujar - std::vector> sprite_texts_; // Vector con los sprites de texto de los sprites - std::vector> texts_; // Vector con los sprites de texto + std::vector> sprites_; // Vector con todos los sprites a dibujar + std::vector> sprite_texts_; // Vector con los sprites de texto de los sprites + std::vector> texts_; // Vector con los sprites de texto // Variables Uint32 ticks_ = 0; // Contador de ticks para ajustar la velocidad del programa diff --git a/source/game/scenes/game_over.cpp b/source/game/scenes/game_over.cpp index e624310..a4748f5 100644 --- a/source/game/scenes/game_over.cpp +++ b/source/game/scenes/game_over.cpp @@ -1,5 +1,3 @@ -#include "game/scene_manager.hpp" // Para SceneManager - #include "game/scenes/game_over.hpp" #include @@ -13,15 +11,16 @@ #include "core/rendering/text.hpp" // Para TEXT_CENTER, TEXT_COLOR, Text #include "core/resources/resource.hpp" // Para Resource #include "external/jail_audio.h" // Para JA_PlayMusic -#include "game/options.hpp" // Para Options, options, OptionsStats, Secti... +#include "game/options.hpp" // Para Options, options, OptionsStats, Secti... +#include "game/scene_manager.hpp" // Para SceneManager #include "utils/defines.hpp" // Para GAMECANVAS_CENTER_X, GAME_SPEED #include "utils/global_events.hpp" // Para check #include "utils/utils.hpp" // Para PaletteColor, stringToColor // Constructor GameOver::GameOver() - : player_sprite_(std::make_shared(Resource::get()->getSurface("player_game_over.gif"), Resource::get()->getAnimations("player_game_over.ani"))), - tv_sprite_(std::make_shared(Resource::get()->getSurface("tv.gif"), Resource::get()->getAnimations("tv.ani"))), + : player_sprite_(std::make_shared(Resource::get()->getSurface("player_game_over.gif"), Resource::get()->getAnimations("player_game_over.ani"))), + tv_sprite_(std::make_shared(Resource::get()->getSurface("tv.gif"), Resource::get()->getAnimations("tv.ani"))), pre_counter_(0), counter_(0), ticks_(0) { diff --git a/source/game/scenes/game_over.hpp b/source/game/scenes/game_over.hpp index 7884ac5..68585d3 100644 --- a/source/game/scenes/game_over.hpp +++ b/source/game/scenes/game_over.hpp @@ -2,9 +2,9 @@ #include -#include // Para shared_ptr -#include // Para vector -class SAnimatedSprite; // lines 7-7 +#include // Para shared_ptr +#include // Para vector +class SurfaceAnimatedSprite; // lines 7-7 class GameOver { private: @@ -14,8 +14,8 @@ class GameOver { static constexpr int COUNTER_FADE_LENGHT_ = 20; // Contador: duración del fade // Objetos y punteros - std::shared_ptr player_sprite_; // Sprite con el jugador - std::shared_ptr tv_sprite_; // Sprite con el televisor + std::shared_ptr player_sprite_; // Sprite con el jugador + std::shared_ptr tv_sprite_; // Sprite con el televisor // Variables int pre_counter_ = 0; // Contador previo diff --git a/source/game/scenes/loading_screen.cpp b/source/game/scenes/loading_screen.cpp index 686a8b2..311073e 100644 --- a/source/game/scenes/loading_screen.cpp +++ b/source/game/scenes/loading_screen.cpp @@ -1,5 +1,3 @@ -#include "game/scene_manager.hpp" // Para SceneManager - #include "game/scenes/loading_screen.hpp" #include @@ -11,7 +9,8 @@ #include "core/rendering/surface_sprite.hpp" // Para SSprite #include "core/resources/resource.hpp" // Para Resource #include "external/jail_audio.h" // Para JA_PlayMusic, JA_SetVolume, JA_StopMusic -#include "game/options.hpp" // Para Options, options, SectionState, Options... +#include "game/options.hpp" // Para Options, options, SectionState, Options... +#include "game/scene_manager.hpp" // Para SceneManager #include "utils/defines.hpp" // Para GAME_SPEED #include "utils/global_events.hpp" // Para check #include "utils/utils.hpp" // Para stringToColor, PaletteColor @@ -20,8 +19,8 @@ LoadingScreen::LoadingScreen() : mono_loading_screen_surface_(Resource::get()->getSurface("loading_screen_bn.gif")), color_loading_screen_surface_(Resource::get()->getSurface("loading_screen_color.gif")), - mono_loading_screen_sprite_(std::make_shared(mono_loading_screen_surface_, 0, 0, mono_loading_screen_surface_->getWidth(), mono_loading_screen_surface_->getHeight())), - color_loading_screen_sprite_(std::make_shared(color_loading_screen_surface_, 0, 0, color_loading_screen_surface_->getWidth(), color_loading_screen_surface_->getHeight())), + mono_loading_screen_sprite_(std::make_shared(mono_loading_screen_surface_, 0, 0, mono_loading_screen_surface_->getWidth(), mono_loading_screen_surface_->getHeight())), + color_loading_screen_sprite_(std::make_shared(color_loading_screen_surface_, 0, 0, color_loading_screen_surface_->getWidth(), color_loading_screen_surface_->getHeight())), screen_surface_(std::make_shared(Options::game.width, Options::game.height)) { // Configura la superficie donde se van a pintar los sprites screen_surface_->clear(static_cast(PaletteColor::WHITE)); diff --git a/source/game/scenes/loading_screen.hpp b/source/game/scenes/loading_screen.hpp index 5702209..16e7a93 100644 --- a/source/game/scenes/loading_screen.hpp +++ b/source/game/scenes/loading_screen.hpp @@ -2,18 +2,18 @@ #include -#include // Para shared_ptr -class SSprite; // lines 7-7 -class Surface; // lines 8-8 +#include // Para shared_ptr +class SurfaceSprite; // lines 7-7 +class Surface; // lines 8-8 class LoadingScreen { private: // Objetos y punteros - std::shared_ptr mono_loading_screen_surface_; // Surface con la pantalla de carga en blanco y negro - std::shared_ptr color_loading_screen_surface_; // Surface con la pantalla de carga en color - std::shared_ptr mono_loading_screen_sprite_; // SSprite para manejar la textura loadingScreenTexture1 - std::shared_ptr color_loading_screen_sprite_; // SSprite para manejar la textura loadingScreenTexture2 - std::shared_ptr screen_surface_; // Surface para dibujar la pantalla de carga + std::shared_ptr mono_loading_screen_surface_; // Surface con la pantalla de carga en blanco y negro + std::shared_ptr color_loading_screen_surface_; // Surface con la pantalla de carga en color + std::shared_ptr mono_loading_screen_sprite_; // SSprite para manejar la textura loadingScreenTexture1 + std::shared_ptr color_loading_screen_sprite_; // SSprite para manejar la textura loadingScreenTexture2 + std::shared_ptr screen_surface_; // Surface para dibujar la pantalla de carga // Variables int pre_counter_ = 0; // Contador previo para realizar una pausa inicial diff --git a/source/game/scenes/logo.cpp b/source/game/scenes/logo.cpp index 3e98060..8c89d04 100644 --- a/source/game/scenes/logo.cpp +++ b/source/game/scenes/logo.cpp @@ -7,7 +7,7 @@ #include "core/rendering/surface.hpp" // Para Surface #include "core/rendering/surface_sprite.hpp" // Para SSprite #include "core/resources/resource.hpp" // Para Resource -#include "game/options.hpp" // Para Options, SectionState, options, Section +#include "game/options.hpp" // Para Options, SectionState, options, Section #include "game/scene_manager.hpp" // Para SceneManager #include "utils/defines.hpp" // Para GAME_SPEED #include "utils/global_events.hpp" // Para check @@ -17,35 +17,24 @@ Logo::Logo() : jailgames_surface_(Resource::get()->getSurface("jailgames.gif")), since_1998_surface_(Resource::get()->getSurface("since_1998.gif")), - since_1998_sprite_(std::make_shared(since_1998_surface_, (256 - since_1998_surface_->getWidth()) / 2, 83 + jailgames_surface_->getHeight() + 5, since_1998_surface_->getWidth(), since_1998_surface_->getHeight())) { + since_1998_sprite_(std::make_shared(since_1998_surface_, (256 - since_1998_surface_->getWidth()) / 2, 83 + jailgames_surface_->getHeight() + 5, since_1998_surface_->getWidth(), since_1998_surface_->getHeight())) { + // Configura variables since_1998_sprite_->setClip(0, 0, since_1998_surface_->getWidth(), since_1998_surface_->getHeight()); since_1998_color_ = static_cast(PaletteColor::BLACK); jailgames_color_ = static_cast(PaletteColor::BRIGHT_WHITE); + // Inicializa variables + SceneManager::current = SceneManager::Scene::LOGO; + // Crea los sprites de cada linea for (int i = 0; i < jailgames_surface_->getHeight(); ++i) { - jailgames_sprite_.push_back(std::make_shared(jailgames_surface_, 0, i, jailgames_surface_->getWidth(), 1)); + jailgames_sprite_.push_back(std::make_shared(jailgames_surface_, 0, i, jailgames_surface_->getWidth(), 1)); jailgames_sprite_.back()->setClip(0, i, jailgames_surface_->getWidth(), 1); jailgames_sprite_.at(i)->setX((i % 2 == 0) ? (256 + (i * 3)) : (-181 - (i * 3))); jailgames_sprite_.at(i)->setY(83 + i); } - // Inicializa variables - SceneManager::current = SceneManager::Scene::LOGO; - - // Inicializa el vector de colores - const std::vector COLORS = { - static_cast(PaletteColor::BLACK), - static_cast(PaletteColor::BLUE), - static_cast(PaletteColor::RED), - static_cast(PaletteColor::MAGENTA), - static_cast(PaletteColor::GREEN), - static_cast(PaletteColor::CYAN), - static_cast(PaletteColor::YELLOW), - static_cast(PaletteColor::BRIGHT_WHITE)}; - for (const auto& color : COLORS) { - color_.push_back(color); - } + initColors(); // Inicializa el vector de colores // Cambia el color del borde Screen::get()->setBorderColor(static_cast(PaletteColor::BLACK)); @@ -220,3 +209,20 @@ void Logo::endSection() { break; } } + +// Inicializa el vector de colores +void Logo::initColors() { + // Inicializa el vector de colores + const std::vector COLORS = { + static_cast(PaletteColor::BLACK), + static_cast(PaletteColor::BLUE), + static_cast(PaletteColor::RED), + static_cast(PaletteColor::MAGENTA), + static_cast(PaletteColor::GREEN), + static_cast(PaletteColor::CYAN), + static_cast(PaletteColor::YELLOW), + static_cast(PaletteColor::BRIGHT_WHITE)}; + for (const auto& color : COLORS) { + color_.push_back(color); + } +} \ No newline at end of file diff --git a/source/game/scenes/logo.hpp b/source/game/scenes/logo.hpp index 6b4e4da..f8c64d5 100644 --- a/source/game/scenes/logo.hpp +++ b/source/game/scenes/logo.hpp @@ -2,10 +2,10 @@ #include -#include // Para shared_ptr -#include // Para vector -class SSprite; // lines 7-7 -class Surface; // lines 8-8 +#include // Para shared_ptr +#include // Para vector +class SurfaceSprite; // lines 7-7 +class Surface; // lines 8-8 class Logo { private: @@ -15,12 +15,12 @@ class Logo { static constexpr int POST_LOGO_ = 20; // Tiempo que dura el logo con el fade al maximo // Objetos y punteros - std::shared_ptr jailgames_surface_; // Textura con los graficos "JAILGAMES" - std::shared_ptr since_1998_surface_; // Textura con los graficos "Since 1998" - std::vector> jailgames_sprite_; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES - std::shared_ptr since_1998_sprite_; // SSprite para manejar la textura2 - Uint8 jailgames_color_ = 0; // Color para el sprite de "JAILGAMES" - Uint8 since_1998_color_ = 0; // Color para el sprite de "Since 1998" + std::shared_ptr jailgames_surface_; // Textura con los graficos "JAILGAMES" + std::shared_ptr since_1998_surface_; // Textura con los graficos "Since 1998" + std::vector> jailgames_sprite_; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES + std::shared_ptr since_1998_sprite_; // SSprite para manejar la textura2 + Uint8 jailgames_color_ = 0; // Color para el sprite de "JAILGAMES" + Uint8 since_1998_color_ = 0; // Color para el sprite de "Since 1998" // Variables std::vector color_; // Vector con los colores para el fade @@ -48,6 +48,9 @@ class Logo { // Termina la sección void endSection(); + // Inicializa el vector de colores + void initColors(); + public: // Constructor Logo(); diff --git a/source/game/scenes/title.cpp b/source/game/scenes/title.cpp index af209a5..425a3e5 100644 --- a/source/game/scenes/title.cpp +++ b/source/game/scenes/title.cpp @@ -1,5 +1,3 @@ -#include "game/scene_manager.hpp" // Para SceneManager - #include "game/scenes/title.hpp" #include @@ -14,7 +12,8 @@ #include "core/rendering/text.hpp" // Para Text, TEXT_CENTER, TEXT_COLOR #include "core/resources/resource.hpp" // Para Resource #include "game/gameplay/cheevos.hpp" // Para Cheevos, Achievement -#include "game/options.hpp" // Para Options, options, SectionState, Section +#include "game/options.hpp" // Para Options, options, SectionState, Section +#include "game/scene_manager.hpp" // Para SceneManager #include "utils/defines.hpp" // Para PLAY_AREA_CENTER_X, GAMECANVAS_WIDTH #include "utils/global_events.hpp" // Para check #include "utils/utils.hpp" // Para stringToColor, PaletteColor, playMusic @@ -22,9 +21,9 @@ // Constructor Title::Title() : title_logo_surface_(Resource::get()->getSurface("title_logo.gif")), - title_logo_sprite_(std::make_shared(title_logo_surface_, 29, 9, title_logo_surface_->getWidth(), title_logo_surface_->getHeight())), + title_logo_sprite_(std::make_shared(title_logo_surface_, 29, 9, title_logo_surface_->getWidth(), title_logo_surface_->getHeight())), loading_screen_surface_(Resource::get()->getSurface("loading_screen_color.gif")), - loading_screen_sprite_(std::make_shared(loading_screen_surface_, 0, 0, loading_screen_surface_->getWidth(), loading_screen_surface_->getHeight())), + loading_screen_sprite_(std::make_shared(loading_screen_surface_, 0, 0, loading_screen_surface_->getWidth(), loading_screen_surface_->getHeight())), bg_surface_(std::make_shared(Options::game.width, Options::game.height)) { // Inicializa variables state_ = SceneManager::options == SceneManager::Options::TITLE_WITH_LOADING_SCREEN ? TitleState::SHOW_LOADING_SCREEN : TitleState::SHOW_MENU; @@ -321,7 +320,7 @@ void Title::createCheevosTexture() { Screen::get()->setRendererSurface(previuos_renderer); // Crea el sprite para el listado de logros - cheevos_sprite_ = std::make_shared(cheevos_surface_, (GAMECANVAS_WIDTH - cheevos_surface_->getWidth()) / 2, CHEEVOS_TEXTURE_POS_Y, cheevos_surface_->getWidth(), cheevos_surface_->getHeight()); + cheevos_sprite_ = std::make_shared(cheevos_surface_, (GAMECANVAS_WIDTH - cheevos_surface_->getWidth()) / 2, CHEEVOS_TEXTURE_POS_Y, cheevos_surface_->getWidth(), cheevos_surface_->getHeight()); cheevos_surface_view_ = {0, 0, cheevos_surface_->getWidth(), CHEEVOS_TEXTURE_VIEW_HEIGHT}; cheevos_sprite_->setClip(cheevos_surface_view_); } diff --git a/source/game/scenes/title.hpp b/source/game/scenes/title.hpp index b93f7c5..7a6f4de 100644 --- a/source/game/scenes/title.hpp +++ b/source/game/scenes/title.hpp @@ -2,11 +2,11 @@ #include -#include // Para shared_ptr -#include // Para string -#include // Para vector -class SSprite; // lines 9-9 -class Surface; // lines 10-10 +#include // Para shared_ptr +#include // Para string +#include // Para vector +class SurfaceSprite; // lines 9-9 +class Surface; // lines 10-10 class Title { private: @@ -23,13 +23,13 @@ class Title { }; // Objetos y punteros - std::shared_ptr title_logo_surface_; // Textura con los graficos - std::shared_ptr title_logo_sprite_; // SSprite para manejar la surface - std::shared_ptr loading_screen_surface_; // Surface con los gráficos de la pantalla de carga - std::shared_ptr loading_screen_sprite_; // SSprite con los gráficos de la pantalla de carga - std::shared_ptr bg_surface_; // Textura para dibujar el fondo de la pantalla - std::shared_ptr cheevos_surface_; // Textura con la lista de logros - std::shared_ptr cheevos_sprite_; // SSprite para manejar la surface con la lista de logros + std::shared_ptr title_logo_surface_; // Textura con los graficos + std::shared_ptr title_logo_sprite_; // SSprite para manejar la surface + std::shared_ptr loading_screen_surface_; // Surface con los gráficos de la pantalla de carga + std::shared_ptr loading_screen_sprite_; // SSprite con los gráficos de la pantalla de carga + std::shared_ptr bg_surface_; // Textura para dibujar el fondo de la pantalla + std::shared_ptr cheevos_surface_; // Textura con la lista de logros + std::shared_ptr cheevos_sprite_; // SSprite para manejar la surface con la lista de logros // Variables int counter_ = 0; // Contador diff --git a/source/game/ui/notifier.cpp b/source/game/ui/notifier.cpp index be26a5d..76fe4ca 100644 --- a/source/game/ui/notifier.cpp +++ b/source/game/ui/notifier.cpp @@ -13,7 +13,7 @@ #include "core/rendering/text.hpp" // Para Text, TEXT_CENTER, TEXT_COLOR #include "core/resources/resource.hpp" // Para Resource #include "external/jail_audio.h" // Para JA_PlaySound -#include "game/options.hpp" // Para Options, options, NotificationPosition +#include "game/options.hpp" // Para Options, options, NotificationPosition #include "utils/utils.hpp" // Para PaletteColor // [SINGLETON] @@ -217,7 +217,7 @@ void Notifier::show(std::vector texts, NotificationText text_is, Ui // Dibuja el icono de la notificación if (has_icons_ && icon >= 0 && texts.size() >= 2) { - auto sp = std::make_unique(icon_surface_, (SDL_FRect){0, 0, ICON_SIZE_, ICON_SIZE_}); + auto sp = std::make_unique(icon_surface_, (SDL_FRect){0, 0, ICON_SIZE_, ICON_SIZE_}); sp->setPosition({PADDING_IN_H, PADDING_IN_V, ICON_SIZE_, ICON_SIZE_}); sp->setClip((SDL_FRect){ICON_SIZE_ * (icon % 10), ICON_SIZE_ * (icon / 10), ICON_SIZE_, ICON_SIZE_}); sp->render(); @@ -245,7 +245,7 @@ void Notifier::show(std::vector texts, NotificationText text_is, Ui Screen::get()->setRendererSurface(previuos_renderer); // Crea el sprite de la notificación - n.sprite = std::make_shared(n.surface, n.rect); + n.sprite = std::make_shared(n.surface, n.rect); // Añade la notificación a la lista notifications_.emplace_back(n); diff --git a/source/game/ui/notifier.hpp b/source/game/ui/notifier.hpp index 33a589b..b7e7e63 100644 --- a/source/game/ui/notifier.hpp +++ b/source/game/ui/notifier.hpp @@ -2,12 +2,12 @@ #include -#include // Para shared_ptr -#include // Para string, basic_string -#include // Para vector -class SSprite; // lines 8-8 -class Surface; // lines 10-10 -class Text; // lines 9-9 +#include // Para shared_ptr +#include // Para string, basic_string +#include // Para vector +class SurfaceSprite; // lines 8-8 +class Surface; // lines 10-10 +class Text; // lines 9-9 // Constantes constexpr Uint32 DEFAULT_NOTIFICATION_DURATION = 2000; @@ -41,20 +41,20 @@ class Notifier { }; struct Notification { - std::shared_ptr surface; // Superficie asociada a la notificación - std::shared_ptr sprite; // Sprite asociado para gráficos o animaciones - std::vector texts; // Lista de textos incluidos en la notificación - NotificationStatus state; // Estado actual de la notificación (RISING, SHOWING, etc.) - NotificationShape shape; // Forma de la notificación (ej. SQUARED o ROUNDED) - SDL_FRect rect; // Dimensiones y posición de la notificación en pantalla - int y; // Posición actual en el eje Y - int travel_dist; // Distancia a recorrer (por ejemplo, en animaciones) - std::string code; // Código identificador único para esta notificación - bool can_be_removed; // Indica si la notificación puede ser eliminada - int height; // Altura de la notificación - Uint32 start_time; // Momento en que se creó la notificación - Uint32 elapsed_time; // Tiempo transcurrido desde la creación - Uint32 display_duration; // Duración total para mostrar la notificación + std::shared_ptr surface; // Superficie asociada a la notificación + std::shared_ptr sprite; // Sprite asociado para gráficos o animaciones + std::vector texts; // Lista de textos incluidos en la notificación + NotificationStatus state; // Estado actual de la notificación (RISING, SHOWING, etc.) + NotificationShape shape; // Forma de la notificación (ej. SQUARED o ROUNDED) + SDL_FRect rect; // Dimensiones y posición de la notificación en pantalla + int y; // Posición actual en el eje Y + int travel_dist; // Distancia a recorrer (por ejemplo, en animaciones) + std::string code; // Código identificador único para esta notificación + bool can_be_removed; // Indica si la notificación puede ser eliminada + int height; // Altura de la notificación + Uint32 start_time; // Momento en que se creó la notificación + Uint32 elapsed_time; // Tiempo transcurrido desde la creación + Uint32 display_duration; // Duración total para mostrar la notificación // Constructor explicit Notification()