renombrades les clases SSprite a SurfaceSprite

This commit is contained in:
2025-10-26 14:56:56 +01:00
parent fdea094e26
commit 342177a751
34 changed files with 225 additions and 221 deletions

View File

@@ -31,8 +31,8 @@ Animations loadAnimationsFromFile(const std::string& file_path) {
} }
// Constructor // Constructor
SAnimatedSprite::SAnimatedSprite(std::shared_ptr<Surface> surface, const std::string& file_path) SurfaceAnimatedSprite::SurfaceAnimatedSprite(std::shared_ptr<Surface> surface, const std::string& file_path)
: SMovingSprite(surface) { : SurfaceMovingSprite(surface) {
// Carga las animaciones // Carga las animaciones
if (!file_path.empty()) { if (!file_path.empty()) {
Animations v = loadAnimationsFromFile(file_path); Animations v = loadAnimationsFromFile(file_path);
@@ -41,15 +41,15 @@ SAnimatedSprite::SAnimatedSprite(std::shared_ptr<Surface> surface, const std::st
} }
// Constructor // Constructor
SAnimatedSprite::SAnimatedSprite(std::shared_ptr<Surface> surface, const Animations& animations) SurfaceAnimatedSprite::SurfaceAnimatedSprite(std::shared_ptr<Surface> surface, const Animations& animations)
: SMovingSprite(surface) { : SurfaceMovingSprite(surface) {
if (!animations.empty()) { if (!animations.empty()) {
setAnimations(animations); setAnimations(animations);
} }
} }
// Obtiene el indice de la animación a partir del nombre // 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; auto index = -1;
for (const auto& a : animations_) { for (const auto& a : animations_) {
@@ -63,7 +63,7 @@ int SAnimatedSprite::getIndex(const std::string& name) {
} }
// Calcula el frame correspondiente a la animación // Calcula el frame correspondiente a la animación
void SAnimatedSprite::animate() { void SurfaceAnimatedSprite::animate() {
if (animations_[current_animation_].speed == 0) { if (animations_[current_animation_].speed == 0) {
return; return;
} }
@@ -93,12 +93,12 @@ void SAnimatedSprite::animate() {
} }
// Comprueba si ha terminado la animación // Comprueba si ha terminado la animación
bool SAnimatedSprite::animationIsCompleted() { bool SurfaceAnimatedSprite::animationIsCompleted() {
return animations_[current_animation_].completed; return animations_[current_animation_].completed;
} }
// Establece la animacion actual // Establece la animacion actual
void SAnimatedSprite::setCurrentAnimation(const std::string& name) { void SurfaceAnimatedSprite::setCurrentAnimation(const std::string& name) {
const auto new_animation = getIndex(name); const auto new_animation = getIndex(name);
if (current_animation_ != new_animation) { if (current_animation_ != new_animation) {
current_animation_ = new_animation; current_animation_ = new_animation;
@@ -110,7 +110,7 @@ void SAnimatedSprite::setCurrentAnimation(const std::string& name) {
} }
// Establece la animacion actual // Establece la animacion actual
void SAnimatedSprite::setCurrentAnimation(int index) { void SurfaceAnimatedSprite::setCurrentAnimation(int index) {
const auto new_animation = index; const auto new_animation = index;
if (current_animation_ != new_animation) { if (current_animation_ != new_animation) {
current_animation_ = new_animation; current_animation_ = new_animation;
@@ -122,20 +122,20 @@ void SAnimatedSprite::setCurrentAnimation(int index) {
} }
// Actualiza las variables del objeto // Actualiza las variables del objeto
void SAnimatedSprite::update() { void SurfaceAnimatedSprite::update() {
animate(); animate();
SMovingSprite::update(); SurfaceMovingSprite::update();
} }
// Reinicia la animación // Reinicia la animación
void SAnimatedSprite::resetAnimation() { void SurfaceAnimatedSprite::resetAnimation() {
animations_[current_animation_].current_frame = 0; animations_[current_animation_].current_frame = 0;
animations_[current_animation_].counter = 0; animations_[current_animation_].counter = 0;
animations_[current_animation_].completed = false; animations_[current_animation_].completed = false;
} }
// Carga la animación desde un vector de cadenas // 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_width = 1.0F;
float frame_height = 1.0F; float frame_height = 1.0F;
int frames_per_row = 1; int frames_per_row = 1;
@@ -221,7 +221,7 @@ void SAnimatedSprite::setAnimations(const Animations& animations) {
} }
// Establece el frame actual de la animación // Establece el frame actual de la animación
void SAnimatedSprite::setCurrentAnimationFrame(int num) { void SurfaceAnimatedSprite::setCurrentAnimationFrame(int num) {
// Descarta valores fuera de rango // Descarta valores fuera de rango
if (num < 0 || num >= static_cast<int>(animations_[current_animation_].frames.size())) { if (num < 0 || num >= static_cast<int>(animations_[current_animation_].frames.size())) {
num = 0; num = 0;

View File

@@ -32,7 +32,7 @@ using Animations = std::vector<std::string>;
// Carga las animaciones en un vector(Animations) desde un fichero // Carga las animaciones en un vector(Animations) desde un fichero
Animations loadAnimationsFromFile(const std::string& file_path); Animations loadAnimationsFromFile(const std::string& file_path);
class SAnimatedSprite : public SMovingSprite { class SurfaceAnimatedSprite : public SurfaceMovingSprite {
protected: protected:
// Variables // Variables
std::vector<AnimationData> animations_; // Vector con las diferentes animaciones std::vector<AnimationData> animations_; // Vector con las diferentes animaciones
@@ -46,13 +46,13 @@ class SAnimatedSprite : public SMovingSprite {
public: public:
// Constructor // Constructor
SAnimatedSprite(std::shared_ptr<Surface> surface, const std::string& file_path); SurfaceAnimatedSprite(std::shared_ptr<Surface> surface, const std::string& file_path);
SAnimatedSprite(std::shared_ptr<Surface> surface, const Animations& animations); SurfaceAnimatedSprite(std::shared_ptr<Surface> surface, const Animations& animations);
explicit SAnimatedSprite(std::shared_ptr<Surface> surface) explicit SurfaceAnimatedSprite(std::shared_ptr<Surface> surface)
: SMovingSprite(surface) {} : SurfaceMovingSprite(surface) {}
// Destructor // Destructor
virtual ~SAnimatedSprite() override = default; virtual ~SurfaceAnimatedSprite() override = default;
// Actualiza las variables del objeto // Actualiza las variables del objeto
void update() override; void update() override;

View File

@@ -3,26 +3,26 @@
#include "core/rendering/surface.hpp" // Para Surface #include "core/rendering/surface.hpp" // Para Surface
// Constructor // Constructor
SMovingSprite::SMovingSprite(std::shared_ptr<Surface> surface, SDL_FRect pos, SDL_FlipMode flip) SurfaceMovingSprite::SurfaceMovingSprite(std::shared_ptr<Surface> surface, SDL_FRect pos, SDL_FlipMode flip)
: SSprite(surface, pos), : SurfaceSprite(surface, pos),
x_(pos.x), x_(pos.x),
y_(pos.y), y_(pos.y),
flip_(flip) { SSprite::pos_ = pos; } flip_(flip) { SurfaceSprite::pos_ = pos; }
SMovingSprite::SMovingSprite(std::shared_ptr<Surface> surface, SDL_FRect pos) SurfaceMovingSprite::SurfaceMovingSprite(std::shared_ptr<Surface> surface, SDL_FRect pos)
: SSprite(surface, pos), : SurfaceSprite(surface, pos),
x_(pos.x), x_(pos.x),
y_(pos.y), y_(pos.y),
flip_(SDL_FLIP_NONE) { SSprite::pos_ = pos; } flip_(SDL_FLIP_NONE) { SurfaceSprite::pos_ = pos; }
SMovingSprite::SMovingSprite(std::shared_ptr<Surface> surface) SurfaceMovingSprite::SurfaceMovingSprite(std::shared_ptr<Surface> surface)
: SSprite(surface), : SurfaceSprite(surface),
x_(0.0f), x_(0.0f),
y_(0.0f), y_(0.0f),
flip_(SDL_FLIP_NONE) { SSprite::clear(); } flip_(SDL_FLIP_NONE) { SurfaceSprite::clear(); }
// Reinicia todas las variables // Reinicia todas las variables
void SMovingSprite::clear() { void SurfaceMovingSprite::clear() {
x_ = 0.0f; // Posición en el eje X x_ = 0.0f; // Posición en el eje X
y_ = 0.0f; // Posición en el eje Y 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 flip_ = SDL_FLIP_NONE; // Establece como se ha de voltear el sprite
SSprite::clear(); SurfaceSprite::clear();
} }
// Mueve el sprite // Mueve el sprite
void SMovingSprite::move() { void SurfaceMovingSprite::move() {
x_ += vx_; x_ += vx_;
y_ += vy_; y_ += vy_;
@@ -50,22 +50,22 @@ void SMovingSprite::move() {
} }
// Actualiza las variables internas del objeto // Actualiza las variables internas del objeto
void SMovingSprite::update() { void SurfaceMovingSprite::update() {
move(); move();
} }
// Muestra el sprite por pantalla // Muestra el sprite por pantalla
void SMovingSprite::render() { void SurfaceMovingSprite::render() {
surface_->render(pos_.x, pos_.y, &clip_, flip_); surface_->render(pos_.x, pos_.y, &clip_, flip_);
} }
// Muestra el sprite por pantalla // 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_); surface_->renderWithColorReplace(pos_.x, pos_.y, source_color, target_color, &clip_, flip_);
} }
// Establece la posición y_ el tamaño del objeto // 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<float>(rect.x); x_ = static_cast<float>(rect.x);
y_ = static_cast<float>(rect.y); y_ = static_cast<float>(rect.y);
@@ -73,7 +73,7 @@ void SMovingSprite::setPos(SDL_FRect rect) {
} }
// Establece el valor de las variables // Establece el valor de las variables
void SMovingSprite::setPos(float x, float y) { void SurfaceMovingSprite::setPos(float x, float y) {
x_ = x; x_ = x;
y_ = y; y_ = y;
@@ -82,13 +82,13 @@ void SMovingSprite::setPos(float x, float y) {
} }
// Establece el valor de la variable // Establece el valor de la variable
void SMovingSprite::setPosX(float value) { void SurfaceMovingSprite::setPosX(float value) {
x_ = value; x_ = value;
pos_.x = static_cast<int>(x_); pos_.x = static_cast<int>(x_);
} }
// Establece el valor de la variable // Establece el valor de la variable
void SMovingSprite::setPosY(float value) { void SurfaceMovingSprite::setPosY(float value) {
y_ = value; y_ = value;
pos_.y = static_cast<int>(y_); pos_.y = static_cast<int>(y_);
} }

View File

@@ -8,7 +8,7 @@
class Surface; // lines 8-8 class Surface; // lines 8-8
// Clase SMovingSprite. Añade movimiento y flip al sprite // Clase SMovingSprite. Añade movimiento y flip al sprite
class SMovingSprite : public SSprite { class SurfaceMovingSprite : public SurfaceSprite {
public: public:
protected: protected:
float x_; // Posición en el eje X float x_; // Posición en el eje X
@@ -27,12 +27,12 @@ class SMovingSprite : public SSprite {
public: public:
// Constructor // Constructor
SMovingSprite(std::shared_ptr<Surface> surface, SDL_FRect pos, SDL_FlipMode flip); SurfaceMovingSprite(std::shared_ptr<Surface> surface, SDL_FRect pos, SDL_FlipMode flip);
SMovingSprite(std::shared_ptr<Surface> surface, SDL_FRect pos); SurfaceMovingSprite(std::shared_ptr<Surface> surface, SDL_FRect pos);
explicit SMovingSprite(std::shared_ptr<Surface> surface); explicit SurfaceMovingSprite(std::shared_ptr<Surface> surface);
// Destructor // Destructor
virtual ~SMovingSprite() override = default; virtual ~SurfaceMovingSprite() override = default;
// Actualiza las variables internas del objeto // Actualiza las variables internas del objeto
virtual void update(); virtual void update();

View File

@@ -3,44 +3,44 @@
#include "core/rendering/surface.hpp" // Para Surface #include "core/rendering/surface.hpp" // Para Surface
// Constructor // Constructor
SSprite::SSprite(std::shared_ptr<Surface> surface, float x, float y, float w, float h) SurfaceSprite::SurfaceSprite(std::shared_ptr<Surface> surface, float x, float y, float w, float h)
: surface_(surface), : surface_(surface),
pos_((SDL_FRect){x, y, w, h}), pos_((SDL_FRect){x, y, w, h}),
clip_((SDL_FRect){0.0F, 0.0F, pos_.w, pos_.h}) {} clip_((SDL_FRect){0.0F, 0.0F, pos_.w, pos_.h}) {}
SSprite::SSprite(std::shared_ptr<Surface> surface, SDL_FRect rect) SurfaceSprite::SurfaceSprite(std::shared_ptr<Surface> surface, SDL_FRect rect)
: surface_(surface), : surface_(surface),
pos_(rect), pos_(rect),
clip_((SDL_FRect){0, 0, pos_.w, pos_.h}) {} clip_((SDL_FRect){0, 0, pos_.w, pos_.h}) {}
SSprite::SSprite(std::shared_ptr<Surface> surface) SurfaceSprite::SurfaceSprite(std::shared_ptr<Surface> surface)
: surface_(surface), : surface_(surface),
pos_((SDL_FRect){0.0F, 0.0F, surface_->getWidth(), surface_->getHeight()}), pos_((SDL_FRect){0.0F, 0.0F, surface_->getWidth(), surface_->getHeight()}),
clip_(pos_) {} clip_(pos_) {}
// Muestra el sprite por pantalla // Muestra el sprite por pantalla
void SSprite::render() { void SurfaceSprite::render() {
surface_->render(pos_.x, pos_.y, &clip_); 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_); surface_->renderWithColorReplace(pos_.x, pos_.y, source_color, target_color, &clip_);
} }
// Establece la posición del objeto // Establece la posición del objeto
void SSprite::setPosition(float x, float y) { void SurfaceSprite::setPosition(float x, float y) {
pos_.x = x; pos_.x = x;
pos_.y = y; pos_.y = y;
} }
// Establece la posición del objeto // Establece la posición del objeto
void SSprite::setPosition(SDL_FPoint p) { void SurfaceSprite::setPosition(SDL_FPoint p) {
pos_.x = p.x; pos_.x = p.x;
pos_.y = p.y; pos_.y = p.y;
} }
// Reinicia las variables a cero // Reinicia las variables a cero
void SSprite::clear() { void SurfaceSprite::clear() {
pos_ = {0, 0, 0, 0}; pos_ = {0, 0, 0, 0};
clip_ = {0, 0, 0, 0}; clip_ = {0, 0, 0, 0};
} }

View File

@@ -5,8 +5,8 @@
#include <memory> // Para shared_ptr #include <memory> // Para shared_ptr
class Surface; // lines 5-5 class Surface; // lines 5-5
// Clase SSprite // Clase SurfaceSprite
class SSprite { class SurfaceSprite {
protected: protected:
// Variables // Variables
std::shared_ptr<Surface> surface_; // Surface donde estan todos los dibujos del sprite std::shared_ptr<Surface> surface_; // Surface donde estan todos los dibujos del sprite
@@ -15,12 +15,12 @@ class SSprite {
public: public:
// Constructor // Constructor
SSprite(std::shared_ptr<Surface>, float x, float y, float w, float h); SurfaceSprite(std::shared_ptr<Surface>, float x, float y, float w, float h);
SSprite(std::shared_ptr<Surface>, SDL_FRect rect); SurfaceSprite(std::shared_ptr<Surface>, SDL_FRect rect);
explicit SSprite(std::shared_ptr<Surface>); explicit SurfaceSprite(std::shared_ptr<Surface>);
// Destructor // Destructor
virtual ~SSprite() = default; virtual ~SurfaceSprite() = default;
// Muestra el sprite por pantalla // Muestra el sprite por pantalla
virtual void render(); virtual void render();

View File

@@ -88,7 +88,7 @@ Text::Text(std::shared_ptr<Surface> surface, const std::string& text_file) {
} }
// Crea los objetos // Crea los objetos
sprite_ = std::make_unique<SSprite>(surface, (SDL_FRect){0.0F, 0.0F, static_cast<float>(box_width_), static_cast<float>(box_height_)}); sprite_ = std::make_unique<SurfaceSprite>(surface, (SDL_FRect){0.0F, 0.0F, static_cast<float>(box_width_), static_cast<float>(box_height_)});
// Inicializa variables // Inicializa variables
fixed_width_ = false; fixed_width_ = false;
@@ -106,7 +106,7 @@ Text::Text(std::shared_ptr<Surface> surface, std::shared_ptr<TextFile> text_file
} }
// Crea los objetos // Crea los objetos
sprite_ = std::make_unique<SSprite>(surface, (SDL_FRect){0.0F, 0.0F, static_cast<float>(box_width_), static_cast<float>(box_height_)}); sprite_ = std::make_unique<SurfaceSprite>(surface, (SDL_FRect){0.0F, 0.0F, static_cast<float>(box_width_), static_cast<float>(box_height_)});
// Inicializa variables // Inicializa variables
fixed_width_ = false; fixed_width_ = false;

View File

@@ -30,7 +30,7 @@ std::shared_ptr<TextFile> loadTextFile(const std::string& file_path);
class Text { class Text {
private: private:
// Objetos y punteros // Objetos y punteros
std::unique_ptr<SSprite> sprite_ = nullptr; // Objeto con los graficos para el texto std::unique_ptr<SurfaceSprite> sprite_ = nullptr; // Objeto con los graficos para el texto
// Variables // Variables
int box_width_ = 0; // Anchura de la caja de cada caracter en el png int box_width_ = 0; // Anchura de la caja de cada caracter en el png

View File

@@ -9,7 +9,7 @@
// Constructor // Constructor
Enemy::Enemy(const EnemyData& enemy) Enemy::Enemy(const EnemyData& enemy)
: sprite_(std::make_shared<SAnimatedSprite>(Resource::get()->getSurface(enemy.surface_path), Resource::get()->getAnimations(enemy.animation_path))), : sprite_(std::make_shared<SurfaceAnimatedSprite>(Resource::get()->getSurface(enemy.surface_path), Resource::get()->getAnimations(enemy.animation_path))),
color_string_(enemy.color), color_string_(enemy.color),
x1_(enemy.x1), x1_(enemy.x1),
x2_(enemy.x2), x2_(enemy.x2),

View File

@@ -2,9 +2,9 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <memory> // Para shared_ptr #include <memory> // Para shared_ptr
#include <string> // Para string #include <string> // Para string
class SAnimatedSprite; // lines 7-7 class SurfaceAnimatedSprite; // lines 7-7
// Estructura para pasar los datos de un enemigo // Estructura para pasar los datos de un enemigo
struct EnemyData { struct EnemyData {
@@ -29,7 +29,7 @@ struct EnemyData {
class Enemy { class Enemy {
private: private:
// Objetos y punteros // Objetos y punteros
std::shared_ptr<SAnimatedSprite> sprite_; // Sprite del enemigo std::shared_ptr<SurfaceAnimatedSprite> sprite_; // Sprite del enemigo
// Variables // Variables
Uint8 color_; // Color del enemigo Uint8 color_; // Color del enemigo

View File

@@ -5,7 +5,7 @@
// Constructor // Constructor
Item::Item(ItemData item) Item::Item(ItemData item)
: sprite_(std::make_shared<SSprite>(Resource::get()->getSurface(item.tile_set_file), item.x, item.y, ITEM_SIZE_, ITEM_SIZE_)), : sprite_(std::make_shared<SurfaceSprite>(Resource::get()->getSurface(item.tile_set_file), item.x, item.y, ITEM_SIZE_, ITEM_SIZE_)),
change_color_speed(4) { change_color_speed(4) {
// Inicia variables // Inicia variables
sprite_->setClip((item.tile % 10) * ITEM_SIZE_, (item.tile / 10) * ITEM_SIZE_, ITEM_SIZE_, ITEM_SIZE_); sprite_->setClip((item.tile % 10) * ITEM_SIZE_, (item.tile / 10) * ITEM_SIZE_, ITEM_SIZE_, ITEM_SIZE_);

View File

@@ -5,7 +5,7 @@
#include <memory> // Para shared_ptr #include <memory> // Para shared_ptr
#include <string> // Para string #include <string> // Para string
#include <vector> // Para vector #include <vector> // Para vector
class SSprite; class SurfaceSprite;
struct ItemData { struct ItemData {
std::string tile_set_file; // Ruta al fichero con los gráficos del item 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; static constexpr float ITEM_SIZE_ = 8;
// Objetos y punteros // Objetos y punteros
std::shared_ptr<SSprite> sprite_; // SSprite del objeto std::shared_ptr<SurfaceSprite> sprite_; // SSprite del objeto
// Variables // Variables
std::vector<Uint8> color_; // Vector con los colores del objeto std::vector<Uint8> color_; // Vector con los colores del objeto

View File

@@ -9,8 +9,8 @@
#include "core/resources/resource.hpp" // Para Resource #include "core/resources/resource.hpp" // Para Resource
#include "core/system/debug.hpp" // Para Debug #include "core/system/debug.hpp" // Para Debug
#include "external/jail_audio.h" // Para JA_PlaySound #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/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 #include "utils/defines.hpp" // Para RoomBorder::BOTTOM, RoomBorder::LEFT, RoomBorder::RIGHT
// Constructor // 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 surface = Resource::get()->getSurface(surface_path);
auto animations = Resource::get()->getAnimations(animations_path); auto animations = Resource::get()->getAnimations(animations_path);
sprite_ = std::make_shared<SAnimatedSprite>(surface, animations); sprite_ = std::make_shared<SurfaceAnimatedSprite>(surface, animations);
sprite_->setWidth(WIDTH_); sprite_->setWidth(WIDTH_);
sprite_->setHeight(HEIGHT_); sprite_->setHeight(HEIGHT_);
sprite_->setCurrentAnimation("walk"); sprite_->setCurrentAnimation("walk");

View File

@@ -71,8 +71,8 @@ class Player {
static constexpr float MAX_VY_ = 1.2f; // Velocidad máxima que puede alcanzar al desplazarse en vertical static constexpr float MAX_VY_ = 1.2f; // Velocidad máxima que puede alcanzar al desplazarse en vertical
// Objetos y punteros // Objetos y punteros
std::shared_ptr<Room> room_; // Objeto encargado de gestionar cada habitación del juego std::shared_ptr<Room> room_; // Objeto encargado de gestionar cada habitación del juego
std::shared_ptr<SAnimatedSprite> sprite_; // Sprite del jugador std::shared_ptr<SurfaceAnimatedSprite> sprite_; // Sprite del jugador
// Variables // Variables
float x_; // Posición del jugador en el eje X float x_; // Posición del jugador en el eje X

View File

@@ -12,8 +12,8 @@
#include "core/system/debug.hpp" // Para Debug #include "core/system/debug.hpp" // Para Debug
#include "external/jail_audio.h" // Para JA_PlaySound #include "external/jail_audio.h" // Para JA_PlaySound
#include "game/gameplay/item_tracker.hpp" // Para ItemTracker #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/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/defines.hpp" // Para BLOCK, PLAY_AREA_HEIGHT, PLAY_AREA_WIDTH
#include "utils/utils.hpp" // Para LineHorizontal, LineDiagonal, LineVertical #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_; const int yc = (tile_map_[i] / tile_set_width_) * TILE_SIZE_;
AnimatedTile at; AnimatedTile at;
at.sprite = std::make_shared<SSprite>(surface_, x, y, 8, 8); at.sprite = std::make_shared<SurfaceSprite>(surface_, x, y, 8, 8);
at.sprite->setClip(xc, yc, 8, 8); at.sprite->setClip(xc, yc, 8, 8);
at.x_orig = xc; at.x_orig = xc;
animated_tiles_.push_back(at); animated_tiles_.push_back(at);

View File

@@ -9,7 +9,7 @@
#include "game/entities/enemy.hpp" // Para EnemyData #include "game/entities/enemy.hpp" // Para EnemyData
#include "game/entities/item.hpp" // Para ItemData #include "game/entities/item.hpp" // Para ItemData
#include "utils/utils.hpp" // Para LineHorizontal, LineDiagonal, LineVertical #include "utils/utils.hpp" // Para LineHorizontal, LineDiagonal, LineVertical
class SSprite; // lines 12-12 class SurfaceSprite; // lines 12-12
class Surface; // lines 13-13 class Surface; // lines 13-13
struct ScoreboardData; // lines 15-15 struct ScoreboardData; // lines 15-15
@@ -31,8 +31,8 @@ enum class RoomBorder : int {
}; };
struct AnimatedTile { struct AnimatedTile {
std::shared_ptr<SSprite> sprite; // SSprite para dibujar el tile std::shared_ptr<SurfaceSprite> sprite; // SSprite para dibujar el tile
int x_orig; // Poicion X donde se encuentra el primer tile de la animacion en la tilesheet int x_orig; // Poicion X donde se encuentra el primer tile de la animacion en la tilesheet
}; };
struct RoomData { struct RoomData {

View File

@@ -7,7 +7,7 @@
#include "core/rendering/surface_animated_sprite.hpp" // Para SAnimatedSprite #include "core/rendering/surface_animated_sprite.hpp" // Para SAnimatedSprite
#include "core/rendering/text.hpp" // Para Text #include "core/rendering/text.hpp" // Para Text
#include "core/resources/resource.hpp" // Para Resource #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/defines.hpp" // Para BLOCK
#include "utils/utils.hpp" // Para stringToColor #include "utils/utils.hpp" // Para stringToColor
@@ -22,7 +22,7 @@ Scoreboard::Scoreboard(std::shared_ptr<ScoreboardData> data)
// Reserva memoria para los objetos // 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_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"); auto player_animations = Resource::get()->getAnimations(Options::cheats.alternate_skin == Options::Cheat::State::ENABLED ? "player2.ani" : "player.ani");
player_sprite_ = std::make_shared<SAnimatedSprite>(player_texture, player_animations); player_sprite_ = std::make_shared<SurfaceAnimatedSprite>(player_texture, player_animations);
player_sprite_->setCurrentAnimation("walk_menu"); player_sprite_->setCurrentAnimation("walk_menu");
surface_ = std::make_shared<Surface>(SURFACE_WIDTH_, SURFACE_HEIGHT_); surface_ = std::make_shared<Surface>(SURFACE_WIDTH_, SURFACE_HEIGHT_);

View File

@@ -2,11 +2,11 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <memory> // Para shared_ptr #include <memory> // Para shared_ptr
#include <string> // Para string, basic_string #include <string> // Para string, basic_string
#include <vector> // Para vector #include <vector> // Para vector
class SAnimatedSprite; // lines 10-10 class SurfaceAnimatedSprite; // lines 10-10
class Surface; // lines 11-11 class Surface; // lines 11-11
struct ScoreboardData { struct ScoreboardData {
int items; // Lleva la cuenta de los objetos recogidos int items; // Lleva la cuenta de los objetos recogidos
@@ -62,10 +62,10 @@ class Scoreboard {
}; };
// Objetos y punteros // Objetos y punteros
std::shared_ptr<SAnimatedSprite> player_sprite_; // Sprite para mostrar las vidas en el marcador std::shared_ptr<SurfaceAnimatedSprite> player_sprite_; // Sprite para mostrar las vidas en el marcador
std::shared_ptr<Surface> item_surface_; // Surface con los graficos para los elementos del marcador std::shared_ptr<Surface> item_surface_; // Surface con los graficos para los elementos del marcador
std::shared_ptr<ScoreboardData> data_; // Contiene las variables a mostrar en el marcador std::shared_ptr<ScoreboardData> data_; // Contiene las variables a mostrar en el marcador
std::shared_ptr<Surface> surface_; // Surface donde dibujar el marcador; std::shared_ptr<Surface> surface_; // Surface donde dibujar el marcador;
// Variables // Variables
std::vector<Uint8> color_; // Vector con los colores del objeto std::vector<Uint8> color_; // Vector con los colores del objeto

View File

@@ -1,5 +1,3 @@
#include "game/scene_manager.hpp" // Para SceneManager
#include "game/scenes/credits.hpp" #include "game/scenes/credits.hpp"
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
@@ -12,14 +10,15 @@
#include "core/rendering/surface_animated_sprite.hpp" // Para SAnimatedSprite #include "core/rendering/surface_animated_sprite.hpp" // Para SAnimatedSprite
#include "core/rendering/text.hpp" // Para Text, TEXT_CENTER, TEXT_COLOR #include "core/rendering/text.hpp" // Para Text, TEXT_CENTER, TEXT_COLOR
#include "core/resources/resource.hpp" // Para Resource #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/defines.hpp" // Para GAME_SPEED, PLAY_AREA_CENTER_X, PLAY_...
#include "utils/global_events.hpp" // Para check #include "utils/global_events.hpp" // Para check
#include "utils/utils.hpp" // Para PaletteColor #include "utils/utils.hpp" // Para PaletteColor
// Constructor // Constructor
Credits::Credits() Credits::Credits()
: shining_sprite_(std::make_shared<SAnimatedSprite>(Resource::get()->getSurface("shine.gif"), Resource::get()->getAnimations("shine.ani"))) { : shining_sprite_(std::make_shared<SurfaceAnimatedSprite>(Resource::get()->getSurface("shine.gif"), Resource::get()->getAnimations("shine.ani"))) {
// Inicializa variables // Inicializa variables
SceneManager::current = SceneManager::Scene::CREDITS; SceneManager::current = SceneManager::Scene::CREDITS;
SceneManager::options = SceneManager::Options::NONE; SceneManager::options = SceneManager::Options::NONE;

View File

@@ -2,10 +2,10 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <memory> // Para shared_ptr #include <memory> // Para shared_ptr
#include <string> // Para string #include <string> // Para string
#include <vector> // Para vector #include <vector> // Para vector
class SAnimatedSprite; // lines 11-11 class SurfaceAnimatedSprite; // lines 11-11
class Surface; class Surface;
class Credits { class Credits {
@@ -16,9 +16,9 @@ class Credits {
}; };
// Objetos y punteros // Objetos y punteros
std::shared_ptr<Surface> text_surface_; // Textura para dibujar el texto std::shared_ptr<Surface> text_surface_; // Textura para dibujar el texto
std::shared_ptr<Surface> cover_surface_; // Textura para cubrir el texto std::shared_ptr<Surface> cover_surface_; // Textura para cubrir el texto
std::shared_ptr<SAnimatedSprite> shining_sprite_; // Sprite para el brillo del corazón std::shared_ptr<SurfaceAnimatedSprite> shining_sprite_; // Sprite para el brillo del corazón
// Variables // Variables
int counter_ = 0; // Contador int counter_ = 0; // Contador

View File

@@ -1,5 +1,3 @@
#include "game/scene_manager.hpp" // Para SceneManager
#include "game/scenes/ending.hpp" #include "game/scenes/ending.hpp"
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
@@ -13,7 +11,8 @@
#include "core/rendering/text.hpp" // Para Text, TEXT_STROKE #include "core/rendering/text.hpp" // Para Text, TEXT_STROKE
#include "core/resources/resource.hpp" // Para Resource #include "core/resources/resource.hpp" // Para Resource
#include "external/jail_audio.h" // Para JA_SetVolume, JA_PlayMusic, JA_StopMusic #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/defines.hpp" // Para GAME_SPEED
#include "utils/global_events.hpp" // Para check #include "utils/global_events.hpp" // Para check
#include "utils/utils.hpp" // Para PaletteColor #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); text->writeDX(TEXT_STROKE, 2, 2, txt.caption, 1, text_color, 2, shadow_color);
// Crea el sprite // Crea el sprite
st.image_sprite = std::make_shared<SSprite>(st.image_surface, 0, 0, st.image_surface->getWidth(), st.image_surface->getHeight()); st.image_sprite = std::make_shared<SurfaceSprite>(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); st.image_sprite->setPosition((Options::game.width - st.image_surface->getWidth()) / 2, txt.pos);
// Crea la cover_surface // Crea la cover_surface
@@ -196,7 +195,7 @@ void Ending::iniTexts() {
surface->fillRect(&rect, color); surface->fillRect(&rect, color);
// Crea el sprite // Crea el sprite
st.cover_sprite = std::make_shared<SSprite>(st.cover_surface, 0, 0, st.cover_surface->getWidth(), st.cover_surface->getHeight() - 8); st.cover_sprite = std::make_shared<SurfaceSprite>(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->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()); 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(); const float HEIGHT = sp.image_surface->getHeight();
// Crea el sprite // Crea el sprite
sp.image_sprite = std::make_shared<SSprite>(sp.image_surface, 0, 0, WIDTH, HEIGHT); sp.image_sprite = std::make_shared<SurfaceSprite>(sp.image_surface, 0, 0, WIDTH, HEIGHT);
sp.image_sprite->setPosition((Options::game.width - WIDTH) / 2, pic.pos); sp.image_sprite->setPosition((Options::game.width - WIDTH) / 2, pic.pos);
// Crea la cover_surface // Crea la cover_surface
@@ -262,7 +261,7 @@ void Ending::iniPics() {
surface->fillRect(&rect, color); surface->fillRect(&rect, color);
// Crea el sprite // Crea el sprite
sp.cover_sprite = std::make_shared<SSprite>(sp.cover_surface, 0, 0, sp.cover_surface->getWidth(), sp.cover_surface->getHeight() - 8); sp.cover_sprite = std::make_shared<SurfaceSprite>(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->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()); sp.cover_sprite->setClip(0, 8, sp.cover_surface->getWidth(), sp.cover_surface->getHeight());

View File

@@ -2,23 +2,23 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <memory> // Para shared_ptr #include <memory> // Para shared_ptr
#include <string> // Para string #include <string> // Para string
#include <vector> // Para vector #include <vector> // Para vector
class SSprite; // lines 8-8 class SurfaceSprite; // lines 8-8
class Surface; // lines 9-9 class Surface; // lines 9-9
class Ending { class Ending {
private: private:
// Estructuras // Estructuras
struct EndingSurface // Estructura con dos texturas y sprites, uno para mostrar y el otro hace de cortinilla struct EndingSurface // Estructura con dos texturas y sprites, uno para mostrar y el otro hace de cortinilla
{ {
std::shared_ptr<Surface> image_surface; // Surface a mostrar std::shared_ptr<Surface> image_surface; // Surface a mostrar
std::shared_ptr<SSprite> image_sprite; // SSprite para mostrar la textura std::shared_ptr<SurfaceSprite> image_sprite; // SSprite para mostrar la textura
std::shared_ptr<Surface> cover_surface; // Surface que cubre a la otra textura std::shared_ptr<Surface> cover_surface; // Surface que cubre a la otra textura
std::shared_ptr<SSprite> cover_sprite; // SSprite para mostrar la textura que cubre a la otra textura std::shared_ptr<SurfaceSprite> 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_desp; // Desplazamiento del spriteClip de la textura de cobertura
int cover_clip_height; // Altura 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 struct TextAndPosition // Estructura con un texto y su posición en el eje Y

View File

@@ -12,7 +12,7 @@
#include "core/rendering/text.hpp" // Para Text #include "core/rendering/text.hpp" // Para Text
#include "core/resources/resource.hpp" // Para Resource #include "core/resources/resource.hpp" // Para Resource
#include "external/jail_audio.h" // Para JA_SetVolume, JA_PlayMusic, JA_StopMusic #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 "game/scene_manager.hpp" // Para SceneManager
#include "utils/defines.hpp" // Para GAMECANVAS_CENTER_X, GAMECANVAS_CENTER_Y #include "utils/defines.hpp" // Para GAMECANVAS_CENTER_X, GAMECANVAS_CENTER_Y
#include "utils/global_events.hpp" // Para check #include "utils/global_events.hpp" // Para check
@@ -275,7 +275,7 @@ void Ending2::loadSprites() {
// Carga los sprites // Carga los sprites
for (const auto& file : sprite_list_) { for (const auto& file : sprite_list_) {
sprites_.emplace_back(std::make_shared<SAnimatedSprite>(Resource::get()->getSurface(file + ".gif"), Resource::get()->getAnimations(file + ".ani"))); sprites_.emplace_back(std::make_shared<SurfaceAnimatedSprite>(Resource::get()->getSurface(file + ".gif"), Resource::get()->getAnimations(file + ".ani")));
sprite_max_width_ = std::max(sprites_.back()->getWidth(), sprite_max_width_); sprite_max_width_ = std::max(sprites_.back()->getWidth(), sprite_max_width_);
sprite_max_height_ = std::max(sprites_.back()->getHeight(), sprite_max_height_); sprite_max_height_ = std::max(sprites_.back()->getHeight(), sprite_max_height_);
} }
@@ -395,7 +395,7 @@ void Ending2::createSpriteTexts() {
// Crea el sprite // Crea el sprite
SDL_FRect pos = {X, Y, W, H}; SDL_FRect pos = {X, Y, W, H};
sprite_texts_.emplace_back(std::make_shared<SMovingSprite>(surface, pos)); sprite_texts_.emplace_back(std::make_shared<SurfaceMovingSprite>(surface, pos));
sprite_texts_.back()->setVelY(SPRITE_DESP_SPEED_); sprite_texts_.back()->setVelY(SPRITE_DESP_SPEED_);
Screen::get()->setRendererSurface(previuos_renderer); Screen::get()->setRendererSurface(previuos_renderer);
} }
@@ -426,7 +426,7 @@ void Ending2::createTexts() {
// Crea el sprite // Crea el sprite
SDL_FRect pos = {X + DX, Y, W, H}; SDL_FRect pos = {X + DX, Y, W, H};
texts_.emplace_back(std::make_shared<SMovingSprite>(surface, pos)); texts_.emplace_back(std::make_shared<SurfaceMovingSprite>(surface, pos));
texts_.back()->setVelY(SPRITE_DESP_SPEED_); texts_.back()->setVelY(SPRITE_DESP_SPEED_);
Screen::get()->setRendererSurface(previuos_renderer); Screen::get()->setRendererSurface(previuos_renderer);
} }
@@ -455,7 +455,7 @@ void Ending2::createTexts() {
// Crea el sprite // Crea el sprite
SDL_FRect pos = {X + DX, Y, W, H}; SDL_FRect pos = {X + DX, Y, W, H};
texts_.emplace_back(std::make_shared<SMovingSprite>(surface, pos)); texts_.emplace_back(std::make_shared<SurfaceMovingSprite>(surface, pos));
texts_.back()->setVelY(SPRITE_DESP_SPEED_); texts_.back()->setVelY(SPRITE_DESP_SPEED_);
Screen::get()->setRendererSurface(previuos_renderer); Screen::get()->setRendererSurface(previuos_renderer);
} }

View File

@@ -7,8 +7,8 @@
#include <vector> // Para vector #include <vector> // Para vector
#include "utils/defines.hpp" // Para GAMECANVAS_WIDTH, GAMECANVAS_FIRST_QUAR... #include "utils/defines.hpp" // Para GAMECANVAS_WIDTH, GAMECANVAS_FIRST_QUAR...
class SAnimatedSprite; // lines 9-9 class SurfaceAnimatedSprite; // lines 9-9
class SMovingSprite; // lines 10-10 class SurfaceMovingSprite; // lines 10-10
class Ending2 { class Ending2 {
private: private:
@@ -62,9 +62,9 @@ class Ending2 {
static constexpr int STATE_FADE_DURATION_ = 5000; static constexpr int STATE_FADE_DURATION_ = 5000;
// Objetos y punteros // Objetos y punteros
std::vector<std::shared_ptr<SAnimatedSprite>> sprites_; // Vector con todos los sprites a dibujar std::vector<std::shared_ptr<SurfaceAnimatedSprite>> sprites_; // Vector con todos los sprites a dibujar
std::vector<std::shared_ptr<SMovingSprite>> sprite_texts_; // Vector con los sprites de texto de los sprites std::vector<std::shared_ptr<SurfaceMovingSprite>> sprite_texts_; // Vector con los sprites de texto de los sprites
std::vector<std::shared_ptr<SMovingSprite>> texts_; // Vector con los sprites de texto std::vector<std::shared_ptr<SurfaceMovingSprite>> texts_; // Vector con los sprites de texto
// Variables // Variables
Uint32 ticks_ = 0; // Contador de ticks para ajustar la velocidad del programa Uint32 ticks_ = 0; // Contador de ticks para ajustar la velocidad del programa

View File

@@ -1,5 +1,3 @@
#include "game/scene_manager.hpp" // Para SceneManager
#include "game/scenes/game_over.hpp" #include "game/scenes/game_over.hpp"
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
@@ -13,15 +11,16 @@
#include "core/rendering/text.hpp" // Para TEXT_CENTER, TEXT_COLOR, Text #include "core/rendering/text.hpp" // Para TEXT_CENTER, TEXT_COLOR, Text
#include "core/resources/resource.hpp" // Para Resource #include "core/resources/resource.hpp" // Para Resource
#include "external/jail_audio.h" // Para JA_PlayMusic #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/defines.hpp" // Para GAMECANVAS_CENTER_X, GAME_SPEED
#include "utils/global_events.hpp" // Para check #include "utils/global_events.hpp" // Para check
#include "utils/utils.hpp" // Para PaletteColor, stringToColor #include "utils/utils.hpp" // Para PaletteColor, stringToColor
// Constructor // Constructor
GameOver::GameOver() GameOver::GameOver()
: player_sprite_(std::make_shared<SAnimatedSprite>(Resource::get()->getSurface("player_game_over.gif"), Resource::get()->getAnimations("player_game_over.ani"))), : player_sprite_(std::make_shared<SurfaceAnimatedSprite>(Resource::get()->getSurface("player_game_over.gif"), Resource::get()->getAnimations("player_game_over.ani"))),
tv_sprite_(std::make_shared<SAnimatedSprite>(Resource::get()->getSurface("tv.gif"), Resource::get()->getAnimations("tv.ani"))), tv_sprite_(std::make_shared<SurfaceAnimatedSprite>(Resource::get()->getSurface("tv.gif"), Resource::get()->getAnimations("tv.ani"))),
pre_counter_(0), pre_counter_(0),
counter_(0), counter_(0),
ticks_(0) { ticks_(0) {

View File

@@ -2,9 +2,9 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <memory> // Para shared_ptr #include <memory> // Para shared_ptr
#include <vector> // Para vector #include <vector> // Para vector
class SAnimatedSprite; // lines 7-7 class SurfaceAnimatedSprite; // lines 7-7
class GameOver { class GameOver {
private: private:
@@ -14,8 +14,8 @@ class GameOver {
static constexpr int COUNTER_FADE_LENGHT_ = 20; // Contador: duración del fade static constexpr int COUNTER_FADE_LENGHT_ = 20; // Contador: duración del fade
// Objetos y punteros // Objetos y punteros
std::shared_ptr<SAnimatedSprite> player_sprite_; // Sprite con el jugador std::shared_ptr<SurfaceAnimatedSprite> player_sprite_; // Sprite con el jugador
std::shared_ptr<SAnimatedSprite> tv_sprite_; // Sprite con el televisor std::shared_ptr<SurfaceAnimatedSprite> tv_sprite_; // Sprite con el televisor
// Variables // Variables
int pre_counter_ = 0; // Contador previo int pre_counter_ = 0; // Contador previo

View File

@@ -1,5 +1,3 @@
#include "game/scene_manager.hpp" // Para SceneManager
#include "game/scenes/loading_screen.hpp" #include "game/scenes/loading_screen.hpp"
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
@@ -11,7 +9,8 @@
#include "core/rendering/surface_sprite.hpp" // Para SSprite #include "core/rendering/surface_sprite.hpp" // Para SSprite
#include "core/resources/resource.hpp" // Para Resource #include "core/resources/resource.hpp" // Para Resource
#include "external/jail_audio.h" // Para JA_PlayMusic, JA_SetVolume, JA_StopMusic #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/defines.hpp" // Para GAME_SPEED
#include "utils/global_events.hpp" // Para check #include "utils/global_events.hpp" // Para check
#include "utils/utils.hpp" // Para stringToColor, PaletteColor #include "utils/utils.hpp" // Para stringToColor, PaletteColor
@@ -20,8 +19,8 @@
LoadingScreen::LoadingScreen() LoadingScreen::LoadingScreen()
: mono_loading_screen_surface_(Resource::get()->getSurface("loading_screen_bn.gif")), : mono_loading_screen_surface_(Resource::get()->getSurface("loading_screen_bn.gif")),
color_loading_screen_surface_(Resource::get()->getSurface("loading_screen_color.gif")), color_loading_screen_surface_(Resource::get()->getSurface("loading_screen_color.gif")),
mono_loading_screen_sprite_(std::make_shared<SSprite>(mono_loading_screen_surface_, 0, 0, mono_loading_screen_surface_->getWidth(), mono_loading_screen_surface_->getHeight())), mono_loading_screen_sprite_(std::make_shared<SurfaceSprite>(mono_loading_screen_surface_, 0, 0, mono_loading_screen_surface_->getWidth(), mono_loading_screen_surface_->getHeight())),
color_loading_screen_sprite_(std::make_shared<SSprite>(color_loading_screen_surface_, 0, 0, color_loading_screen_surface_->getWidth(), color_loading_screen_surface_->getHeight())), color_loading_screen_sprite_(std::make_shared<SurfaceSprite>(color_loading_screen_surface_, 0, 0, color_loading_screen_surface_->getWidth(), color_loading_screen_surface_->getHeight())),
screen_surface_(std::make_shared<Surface>(Options::game.width, Options::game.height)) { screen_surface_(std::make_shared<Surface>(Options::game.width, Options::game.height)) {
// Configura la superficie donde se van a pintar los sprites // Configura la superficie donde se van a pintar los sprites
screen_surface_->clear(static_cast<Uint8>(PaletteColor::WHITE)); screen_surface_->clear(static_cast<Uint8>(PaletteColor::WHITE));

View File

@@ -2,18 +2,18 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <memory> // Para shared_ptr #include <memory> // Para shared_ptr
class SSprite; // lines 7-7 class SurfaceSprite; // lines 7-7
class Surface; // lines 8-8 class Surface; // lines 8-8
class LoadingScreen { class LoadingScreen {
private: private:
// Objetos y punteros // Objetos y punteros
std::shared_ptr<Surface> mono_loading_screen_surface_; // Surface con la pantalla de carga en blanco y negro std::shared_ptr<Surface> mono_loading_screen_surface_; // Surface con la pantalla de carga en blanco y negro
std::shared_ptr<Surface> color_loading_screen_surface_; // Surface con la pantalla de carga en color std::shared_ptr<Surface> color_loading_screen_surface_; // Surface con la pantalla de carga en color
std::shared_ptr<SSprite> mono_loading_screen_sprite_; // SSprite para manejar la textura loadingScreenTexture1 std::shared_ptr<SurfaceSprite> mono_loading_screen_sprite_; // SSprite para manejar la textura loadingScreenTexture1
std::shared_ptr<SSprite> color_loading_screen_sprite_; // SSprite para manejar la textura loadingScreenTexture2 std::shared_ptr<SurfaceSprite> color_loading_screen_sprite_; // SSprite para manejar la textura loadingScreenTexture2
std::shared_ptr<Surface> screen_surface_; // Surface para dibujar la pantalla de carga std::shared_ptr<Surface> screen_surface_; // Surface para dibujar la pantalla de carga
// Variables // Variables
int pre_counter_ = 0; // Contador previo para realizar una pausa inicial int pre_counter_ = 0; // Contador previo para realizar una pausa inicial

View File

@@ -7,7 +7,7 @@
#include "core/rendering/surface.hpp" // Para Surface #include "core/rendering/surface.hpp" // Para Surface
#include "core/rendering/surface_sprite.hpp" // Para SSprite #include "core/rendering/surface_sprite.hpp" // Para SSprite
#include "core/resources/resource.hpp" // Para Resource #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 "game/scene_manager.hpp" // Para SceneManager
#include "utils/defines.hpp" // Para GAME_SPEED #include "utils/defines.hpp" // Para GAME_SPEED
#include "utils/global_events.hpp" // Para check #include "utils/global_events.hpp" // Para check
@@ -17,35 +17,24 @@
Logo::Logo() Logo::Logo()
: jailgames_surface_(Resource::get()->getSurface("jailgames.gif")), : jailgames_surface_(Resource::get()->getSurface("jailgames.gif")),
since_1998_surface_(Resource::get()->getSurface("since_1998.gif")), since_1998_surface_(Resource::get()->getSurface("since_1998.gif")),
since_1998_sprite_(std::make_shared<SSprite>(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<SurfaceSprite>(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_sprite_->setClip(0, 0, since_1998_surface_->getWidth(), since_1998_surface_->getHeight());
since_1998_color_ = static_cast<Uint8>(PaletteColor::BLACK); since_1998_color_ = static_cast<Uint8>(PaletteColor::BLACK);
jailgames_color_ = static_cast<Uint8>(PaletteColor::BRIGHT_WHITE); jailgames_color_ = static_cast<Uint8>(PaletteColor::BRIGHT_WHITE);
// Inicializa variables
SceneManager::current = SceneManager::Scene::LOGO;
// Crea los sprites de cada linea // Crea los sprites de cada linea
for (int i = 0; i < jailgames_surface_->getHeight(); ++i) { for (int i = 0; i < jailgames_surface_->getHeight(); ++i) {
jailgames_sprite_.push_back(std::make_shared<SSprite>(jailgames_surface_, 0, i, jailgames_surface_->getWidth(), 1)); jailgames_sprite_.push_back(std::make_shared<SurfaceSprite>(jailgames_surface_, 0, i, jailgames_surface_->getWidth(), 1));
jailgames_sprite_.back()->setClip(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)->setX((i % 2 == 0) ? (256 + (i * 3)) : (-181 - (i * 3)));
jailgames_sprite_.at(i)->setY(83 + i); jailgames_sprite_.at(i)->setY(83 + i);
} }
// Inicializa variables initColors(); // Inicializa el vector de colores
SceneManager::current = SceneManager::Scene::LOGO;
// Inicializa el vector de colores
const std::vector<Uint8> COLORS = {
static_cast<Uint8>(PaletteColor::BLACK),
static_cast<Uint8>(PaletteColor::BLUE),
static_cast<Uint8>(PaletteColor::RED),
static_cast<Uint8>(PaletteColor::MAGENTA),
static_cast<Uint8>(PaletteColor::GREEN),
static_cast<Uint8>(PaletteColor::CYAN),
static_cast<Uint8>(PaletteColor::YELLOW),
static_cast<Uint8>(PaletteColor::BRIGHT_WHITE)};
for (const auto& color : COLORS) {
color_.push_back(color);
}
// Cambia el color del borde // Cambia el color del borde
Screen::get()->setBorderColor(static_cast<Uint8>(PaletteColor::BLACK)); Screen::get()->setBorderColor(static_cast<Uint8>(PaletteColor::BLACK));
@@ -220,3 +209,20 @@ void Logo::endSection() {
break; break;
} }
} }
// Inicializa el vector de colores
void Logo::initColors() {
// Inicializa el vector de colores
const std::vector<Uint8> COLORS = {
static_cast<Uint8>(PaletteColor::BLACK),
static_cast<Uint8>(PaletteColor::BLUE),
static_cast<Uint8>(PaletteColor::RED),
static_cast<Uint8>(PaletteColor::MAGENTA),
static_cast<Uint8>(PaletteColor::GREEN),
static_cast<Uint8>(PaletteColor::CYAN),
static_cast<Uint8>(PaletteColor::YELLOW),
static_cast<Uint8>(PaletteColor::BRIGHT_WHITE)};
for (const auto& color : COLORS) {
color_.push_back(color);
}
}

View File

@@ -2,10 +2,10 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <memory> // Para shared_ptr #include <memory> // Para shared_ptr
#include <vector> // Para vector #include <vector> // Para vector
class SSprite; // lines 7-7 class SurfaceSprite; // lines 7-7
class Surface; // lines 8-8 class Surface; // lines 8-8
class Logo { class Logo {
private: private:
@@ -15,12 +15,12 @@ class Logo {
static constexpr int POST_LOGO_ = 20; // Tiempo que dura el logo con el fade al maximo static constexpr int POST_LOGO_ = 20; // Tiempo que dura el logo con el fade al maximo
// Objetos y punteros // Objetos y punteros
std::shared_ptr<Surface> jailgames_surface_; // Textura con los graficos "JAILGAMES" std::shared_ptr<Surface> jailgames_surface_; // Textura con los graficos "JAILGAMES"
std::shared_ptr<Surface> since_1998_surface_; // Textura con los graficos "Since 1998" std::shared_ptr<Surface> since_1998_surface_; // Textura con los graficos "Since 1998"
std::vector<std::shared_ptr<SSprite>> jailgames_sprite_; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES std::vector<std::shared_ptr<SurfaceSprite>> jailgames_sprite_; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES
std::shared_ptr<SSprite> since_1998_sprite_; // SSprite para manejar la textura2 std::shared_ptr<SurfaceSprite> since_1998_sprite_; // SSprite para manejar la textura2
Uint8 jailgames_color_ = 0; // Color para el sprite de "JAILGAMES" Uint8 jailgames_color_ = 0; // Color para el sprite de "JAILGAMES"
Uint8 since_1998_color_ = 0; // Color para el sprite de "Since 1998" Uint8 since_1998_color_ = 0; // Color para el sprite de "Since 1998"
// Variables // Variables
std::vector<Uint8> color_; // Vector con los colores para el fade std::vector<Uint8> color_; // Vector con los colores para el fade
@@ -48,6 +48,9 @@ class Logo {
// Termina la sección // Termina la sección
void endSection(); void endSection();
// Inicializa el vector de colores
void initColors();
public: public:
// Constructor // Constructor
Logo(); Logo();

View File

@@ -1,5 +1,3 @@
#include "game/scene_manager.hpp" // Para SceneManager
#include "game/scenes/title.hpp" #include "game/scenes/title.hpp"
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
@@ -14,7 +12,8 @@
#include "core/rendering/text.hpp" // Para Text, TEXT_CENTER, TEXT_COLOR #include "core/rendering/text.hpp" // Para Text, TEXT_CENTER, TEXT_COLOR
#include "core/resources/resource.hpp" // Para Resource #include "core/resources/resource.hpp" // Para Resource
#include "game/gameplay/cheevos.hpp" // Para Cheevos, Achievement #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/defines.hpp" // Para PLAY_AREA_CENTER_X, GAMECANVAS_WIDTH
#include "utils/global_events.hpp" // Para check #include "utils/global_events.hpp" // Para check
#include "utils/utils.hpp" // Para stringToColor, PaletteColor, playMusic #include "utils/utils.hpp" // Para stringToColor, PaletteColor, playMusic
@@ -22,9 +21,9 @@
// Constructor // Constructor
Title::Title() Title::Title()
: title_logo_surface_(Resource::get()->getSurface("title_logo.gif")), : title_logo_surface_(Resource::get()->getSurface("title_logo.gif")),
title_logo_sprite_(std::make_shared<SSprite>(title_logo_surface_, 29, 9, title_logo_surface_->getWidth(), title_logo_surface_->getHeight())), title_logo_sprite_(std::make_shared<SurfaceSprite>(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_surface_(Resource::get()->getSurface("loading_screen_color.gif")),
loading_screen_sprite_(std::make_shared<SSprite>(loading_screen_surface_, 0, 0, loading_screen_surface_->getWidth(), loading_screen_surface_->getHeight())), loading_screen_sprite_(std::make_shared<SurfaceSprite>(loading_screen_surface_, 0, 0, loading_screen_surface_->getWidth(), loading_screen_surface_->getHeight())),
bg_surface_(std::make_shared<Surface>(Options::game.width, Options::game.height)) { bg_surface_(std::make_shared<Surface>(Options::game.width, Options::game.height)) {
// Inicializa variables // Inicializa variables
state_ = SceneManager::options == SceneManager::Options::TITLE_WITH_LOADING_SCREEN ? TitleState::SHOW_LOADING_SCREEN : TitleState::SHOW_MENU; 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); Screen::get()->setRendererSurface(previuos_renderer);
// Crea el sprite para el listado de logros // Crea el sprite para el listado de logros
cheevos_sprite_ = std::make_shared<SSprite>(cheevos_surface_, (GAMECANVAS_WIDTH - cheevos_surface_->getWidth()) / 2, CHEEVOS_TEXTURE_POS_Y, cheevos_surface_->getWidth(), cheevos_surface_->getHeight()); cheevos_sprite_ = std::make_shared<SurfaceSprite>(cheevos_surface_, (GAMECANVAS_WIDTH - cheevos_surface_->getWidth()) / 2, CHEEVOS_TEXTURE_POS_Y, cheevos_surface_->getWidth(), cheevos_surface_->getHeight());
cheevos_surface_view_ = {0, 0, cheevos_surface_->getWidth(), CHEEVOS_TEXTURE_VIEW_HEIGHT}; cheevos_surface_view_ = {0, 0, cheevos_surface_->getWidth(), CHEEVOS_TEXTURE_VIEW_HEIGHT};
cheevos_sprite_->setClip(cheevos_surface_view_); cheevos_sprite_->setClip(cheevos_surface_view_);
} }

View File

@@ -2,11 +2,11 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <memory> // Para shared_ptr #include <memory> // Para shared_ptr
#include <string> // Para string #include <string> // Para string
#include <vector> // Para vector #include <vector> // Para vector
class SSprite; // lines 9-9 class SurfaceSprite; // lines 9-9
class Surface; // lines 10-10 class Surface; // lines 10-10
class Title { class Title {
private: private:
@@ -23,13 +23,13 @@ class Title {
}; };
// Objetos y punteros // Objetos y punteros
std::shared_ptr<Surface> title_logo_surface_; // Textura con los graficos std::shared_ptr<Surface> title_logo_surface_; // Textura con los graficos
std::shared_ptr<SSprite> title_logo_sprite_; // SSprite para manejar la surface std::shared_ptr<SurfaceSprite> title_logo_sprite_; // SSprite para manejar la surface
std::shared_ptr<Surface> loading_screen_surface_; // Surface con los gráficos de la pantalla de carga std::shared_ptr<Surface> loading_screen_surface_; // Surface con los gráficos de la pantalla de carga
std::shared_ptr<SSprite> loading_screen_sprite_; // SSprite con los gráficos de la pantalla de carga std::shared_ptr<SurfaceSprite> loading_screen_sprite_; // SSprite con los gráficos de la pantalla de carga
std::shared_ptr<Surface> bg_surface_; // Textura para dibujar el fondo de la pantalla std::shared_ptr<Surface> bg_surface_; // Textura para dibujar el fondo de la pantalla
std::shared_ptr<Surface> cheevos_surface_; // Textura con la lista de logros std::shared_ptr<Surface> cheevos_surface_; // Textura con la lista de logros
std::shared_ptr<SSprite> cheevos_sprite_; // SSprite para manejar la surface con la lista de logros std::shared_ptr<SurfaceSprite> cheevos_sprite_; // SSprite para manejar la surface con la lista de logros
// Variables // Variables
int counter_ = 0; // Contador int counter_ = 0; // Contador

View File

@@ -13,7 +13,7 @@
#include "core/rendering/text.hpp" // Para Text, TEXT_CENTER, TEXT_COLOR #include "core/rendering/text.hpp" // Para Text, TEXT_CENTER, TEXT_COLOR
#include "core/resources/resource.hpp" // Para Resource #include "core/resources/resource.hpp" // Para Resource
#include "external/jail_audio.h" // Para JA_PlaySound #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 #include "utils/utils.hpp" // Para PaletteColor
// [SINGLETON] // [SINGLETON]
@@ -217,7 +217,7 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, Ui
// Dibuja el icono de la notificación // Dibuja el icono de la notificación
if (has_icons_ && icon >= 0 && texts.size() >= 2) { if (has_icons_ && icon >= 0 && texts.size() >= 2) {
auto sp = std::make_unique<SSprite>(icon_surface_, (SDL_FRect){0, 0, ICON_SIZE_, ICON_SIZE_}); auto sp = std::make_unique<SurfaceSprite>(icon_surface_, (SDL_FRect){0, 0, ICON_SIZE_, ICON_SIZE_});
sp->setPosition({PADDING_IN_H, PADDING_IN_V, 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->setClip((SDL_FRect){ICON_SIZE_ * (icon % 10), ICON_SIZE_ * (icon / 10), ICON_SIZE_, ICON_SIZE_});
sp->render(); sp->render();
@@ -245,7 +245,7 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, Ui
Screen::get()->setRendererSurface(previuos_renderer); Screen::get()->setRendererSurface(previuos_renderer);
// Crea el sprite de la notificación // Crea el sprite de la notificación
n.sprite = std::make_shared<SSprite>(n.surface, n.rect); n.sprite = std::make_shared<SurfaceSprite>(n.surface, n.rect);
// Añade la notificación a la lista // Añade la notificación a la lista
notifications_.emplace_back(n); notifications_.emplace_back(n);

View File

@@ -2,12 +2,12 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <memory> // Para shared_ptr #include <memory> // Para shared_ptr
#include <string> // Para string, basic_string #include <string> // Para string, basic_string
#include <vector> // Para vector #include <vector> // Para vector
class SSprite; // lines 8-8 class SurfaceSprite; // lines 8-8
class Surface; // lines 10-10 class Surface; // lines 10-10
class Text; // lines 9-9 class Text; // lines 9-9
// Constantes // Constantes
constexpr Uint32 DEFAULT_NOTIFICATION_DURATION = 2000; constexpr Uint32 DEFAULT_NOTIFICATION_DURATION = 2000;
@@ -41,20 +41,20 @@ class Notifier {
}; };
struct Notification { struct Notification {
std::shared_ptr<Surface> surface; // Superficie asociada a la notificación std::shared_ptr<Surface> surface; // Superficie asociada a la notificación
std::shared_ptr<SSprite> sprite; // Sprite asociado para gráficos o animaciones std::shared_ptr<SurfaceSprite> sprite; // Sprite asociado para gráficos o animaciones
std::vector<std::string> texts; // Lista de textos incluidos en la notificación std::vector<std::string> texts; // Lista de textos incluidos en la notificación
NotificationStatus state; // Estado actual de la notificación (RISING, SHOWING, etc.) NotificationStatus state; // Estado actual de la notificación (RISING, SHOWING, etc.)
NotificationShape shape; // Forma de la notificación (ej. SQUARED o ROUNDED) NotificationShape shape; // Forma de la notificación (ej. SQUARED o ROUNDED)
SDL_FRect rect; // Dimensiones y posición de la notificación en pantalla SDL_FRect rect; // Dimensiones y posición de la notificación en pantalla
int y; // Posición actual en el eje Y int y; // Posición actual en el eje Y
int travel_dist; // Distancia a recorrer (por ejemplo, en animaciones) int travel_dist; // Distancia a recorrer (por ejemplo, en animaciones)
std::string code; // Código identificador único para esta notificación std::string code; // Código identificador único para esta notificación
bool can_be_removed; // Indica si la notificación puede ser eliminada bool can_be_removed; // Indica si la notificación puede ser eliminada
int height; // Altura de la notificación int height; // Altura de la notificación
Uint32 start_time; // Momento en que se creó la notificación Uint32 start_time; // Momento en que se creó la notificación
Uint32 elapsed_time; // Tiempo transcurrido desde la creación Uint32 elapsed_time; // Tiempo transcurrido desde la creación
Uint32 display_duration; // Duración total para mostrar la notificación Uint32 display_duration; // Duración total para mostrar la notificación
// Constructor // Constructor
explicit Notification() explicit Notification()