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

@@ -9,7 +9,7 @@
// Constructor
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),
x1_(enemy.x1),
x2_(enemy.x2),

View File

@@ -2,9 +2,9 @@
#include <SDL3/SDL.h>
#include <memory> // Para shared_ptr
#include <string> // Para string
class SAnimatedSprite; // lines 7-7
#include <memory> // Para shared_ptr
#include <string> // 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<SAnimatedSprite> sprite_; // Sprite del enemigo
std::shared_ptr<SurfaceAnimatedSprite> sprite_; // Sprite del enemigo
// Variables
Uint8 color_; // Color del enemigo

View File

@@ -5,7 +5,7 @@
// Constructor
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) {
// Inicia variables
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 <string> // Para string
#include <vector> // 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<SSprite> sprite_; // SSprite del objeto
std::shared_ptr<SurfaceSprite> sprite_; // SSprite del objeto
// Variables
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/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<SAnimatedSprite>(surface, animations);
sprite_ = std::make_shared<SurfaceAnimatedSprite>(surface, animations);
sprite_->setWidth(WIDTH_);
sprite_->setHeight(HEIGHT_);
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
// Objetos y punteros
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<Room> room_; // Objeto encargado de gestionar cada habitación del juego
std::shared_ptr<SurfaceAnimatedSprite> sprite_; // Sprite del jugador
// Variables
float x_; // Posición del jugador en el eje X

View File

@@ -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<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.x_orig = xc;
animated_tiles_.push_back(at);

View File

@@ -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<SSprite> 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<SurfaceSprite> 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 {

View File

@@ -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<ScoreboardData> 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<SAnimatedSprite>(player_texture, player_animations);
player_sprite_ = std::make_shared<SurfaceAnimatedSprite>(player_texture, player_animations);
player_sprite_->setCurrentAnimation("walk_menu");
surface_ = std::make_shared<Surface>(SURFACE_WIDTH_, SURFACE_HEIGHT_);

View File

@@ -2,11 +2,11 @@
#include <SDL3/SDL.h>
#include <memory> // Para shared_ptr
#include <string> // Para string, basic_string
#include <vector> // Para vector
class SAnimatedSprite; // lines 10-10
class Surface; // lines 11-11
#include <memory> // Para shared_ptr
#include <string> // Para string, basic_string
#include <vector> // 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<SAnimatedSprite> 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<ScoreboardData> data_; // Contiene las variables a mostrar en el marcador
std::shared_ptr<Surface> surface_; // Surface donde dibujar 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<ScoreboardData> data_; // Contiene las variables a mostrar en el marcador
std::shared_ptr<Surface> surface_; // Surface donde dibujar el marcador;
// Variables
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 <SDL3/SDL.h>
@@ -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<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
SceneManager::current = SceneManager::Scene::CREDITS;
SceneManager::options = SceneManager::Options::NONE;

View File

@@ -2,10 +2,10 @@
#include <SDL3/SDL.h>
#include <memory> // Para shared_ptr
#include <string> // Para string
#include <vector> // Para vector
class SAnimatedSprite; // lines 11-11
#include <memory> // Para shared_ptr
#include <string> // Para string
#include <vector> // Para vector
class SurfaceAnimatedSprite; // lines 11-11
class Surface;
class Credits {
@@ -16,9 +16,9 @@ class Credits {
};
// Objetos y punteros
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<SAnimatedSprite> shining_sprite_; // Sprite para el brillo del corazón
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<SurfaceAnimatedSprite> shining_sprite_; // Sprite para el brillo del corazón
// Variables
int counter_ = 0; // Contador

View File

@@ -1,5 +1,3 @@
#include "game/scene_manager.hpp" // Para SceneManager
#include "game/scenes/ending.hpp"
#include <SDL3/SDL.h>
@@ -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<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);
// Crea la cover_surface
@@ -196,7 +195,7 @@ void Ending::iniTexts() {
surface->fillRect(&rect, color);
// 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->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<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);
// Crea la cover_surface
@@ -262,7 +261,7 @@ void Ending::iniPics() {
surface->fillRect(&rect, color);
// 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->setClip(0, 8, sp.cover_surface->getWidth(), sp.cover_surface->getHeight());

View File

@@ -2,23 +2,23 @@
#include <SDL3/SDL.h>
#include <memory> // Para shared_ptr
#include <string> // Para string
#include <vector> // Para vector
class SSprite; // lines 8-8
class Surface; // lines 9-9
#include <memory> // Para shared_ptr
#include <string> // Para string
#include <vector> // 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<Surface> image_surface; // Surface a mostrar
std::shared_ptr<SSprite> image_sprite; // SSprite para mostrar la 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
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<Surface> image_surface; // Surface a mostrar
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<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_height; // Altura del spriteClip de la textura de cobertura
};
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/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<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_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<SMovingSprite>(surface, pos));
sprite_texts_.emplace_back(std::make_shared<SurfaceMovingSprite>(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<SMovingSprite>(surface, pos));
texts_.emplace_back(std::make_shared<SurfaceMovingSprite>(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<SMovingSprite>(surface, pos));
texts_.emplace_back(std::make_shared<SurfaceMovingSprite>(surface, pos));
texts_.back()->setVelY(SPRITE_DESP_SPEED_);
Screen::get()->setRendererSurface(previuos_renderer);
}

View File

@@ -7,8 +7,8 @@
#include <vector> // 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<std::shared_ptr<SAnimatedSprite>> 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<SMovingSprite>> texts_; // Vector con los sprites de texto
std::vector<std::shared_ptr<SurfaceAnimatedSprite>> sprites_; // Vector con todos los sprites a dibujar
std::vector<std::shared_ptr<SurfaceMovingSprite>> sprite_texts_; // Vector con los sprites de texto de los sprites
std::vector<std::shared_ptr<SurfaceMovingSprite>> texts_; // Vector con los sprites de texto
// Variables
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 <SDL3/SDL.h>
@@ -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<SAnimatedSprite>(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"))),
: 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<SurfaceAnimatedSprite>(Resource::get()->getSurface("tv.gif"), Resource::get()->getAnimations("tv.ani"))),
pre_counter_(0),
counter_(0),
ticks_(0) {

View File

@@ -2,9 +2,9 @@
#include <SDL3/SDL.h>
#include <memory> // Para shared_ptr
#include <vector> // Para vector
class SAnimatedSprite; // lines 7-7
#include <memory> // Para shared_ptr
#include <vector> // 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<SAnimatedSprite> player_sprite_; // Sprite con el jugador
std::shared_ptr<SAnimatedSprite> tv_sprite_; // Sprite con el televisor
std::shared_ptr<SurfaceAnimatedSprite> player_sprite_; // Sprite con el jugador
std::shared_ptr<SurfaceAnimatedSprite> tv_sprite_; // Sprite con el televisor
// Variables
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 <SDL3/SDL.h>
@@ -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<SSprite>(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())),
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<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)) {
// Configura la superficie donde se van a pintar los sprites
screen_surface_->clear(static_cast<Uint8>(PaletteColor::WHITE));

View File

@@ -2,18 +2,18 @@
#include <SDL3/SDL.h>
#include <memory> // Para shared_ptr
class SSprite; // lines 7-7
class Surface; // lines 8-8
#include <memory> // Para shared_ptr
class SurfaceSprite; // lines 7-7
class Surface; // lines 8-8
class LoadingScreen {
private:
// 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> 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<SSprite> 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> 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<SurfaceSprite> mono_loading_screen_sprite_; // SSprite para manejar la textura loadingScreenTexture1
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
// Variables
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_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<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_color_ = static_cast<Uint8>(PaletteColor::BLACK);
jailgames_color_ = static_cast<Uint8>(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<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_.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<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);
}
initColors(); // Inicializa el vector de colores
// Cambia el color del borde
Screen::get()->setBorderColor(static_cast<Uint8>(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<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 <memory> // Para shared_ptr
#include <vector> // Para vector
class SSprite; // lines 7-7
class Surface; // lines 8-8
#include <memory> // Para shared_ptr
#include <vector> // 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<Surface> jailgames_surface_; // Textura con los graficos "JAILGAMES"
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::shared_ptr<SSprite> 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<Surface> jailgames_surface_; // Textura con los graficos "JAILGAMES"
std::shared_ptr<Surface> since_1998_surface_; // Textura con los graficos "Since 1998"
std::vector<std::shared_ptr<SurfaceSprite>> jailgames_sprite_; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES
std::shared_ptr<SurfaceSprite> 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<Uint8> 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();

View File

@@ -1,5 +1,3 @@
#include "game/scene_manager.hpp" // Para SceneManager
#include "game/scenes/title.hpp"
#include <SDL3/SDL.h>
@@ -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<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_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)) {
// 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<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_sprite_->setClip(cheevos_surface_view_);
}

View File

@@ -2,11 +2,11 @@
#include <SDL3/SDL.h>
#include <memory> // Para shared_ptr
#include <string> // Para string
#include <vector> // Para vector
class SSprite; // lines 9-9
class Surface; // lines 10-10
#include <memory> // Para shared_ptr
#include <string> // Para string
#include <vector> // 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<Surface> title_logo_surface_; // Textura con los graficos
std::shared_ptr<SSprite> 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<SSprite> 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> 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<Surface> title_logo_surface_; // Textura con los graficos
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<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> cheevos_surface_; // Textura con la lista de logros
std::shared_ptr<SurfaceSprite> cheevos_sprite_; // SSprite para manejar la surface con la lista de logros
// Variables
int counter_ = 0; // Contador

View File

@@ -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<std::string> 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<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->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<std::string> texts, NotificationText text_is, Ui
Screen::get()->setRendererSurface(previuos_renderer);
// 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
notifications_.emplace_back(n);

View File

@@ -2,12 +2,12 @@
#include <SDL3/SDL.h>
#include <memory> // Para shared_ptr
#include <string> // Para string, basic_string
#include <vector> // Para vector
class SSprite; // lines 8-8
class Surface; // lines 10-10
class Text; // lines 9-9
#include <memory> // Para shared_ptr
#include <string> // Para string, basic_string
#include <vector> // 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> surface; // Superficie asociada a la notificación
std::shared_ptr<SSprite> sprite; // Sprite asociado para gráficos o animaciones
std::vector<std::string> 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> surface; // Superficie asociada a la notificación
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
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()