Compare commits

3 Commits

Author SHA1 Message Date
9825c7fb9b Pasaeta de include-what-you-use 2024-10-13 21:58:36 +02:00
d0a6e4c572 Afegits destructors virtuals en les classes Sprite 2024-10-13 21:23:15 +02:00
7c876e1d4d Acabat amb cppcheck
Arreglades les herencies de les classes Sprite
2024-10-13 21:00:33 +02:00
51 changed files with 458 additions and 468 deletions

View File

@@ -1,6 +1,8 @@
#include "animated_sprite.h" #include "animated_sprite.h"
#include <algorithm> // for copy
#include <fstream> // for basic_ostream, operator<<, basic_istream, basic... #include <fstream> // for basic_ostream, operator<<, basic_istream, basic...
#include <iostream> // for cout #include <iostream> // for cout
#include <iterator> // for back_insert_iterator, back_inserter
#include <sstream> // for basic_stringstream #include <sstream> // for basic_stringstream
#include "texture.h" // for Texture #include "texture.h" // for Texture

View File

@@ -2,11 +2,11 @@
#include <SDL2/SDL_rect.h> // for SDL_Rect #include <SDL2/SDL_rect.h> // for SDL_Rect
#include <SDL2/SDL_stdinc.h> // for Uint8 #include <SDL2/SDL_stdinc.h> // for Uint8
#include <string> // for string, basic_string #include <memory> // for shared_ptr
#include <string> // for string
#include <vector> // for vector #include <vector> // for vector
#include "moving_sprite.h" // for MovingSprite #include "moving_sprite.h" // for MovingSprite
#include "texture.h" class Texture;
#include <memory>
struct Animation struct Animation
{ {
@@ -37,11 +37,11 @@ protected:
public: public:
// Constructor // Constructor
explicit AnimatedSprite(std::shared_ptr<Texture> texture = nullptr, const std::string &file = std::string(), std::vector<std::string>* buffer = nullptr); explicit AnimatedSprite(std::shared_ptr<Texture> texture = nullptr, const std::string &file = std::string(), std::vector<std::string> *buffer = nullptr);
explicit AnimatedSprite(const AnimatedFile *animation); explicit AnimatedSprite(const AnimatedFile *animation);
// Destructor // Destructor
~AnimatedSprite(); virtual ~AnimatedSprite();
// Calcula el frame correspondiente a la animación actual // Calcula el frame correspondiente a la animación actual
void animate(); void animate();

View File

@@ -1,10 +1,12 @@
#include "background.h" #include "background.h"
#include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888
#include <algorithm> // for max, min #include <algorithm> // for clamp, max
#include <string> // for basic_string
#include "asset.h" // for Asset #include "asset.h" // for Asset
#include "moving_sprite.h" // for MovingSprite
#include "param.h" // for param #include "param.h" // for param
#include "sprite.h" // for Sprite
#include "texture.h" // for Texture
// Constructor // Constructor
Background::Background(SDL_Renderer *renderer) Background::Background(SDL_Renderer *renderer)

View File

@@ -2,11 +2,11 @@
#include <SDL2/SDL_rect.h> // for SDL_Rect #include <SDL2/SDL_rect.h> // for SDL_Rect
#include <SDL2/SDL_render.h> // for SDL_Renderer, SDL_Texture #include <SDL2/SDL_render.h> // for SDL_Renderer, SDL_Texture
#include <memory> // for unique_ptr, shared_ptr
#include "utils.h" // for Color #include "utils.h" // for Color
#include "moving_sprite.h" class MovingSprite;
#include "sprite.h" class Sprite;
#include "texture.h" class Texture;
#include <memory>
/* /*
Esta clase es la encargada de dibujar el fondo que aparece durante la sección Esta clase es la encargada de dibujar el fondo que aparece durante la sección

View File

@@ -1,5 +1,5 @@
#include "balloon.h" #include "balloon.h"
#include <math.h> // for abs #include <cmath> // for abs
#include "animated_sprite.h" // for AnimatedSprite #include "animated_sprite.h" // for AnimatedSprite
#include "moving_sprite.h" // for MovingSprite #include "moving_sprite.h" // for MovingSprite
#include "param.h" // for param #include "param.h" // for param

View File

@@ -1,12 +1,12 @@
#pragma once #pragma once
#include <SDL2/SDL_stdinc.h> // for Uint8, Uint16, Uint32 #include <SDL2/SDL_stdinc.h> // for Uint8, Uint16, Uint32
#include <memory> // for shared_ptr, unique_ptr
#include <string> // for string #include <string> // for string
#include <vector> // for vector #include <vector> // for vector
#include <memory> #include "animated_sprite.h" // for AnimatedSprite
#include "utils.h" // for Circle #include "utils.h" // for Circle
#include "animated_sprite.h" class Texture;
#include "texture.h"
// Cantidad de elementos del vector con los valores de la deformación del globo al rebotar // Cantidad de elementos del vector con los valores de la deformación del globo al rebotar
constexpr int MAX_BOUNCE = 10; constexpr int MAX_BOUNCE = 10;

View File

@@ -428,7 +428,6 @@ void BalloonFormations::initBalloonFormations()
// #24 - Treinta enemigos BALLOON1. Del centro hacia los extremos. Juntos. Simetricos // #24 - Treinta enemigos BALLOON1. Del centro hacia los extremos. Juntos. Simetricos
j = 24; j = 24;
balloon_formation_[j].number_of_balloons = 30; balloon_formation_[j].number_of_balloons = 30;
inc_x = 0;
inc_time = 5; inc_time = 5;
for (int i = 0; i < balloon_formation_[j].number_of_balloons; i++) for (int i = 0; i < balloon_formation_[j].number_of_balloons; i++)
{ {

View File

@@ -1,9 +1,9 @@
#include "bullet.h" #include "bullet.h"
#include <memory> // for unique_ptr, make_unique, shared_ptr
#include "param.h" // for param #include "param.h" // for param
#include "sprite.h" // for Sprite #include "sprite.h" // for Sprite
#include <memory> // for std::unique_ptr class Texture;
// Constantes evaluables en tiempo de compilación
constexpr int BULLET_WIDTH = 12; constexpr int BULLET_WIDTH = 12;
constexpr int BULLET_HEIGHT = 12; constexpr int BULLET_HEIGHT = 12;
constexpr int BULLET_VELY = -3; constexpr int BULLET_VELY = -3;
@@ -23,8 +23,7 @@ Bullet::Bullet(int x, int y, BulletType kind, bool powered_up, int owner, SDL_Re
owner_(owner), owner_(owner),
play_area_(play_area) play_area_(play_area)
{ {
vel_x_ = (kind_ == BulletType::LEFT) ? BULLET_VELX_LEFT vel_x_ = (kind_ == BulletType::LEFT) ? BULLET_VELX_LEFT : (kind_ == BulletType::RIGHT) ? BULLET_VELX_RIGHT
: (kind_ == BulletType::RIGHT) ? BULLET_VELX_RIGHT
: 0; : 0;
auto sprite_offset = powered_up ? 3 : 0; auto sprite_offset = powered_up ? 3 : 0;
@@ -67,12 +66,12 @@ BulletMoveStatus Bullet::move()
bool Bullet::isEnabled() const bool Bullet::isEnabled() const
{ {
return kind_ != BulletType::NULL_TYPE; return kind_ != BulletType::NONE;
} }
void Bullet::disable() void Bullet::disable()
{ {
kind_ = BulletType::NULL_TYPE; kind_ = BulletType::NONE;
} }
int Bullet::getPosX() const int Bullet::getPosX() const

View File

@@ -2,10 +2,10 @@
#include <SDL2/SDL_rect.h> // for SDL_Rect #include <SDL2/SDL_rect.h> // for SDL_Rect
#include <SDL2/SDL_stdinc.h> // for Uint8 #include <SDL2/SDL_stdinc.h> // for Uint8
#include <memory> // for unique_ptr #include <memory> // for shared_ptr, unique_ptr
#include "sprite.h" // for Sprite #include "sprite.h" // for Sprite
#include "utils.h" // for Circle #include "utils.h" // for Circle
#include "texture.h" // lines 9-9 class Texture;
// Enumeración para los diferentes tipos de balas // Enumeración para los diferentes tipos de balas
enum class BulletType enum class BulletType
@@ -13,7 +13,7 @@ enum class BulletType
UP, UP,
LEFT, LEFT,
RIGHT, RIGHT,
NULL_TYPE NONE
}; };
// Enumeración para los resultados del movimiento de la bala // Enumeración para los resultados del movimiento de la bala

View File

@@ -1,8 +1,10 @@
#include "define_buttons.h" #include "define_buttons.h"
#include <utility> // for move
#include "input.h" // for Input, InputType
#include "lang.h" // for getText #include "lang.h" // for getText
#include "options.h" // for options #include "options.h" // for options
#include "param.h" // for param #include "param.h" // for param
#include "section.h" // for name, SectionName, options, SectionOptions #include "section.h" // for Name, Options, name, options
#include "text.h" // for Text #include "text.h" // for Text
#include "utils.h" // for OptionsController, Options, Param, ParamGame #include "utils.h" // for OptionsController, Options, Param, ParamGame

View File

@@ -2,11 +2,12 @@
#include <SDL2/SDL_events.h> // for SDL_ControllerButtonEvent #include <SDL2/SDL_events.h> // for SDL_ControllerButtonEvent
#include <SDL2/SDL_gamecontroller.h> // for SDL_GameControllerButton #include <SDL2/SDL_gamecontroller.h> // for SDL_GameControllerButton
#include <string> // for string, basic_string #include <memory> // for shared_ptr, unique_ptr
#include <string> // for string
#include <vector> // for vector #include <vector> // for vector
#include "input.h" // for inputs_e class Input;
#include "text.h" class Text;
#include <memory> enum class InputType : int;
struct DefineButtonsButton struct DefineButtonsButton
{ {

View File

@@ -5,43 +5,44 @@
#include <SDL2/SDL_error.h> // for SDL_GetError #include <SDL2/SDL_error.h> // for SDL_GetError
#include <SDL2/SDL_gamecontroller.h> // for SDL_CONTROLLER_BUTTON_B, SDL_CO... #include <SDL2/SDL_gamecontroller.h> // for SDL_CONTROLLER_BUTTON_B, SDL_CO...
#include <SDL2/SDL_hints.h> // for SDL_SetHint, SDL_HINT_RENDER_DR... #include <SDL2/SDL_hints.h> // for SDL_SetHint, SDL_HINT_RENDER_DR...
#include <SDL2/SDL_scancode.h> // for SDL_SCANCODE_DOWN, SDL_SCANCODE_E #include <SDL2/SDL_scancode.h> // for SDL_SCANCODE_0, SDL_SCANCODE_DOWN
#include <SDL2/SDL_stdinc.h> // for Uint32 #include <SDL2/SDL_stdinc.h> // for SDL_bool, Uint32
#include <SDL2/SDL_timer.h> // for SDL_GetTicks #include <SDL2/SDL_timer.h> // for SDL_GetTicks
#include <errno.h> // for errno, EACCES, EEXIST, ENAMETOO... #include <errno.h> // for errno, EEXIST, EACCES, ENAMETOO...
#include <stdio.h> // for printf, perror, size_t #include <stdio.h> // for printf, perror
#include <string.h> // for strcmp #include <string.h> // for strcmp
#include <sys/stat.h> // for stat, mkdir, S_IRWXU #include <sys/stat.h> // for mkdir, stat, S_IRWXU
#include <unistd.h> // for getuid #include <unistd.h> // for getuid
#include <cstdlib> // for exit, EXIT_FAILURE, rand, srand #include <cstdlib> // for exit, EXIT_FAILURE, rand, srand
#include <iostream> // for basic_ostream, operator<<, cout #include <iostream> // for basic_ostream, operator<<, cout
#include <string> // for basic_string, operator+, allocator #include <memory> // for make_unique, unique_ptr
#include "asset.h" // for Asset, assetType #include <string> // for operator+, allocator, char_traits
#include "asset.h" // for Asset, AssetType
#include "dbgtxt.h" // for dbg_init #include "dbgtxt.h" // for dbg_init
#include "game.h" // for Game, GAME_MODE_DEMO_OFF, GAME_... #include "game.h" // for Game, GAME_MODE_DEMO_OFF, GAME_...
#include "global_inputs.h" #include "global_inputs.h" // for init
#include "hiscore_table.h" // for HiScoreTable #include "hiscore_table.h" // for HiScoreTable
#include "input.h" // for inputs_e, Input #include "input.h" // for Input, InputType
#include "instructions.h" // for Instructions #include "instructions.h" // for Instructions
#include "intro.h" // for Intro #include "intro.h" // for Intro
#include "jail_audio.h" // for JA_DeleteMusic, JA_DeleteSound #include "jail_audio.h" // for JA_LoadMusic, JA_LoadSound, JA_...
#include "lang.h" // for Code, loadFromFile
#include "logo.h" // for Logo #include "logo.h" // for Logo
#include "manage_hiscore_table.h" // for ManageHiScoreTable #include "manage_hiscore_table.h" // for ManageHiScoreTable
#include "on_screen_help.h" // for OnScreenHelp #include "on_screen_help.h" // for OnScreenHelp
#include "options.h" // for options, loadOptionsFile, saveO... #include "options.h" // for options, loadOptionsFile, saveO...
#include "param.h" // for param, loadParamsFromFile #include "param.h" // for param, loadParamsFromFile
#include "screen.h" // for Screen #include "screen.h" // for Screen
#include "section.h" // for SectionName, name, options, SectionOptions #include "section.h" // for Name, name, Options, options
#include "title.h" // for Title #include "title.h" // for Title
#include "utils.h" // for MusicFile, SoundFile, opt... #include "utils.h" // for MusicFile, SoundFile, Options
#include <memory>
#ifndef _WIN32 #ifndef _WIN32
#include <pwd.h> // for getpwuid, passwd #include <pwd.h> // for getpwuid, passwd
#endif #endif
// Constructor // Constructor
Director::Director(int argc, char *argv[]) Director::Director(int argc, const char *argv[])
{ {
#ifdef RECORDING #ifdef RECORDING
section::name = section::Name::GAME; section::name = section::Name::GAME;
@@ -160,8 +161,8 @@ void Director::initInput()
Input::get()->bindKey(InputType::RESET, SDL_SCANCODE_F10); Input::get()->bindKey(InputType::RESET, SDL_SCANCODE_F10);
// Asigna botones a inputs // Asigna botones a inputs
const int numGamePads = Input::get()->getNumControllers(); const int num_gamepads = Input::get()->getNumControllers();
for (int i = 0; i < numGamePads; ++i) for (int i = 0; i < num_gamepads; ++i)
{ {
// Mando - Movimiento del jugador // Mando - Movimiento del jugador
Input::get()->bindGameControllerButton(i, InputType::UP, SDL_CONTROLLER_BUTTON_DPAD_UP); Input::get()->bindGameControllerButton(i, InputType::UP, SDL_CONTROLLER_BUTTON_DPAD_UP);
@@ -188,7 +189,7 @@ void Director::initInput()
} }
// Mapea las asignaciones a los botones desde el archivo de configuración, si se da el caso // Mapea las asignaciones a los botones desde el archivo de configuración, si se da el caso
for (int i = 0; i < numGamePads; ++i) for (int i = 0; i < num_gamepads; ++i)
for (int index = 0; index < (int)options.controller.size(); ++index) for (int index = 0; index < (int)options.controller.size(); ++index)
if (Input::get()->getControllerName(i) == options.controller[index].name) if (Input::get()->getControllerName(i) == options.controller[index].name)
{ {
@@ -200,7 +201,7 @@ void Director::initInput()
} }
// Asigna botones a inputs desde otros inputs // Asigna botones a inputs desde otros inputs
for (int i = 0; i < numGamePads; ++i) for (int i = 0; i < num_gamepads; ++i)
{ {
Input::get()->bindGameControllerButton(i, InputType::EXIT, InputType::START); Input::get()->bindGameControllerButton(i, InputType::EXIT, InputType::START);
Input::get()->bindGameControllerButton(i, InputType::RESET, InputType::FIRE_CENTER); Input::get()->bindGameControllerButton(i, InputType::RESET, InputType::FIRE_CENTER);
@@ -213,7 +214,7 @@ void Director::initInput()
} }
// Guarda las asignaciones de botones en las opciones // Guarda las asignaciones de botones en las opciones
for (int i = 0; i < numGamePads; ++i) for (int i = 0; i < num_gamepads; ++i)
{ {
options.controller[i].name = Input::get()->getControllerName(i); options.controller[i].name = Input::get()->getControllerName(i);
for (int j = 0; j < (int)options.controller[i].inputs.size(); ++j) for (int j = 0; j < (int)options.controller[i].inputs.size(); ++j)
@@ -484,7 +485,7 @@ void Director::loadParams(const std::string &file_path)
} }
// Comprueba los parametros del programa // Comprueba los parametros del programa
void Director::checkProgramArguments(int argc, char *argv[]) void Director::checkProgramArguments(int argc, const char *argv[])
{ {
// Establece la ruta del programa // Establece la ruta del programa
executable_path_ = argv[0]; executable_path_ = argv[0];
@@ -492,7 +493,7 @@ void Director::checkProgramArguments(int argc, char *argv[])
// Valores por defecto // Valores por defecto
param_file_argument_.clear(); param_file_argument_.clear();
// Comprueba el resto de parametros // Comprueba el resto de parámetros
for (int i = 1; i < argc; ++i) for (int i = 1; i < argc; ++i)
{ {
if (strcmp(argv[i], "--320x240") == 0) if (strcmp(argv[i], "--320x240") == 0)
@@ -566,17 +567,15 @@ void Director::createSystemFolder(const std::string &folder)
void Director::loadSounds() void Director::loadSounds()
{ {
// Obtiene la lista con las rutas a los ficheros de sonidos // Obtiene la lista con las rutas a los ficheros de sonidos
std::vector<std::string> list = Asset::get()->getListByType(AssetType::SOUND); auto list = Asset::get()->getListByType(AssetType::SOUND);
sounds_.clear(); sounds_.clear();
for (const auto &l : list) for (const auto &l : list)
{ {
const size_t lastIndex = l.find_last_of("/") + 1; auto last_index = l.find_last_of('/') + 1;
const std::string name = l.substr(lastIndex, std::string::npos); auto name = l.substr(last_index);
SoundFile temp;
temp.name = name; // Añade el nombre del fichero sounds_.emplace_back(SoundFile{name, JA_LoadSound(l.c_str())});
temp.file = JA_LoadSound(l.c_str()); // Carga el fichero de audio
sounds_.push_back(temp);
} }
} }
@@ -584,78 +583,69 @@ void Director::loadSounds()
void Director::loadMusics() void Director::loadMusics()
{ {
// Obtiene la lista con las rutas a los ficheros musicales // Obtiene la lista con las rutas a los ficheros musicales
std::vector<std::string> list = Asset::get()->getListByType(AssetType::MUSIC); auto list = Asset::get()->getListByType(AssetType::MUSIC);
musics_.clear(); musics_.clear();
for (const auto &l : list) for (const auto &l : list)
{ {
const size_t lastIndex = l.find_last_of("/") + 1; auto last_index = l.find_last_of('/') + 1;
const std::string name = l.substr(lastIndex, std::string::npos); auto name = l.substr(last_index);
MusicFile temp;
temp.name = name; // Añade el nombre del fichero musics_.emplace_back(MusicFile{name, JA_LoadMusic(l.c_str())});
temp.file = JA_LoadMusic(l.c_str()); // Carga el fichero de audio
musics_.push_back(temp);
} }
} }
// Ejecuta la sección con el logo // Ejecuta la sección con el logo
void Director::runLogo() void Director::runLogo()
{ {
auto logo = new Logo(); auto logo = std::make_unique<Logo>();
logo->run(); logo->run();
delete logo;
} }
// Ejecuta la sección con la secuencia de introducción // Ejecuta la sección con la secuencia de introducción
void Director::runIntro() void Director::runIntro()
{ {
auto intro = new Intro(getMusic(musics_, "intro.ogg")); auto intro = std::make_unique<Intro>(getMusic(musics_, "intro.ogg"));
intro->run(); intro->run();
delete intro;
} }
// Ejecuta la sección con el titulo del juego // Ejecuta la sección con el título del juego
void Director::runTitle() void Director::runTitle()
{ {
auto title = new Title(getMusic(musics_, "title.ogg")); auto title = std::make_unique<Title>(getMusic(musics_, "title.ogg"));
title->run(); title->run();
delete title;
} }
// Ejecuta la sección donde se juega al juego // Ejecuta la sección donde se juega al juego
void Director::runGame() void Director::runGame()
{ {
const auto playerID = section::options == section::Options::GAME_PLAY_1P ? 1 : 2; const auto player_id = section::options == section::Options::GAME_PLAY_1P ? 1 : 2;
constexpr auto currentStage = 0; constexpr auto current_stage = 0;
auto game = new Game(playerID, currentStage, GAME_MODE_DEMO_OFF, getMusic(musics_, "playing.ogg")); auto game = std::make_unique<Game>(player_id, current_stage, GAME_MODE_DEMO_OFF, getMusic(musics_, "playing.ogg"));
game->run(); game->run();
delete game;
} }
// Ejecuta la sección donde se muestran las instrucciones // Ejecuta la sección donde se muestran las instrucciones
void Director::runInstructions() void Director::runInstructions()
{ {
auto instructions = new Instructions(getMusic(musics_, "title.ogg")); auto instructions = std::make_unique<Instructions>(getMusic(musics_, "title.ogg"));
instructions->run(); instructions->run();
delete instructions;
} }
// Ejecuta la sección donde se muestra la tabla de puntuaciones // Ejecuta la sección donde se muestra la tabla de puntuaciones
void Director::runHiScoreTable() void Director::runHiScoreTable()
{ {
auto hiScoreTable = new HiScoreTable(getMusic(musics_, "title.ogg")); auto hi_score_table = std::make_unique<HiScoreTable>(getMusic(musics_, "title.ogg"));
hiScoreTable->run(); hi_score_table->run();
delete hiScoreTable;
} }
// Ejecuta el juego en modo demo // Ejecuta el juego en modo demo
void Director::runDemoGame() void Director::runDemoGame()
{ {
const auto playerID = (rand() % 2) + 1; const auto player_id = (rand() % 2) + 1;
constexpr auto currentStage = 0; constexpr auto current_stage = 0;
auto game = new Game(playerID, currentStage, GAME_MODE_DEMO_ON, nullptr); auto game = std::make_unique<Game>(player_id, current_stage, GAME_MODE_DEMO_ON, nullptr);
game->run(); game->run();
delete game;
} }
int Director::run() int Director::run()
@@ -702,8 +692,8 @@ int Director::run()
} }
} }
const int returnCode = section::options == section::Options::QUIT_NORMAL ? 0 : 1; const int return_code = section::options == section::Options::QUIT_NORMAL ? 0 : 1;
return returnCode; return return_code;
} }
// Obtiene una fichero a partir de un lang::Code // Obtiene una fichero a partir de un lang::Code

View File

@@ -2,10 +2,11 @@
#include <SDL2/SDL_render.h> // for SDL_Renderer #include <SDL2/SDL_render.h> // for SDL_Renderer
#include <SDL2/SDL_video.h> // for SDL_Window #include <SDL2/SDL_video.h> // for SDL_Window
#include <string> // for string, basic_string #include <string> // for string
#include <vector> // for vector #include <vector> // for vector
#include "lang.h" // for lang_e namespace lang { enum class Code : int; }
#include "utils.h" // for MusicFile, SoundFile struct MusicFile;
struct SoundFile;
// Textos // Textos
constexpr char WINDOW_CAPTION[] = "Coffee Crisis Arcade Edition"; constexpr char WINDOW_CAPTION[] = "Coffee Crisis Arcade Edition";
@@ -46,7 +47,7 @@ private:
void loadMusics(); void loadMusics();
// Comprueba los parametros del programa // Comprueba los parametros del programa
void checkProgramArguments(int argc, char *argv[]); void checkProgramArguments(int argc, const char *argv[]);
// Crea la carpeta del sistema donde guardar datos // Crea la carpeta del sistema donde guardar datos
void createSystemFolder(const std::string &folder); void createSystemFolder(const std::string &folder);
@@ -77,7 +78,7 @@ private:
public: public:
// Constructor // Constructor
Director(int argc, char *argv[]); Director(int argc, const char *argv[]);
// Destructor // Destructor
~Director(); ~Director();

View File

@@ -1,6 +1,7 @@
#include "explosions.h" #include "explosions.h"
#include <utility> // for move
#include "animated_sprite.h" // for AnimatedSprite #include "animated_sprite.h" // for AnimatedSprite
class Texture; class Texture; // lines 3-3
// Constructor // Constructor
Explosions::Explosions() Explosions::Explosions()

View File

@@ -1,10 +1,10 @@
#pragma once #pragma once
#include <memory> // for shared_ptr, unique_ptr
#include <string> // for string #include <string> // for string
#include <vector> // for vector #include <vector> // for vector
#include "animated_sprite.h" class AnimatedSprite;
#include <memory> class Texture;
#include "texture.h"
struct ExplosionTexture struct ExplosionTexture
{ {

View File

@@ -1,39 +1,41 @@
#include "game.h" #include "game.h"
#include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND
#include <SDL2/SDL_keycode.h> // for SDLK_1, SDLK_2, SDLK_3, SDLK_h #include <SDL2/SDL_events.h> // for SDL_PollEvent, SDL_Event, SDL_KEYDOWN
#include <SDL2/SDL_keycode.h> // for SDLK_1, SDLK_2, SDLK_3, SDLK_4
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_rwops.h> // for SDL_RWFromFile, SDL_RWclose, SDL_R... #include <SDL2/SDL_rwops.h> // for SDL_RWFromFile, SDL_RWclose, SDL_R...
#include <SDL2/SDL_timer.h> // for SDL_GetTicks #include <SDL2/SDL_timer.h> // for SDL_GetTicks
#include <SDL2/SDL_video.h> // for SDL_WINDOWEVENT_FOCUS_GAINED, SDL_... #include <SDL2/SDL_video.h> // for SDL_WINDOWEVENT_FOCUS_GAINED, SDL_...
#include <stdlib.h> // for rand #include <stdlib.h> // for rand
#include <algorithm> // for min #include <algorithm> // for min, remove_if
#include <fstream> // for basic_ifstream #include <fstream> // for basic_ostream, operator<<, basic_i...
#include <iostream> // for char_traits, basic_istream, ifstream #include <iostream> // for cout
#include <numeric> #include <numeric> // for accumulate
#include <utility> // for move
#include "asset.h" // for Asset #include "asset.h" // for Asset
#include "background.h" // for Background #include "background.h" // for Background
#include "balloon.h" // for Balloon, BALLOON_SPEED_1, BALLOON_... #include "balloon.h" // for Balloon, BALLOON_SCORE_1, BALLOON_...
#include "bullet.h" // for Bullet, BulletType::LEFT, BulletType::RIGHT #include "balloon_formations.h" // for Stage, BalloonFormationParams, Bal...
#include "balloon_formations.h" // for Stage, EnemyFormations, enemyIni... #include "bullet.h" // for Bullet, BulletType, BulletMoveStatus
#include "explosions.h" // for Explosions #include "explosions.h" // for Explosions
#include "fade.h" // for Fade, FadeType::RANDOM_SQUARE, FADE_VEN... #include "fade.h" // for Fade, FadeType
#include "global_inputs.h" // for globalInputs::check #include "global_inputs.h" // for check
#include "input.h" // for inputs_e, Input, INPUT_DO_NOT_ALLO... #include "input.h" // for InputType, Input, INPUT_DO_NOT_ALL...
#include "item.h" // for Item, ITEM_COFFEE_MACHINE, ITEM_CLOCK #include "item.h" // for Item, ITEM_COFFEE_MACHINE, ITEM_CLOCK
#include "jail_audio.h" // for JA_PlaySound, JA_DeleteSound, JA_L... #include "jail_audio.h" // for JA_PlaySound, JA_DeleteSound, JA_L...
#include "lang.h" // for getText #include "lang.h" // for getText
#include "manage_hiscore_table.h" // for ManageHiScoreTable #include "manage_hiscore_table.h" // for ManageHiScoreTable
#include "options.h" // for options #include "options.h" // for options
#include "param.h" // for param #include "param.h" // for param
#include "player.h" // for Player, PlayerStatus::PLAYING, PLA... #include "player.h" // for Player, PlayerStatus
#include "scoreboard.h" // for Scoreboard, scoreboard_modes_e #include "scoreboard.h" // for Scoreboard, ScoreboardMode, SCOREB...
#include "screen.h" // for Screen #include "screen.h" // for Screen
#include "section.h" // for Name, name, Options, options
#include "smart_sprite.h" // for SmartSprite #include "smart_sprite.h" // for SmartSprite
#include "text.h" // for Text, TEXT_CENTER #include "text.h" // for Text, TEXT_CENTER
#include "texture.h" // for Texture #include "texture.h" // for Texture
#include "dbgtxt.h" struct JA_Music_t; // lines 35-35
struct JA_Music_t; struct JA_Sound_t; // lines 36-36
struct JA_Sound_t;
// Constructor // Constructor
Game::Game(int player_id, int current_stage, bool demo, JA_Music_t *music) Game::Game(int player_id, int current_stage, bool demo, JA_Music_t *music)

View File

@@ -1,31 +1,29 @@
#pragma once #pragma once
#include <SDL2/SDL_events.h> // for SDL_Event
#include <SDL2/SDL_render.h> // for SDL_Renderer, SDL_Texture #include <SDL2/SDL_render.h> // for SDL_Renderer, SDL_Texture
#include <SDL2/SDL_stdinc.h> // for Uint32 #include <SDL2/SDL_stdinc.h> // for Uint32
#include <memory> // for shared_ptr, unique_ptr
#include <string> // for string #include <string> // for string
#include <vector> // for vector #include <vector> // for vector
#include "section.h" // for SectionOptions #include "balloon.h" // for Balloon
#include "player.h" // for Player
#include "utils.h" // for DemoKeys, Color, HiScoreEntry #include "utils.h" // for DemoKeys, Color, HiScoreEntry
#include <memory> class Asset;
#include "asset.h" // lines 11-11 class Background;
#include "background.h" // lines 12-12 class BalloonFormations;
#include "balloon.h" // lines 13-13 class Bullet;
#include "bullet.h" // lines 14-14 class Explosions;
#include "balloon_formations.h" // lines 15-15 class Fade;
#include "explosions.h" // lines 16-16 class Input;
#include "fade.h" // lines 17-17 class Item;
#include "input.h" // lines 18-18 class Scoreboard;
#include "item.h" // lines 19-19 class Screen;
#include "player.h" // lines 20-20 class SmartSprite;
#include "scoreboard.h" // lines 21-21 class Text;
#include "screen.h" // lines 22-22 class Texture;
#include "smart_sprite.h" // lines 23-23 enum class BulletType; // lines 26-26
#include "text.h" // lines 24-24 struct JA_Music_t; // lines 27-27
#include "texture.h" // lines 24-24 struct JA_Sound_t; // lines 28-28
enum class BulletType;
struct JA_Music_t; // lines 26-26
struct JA_Sound_t; // lines 27-27
// Modo demo // Modo demo
constexpr bool GAME_MODE_DEMO_OFF = false; constexpr bool GAME_MODE_DEMO_OFF = false;

View File

@@ -1,6 +1,6 @@
#include "game_logo.h" #include "game_logo.h"
#include <SDL2/SDL_render.h> // for SDL_FLIP_HORIZONTAL
#include <algorithm> // for max #include <algorithm> // for max
#include <string> // for basic_string
#include "animated_sprite.h" // for AnimatedSprite #include "animated_sprite.h" // for AnimatedSprite
#include "asset.h" // for Asset #include "asset.h" // for Asset
#include "jail_audio.h" // for JA_DeleteSound, JA_LoadSound, JA_PlaySound #include "jail_audio.h" // for JA_DeleteSound, JA_LoadSound, JA_PlaySound

View File

@@ -1,13 +1,11 @@
#pragma once #pragma once
#include <SDL2/SDL_render.h> // for SDL_Renderer #include <memory> // for unique_ptr, shared_ptr
#include <memory> class AnimatedSprite;
#include "texture.h" class SmartSprite;
#include "animated_sprite.h" class Sprite;
#include "smart_sprite.h" class Texture;
#include "sprite.h" struct JA_Sound_t; // lines 10-10
struct JA_Sound_t;
// Clase GameLogo // Clase GameLogo
class GameLogo class GameLogo

View File

@@ -1,5 +1,6 @@
#include "hiscore_table.h" #include "hiscore_table.h"
#include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND
#include <SDL2/SDL_events.h> // for SDL_PollEvent, SDL_Event, SDL_QUIT
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_timer.h> // for SDL_GetTicks #include <SDL2/SDL_timer.h> // for SDL_GetTicks
#include <SDL2/SDL_video.h> // for SDL_WINDOWEVENT_SIZE_CHANGED #include <SDL2/SDL_video.h> // for SDL_WINDOWEVENT_SIZE_CHANGED
@@ -7,15 +8,17 @@
#include <vector> // for vector #include <vector> // for vector
#include "asset.h" // for Asset #include "asset.h" // for Asset
#include "background.h" // for Background #include "background.h" // for Background
#include "global_inputs.h" // for globalInputs::check #include "fade.h" // for Fade, FadeMode, FadeType
#include "global_inputs.h" // for check
#include "input.h" // for Input #include "input.h" // for Input
#include "jail_audio.h" // for JA_GetMusicState, JA_Music_state #include "jail_audio.h" // for JA_GetMusicState, JA_Music_state
#include "lang.h" // for getText #include "lang.h" // for getText
#include "options.h" // for options #include "options.h" // for options
#include "param.h" // for param #include "param.h" // for param
#include "screen.h" // for Screen #include "screen.h" // for Screen
#include "text.h" // for Text, TEXT_CENTER, TEXT_SHADOW, TEXT_COLOR #include "section.h" // for Name, name, Options, options
#include "utils.h" // for Param, ParamGame, HiScoreEntry #include "text.h" // for Text, TEXT_CENTER, TEXT_SHADOW, TEXT...
#include "utils.h" // for Param, ParamGame, Color, HiScoreEntry
// Constructor // Constructor
HiScoreTable::HiScoreTable(JA_Music_t *music) HiScoreTable::HiScoreTable(JA_Music_t *music)

View File

@@ -1,17 +1,15 @@
#pragma once #pragma once
#include <SDL2/SDL_events.h> // for SDL_Event
#include <SDL2/SDL_rect.h> // for SDL_Rect #include <SDL2/SDL_rect.h> // for SDL_Rect
#include <SDL2/SDL_render.h> // for SDL_Renderer, SDL_Texture #include <SDL2/SDL_render.h> // for SDL_Renderer, SDL_Texture
#include <SDL2/SDL_stdinc.h> // for Uint16, Uint32 #include <SDL2/SDL_stdinc.h> // for Uint16, Uint32, Uint8
#include <memory> #include <memory> // for unique_ptr
#include <string> // for string #include <string> // for string
#include "fade.h" class Background; // lines 8-8
#include "section.h" // for SectionOptions class Fade; // lines 9-9
#include "background.h" class Text; // lines 10-10
#include "text.h" enum class FadeMode : Uint8; // lines 11-11
struct JA_Music_t; // lines 12-12
struct JA_Music_t;
/* /*
Esta clase gestiona un estado del programa. Se encarga de mostrar la tabla con las puntuaciones Esta clase gestiona un estado del programa. Se encarga de mostrar la tabla con las puntuaciones

View File

@@ -1,25 +1,26 @@
#include "instructions.h" #include "instructions.h"
#include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND
#include <SDL2/SDL_events.h> // for SDL_PollEvent, SDL_Event, SDL_QUIT
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_timer.h> // for SDL_GetTicks #include <SDL2/SDL_timer.h> // for SDL_GetTicks
#include <SDL2/SDL_video.h> // for SDL_WINDOWEVENT_SIZE_CHANGED #include <SDL2/SDL_video.h> // for SDL_WINDOWEVENT_SIZE_CHANGED
#include <algorithm> // for max #include <algorithm> // for max
#include <string> // for basic_string #include <utility> // for move
#include "asset.h" // for Asset #include "asset.h" // for Asset
#include "fade.h" // for Fade, FadeType::FULLSCREEN, FadeMode::IN #include "fade.h" // for Fade, FadeMode, FadeType
#include "global_inputs.h" // for globalInputs::check #include "global_inputs.h" // for check
#include "input.h" // for Input #include "input.h" // for Input
#include "jail_audio.h" // for JA_GetMusicState, JA_Music_state #include "jail_audio.h" // for JA_GetMusicState, JA_Music_state
#include "lang.h" // for getText #include "lang.h" // for getText
#include "param.h" // for param #include "param.h" // for param
#include "screen.h" // for Screen #include "screen.h" // for Screen
#include "section.h" // for name, SectionName, options, SectionOptions #include "section.h" // for Name, name, Options, options
#include "sprite.h" // for Sprite #include "sprite.h" // for Sprite
#include "text.h" // for Text, TEXT_CENTER, TEXT_COLOR, TEXT_SHADOW #include "text.h" // for Text, TEXT_CENTER, TEXT_COLOR, TEXT_...
#include "texture.h" // for Texture #include "texture.h" // for Texture
#include "tiled_bg.h" // for Tiledbg, TILED_MODE_STATIC #include "tiled_bg.h" // for Tiledbg, TILED_MODE_STATIC
#include "utils.h" // for Param, ParamGame, Color, shdwT... #include "utils.h" // for Param, ParamGame, Color, shdw_txt_color
struct JA_Music_t; struct JA_Music_t; // lines 22-22
// Constructor // Constructor
Instructions::Instructions(JA_Music_t *music) Instructions::Instructions(JA_Music_t *music)

View File

@@ -1,17 +1,16 @@
#pragma once #pragma once
#include <SDL2/SDL_events.h> // for SDL_Event
#include <SDL2/SDL_rect.h> // for SDL_Point, SDL_Rect #include <SDL2/SDL_rect.h> // for SDL_Point, SDL_Rect
#include <SDL2/SDL_render.h> // for SDL_Texture, SDL_Renderer #include <SDL2/SDL_render.h> // for SDL_Texture, SDL_Renderer
#include <SDL2/SDL_stdinc.h> // for Uint32 #include <SDL2/SDL_stdinc.h> // for Uint32
#include <memory> // for unique_ptr, shared_ptr
#include <vector> // for vector #include <vector> // for vector
#include <memory> class Fade;
#include "fade.h" class Sprite;
#include "sprite.h" class Text;
#include "text.h" class Texture;
#include "texture.h" class Tiledbg;
#include "tiled_bg.h" struct JA_Music_t; // lines 14-14
struct JA_Music_t;
/* /*
Esta clase gestiona un estado del programa. Se encarga de poner en pantalla Esta clase gestiona un estado del programa. Se encarga de poner en pantalla

View File

@@ -1,22 +1,22 @@
#include "intro.h" #include "intro.h"
#include <SDL2/SDL_render.h> // for SDL_Renderer #include <SDL2/SDL_events.h> // for SDL_PollEvent, SDL_Event, SDL_QUIT, SDL...
#include <SDL2/SDL_timer.h> // for SDL_GetTicks #include <SDL2/SDL_timer.h> // for SDL_GetTicks
#include <SDL2/SDL_video.h> // for SDL_WINDOWEVENT_SIZE_CHANGED #include <SDL2/SDL_video.h> // for SDL_WINDOWEVENT_SIZE_CHANGED
#include <string> // for basic_string #include <utility> // for move
#include "asset.h" // for Asset #include "asset.h" // for Asset
#include "global_inputs.h" // for globalInputs::check #include "global_inputs.h" // for check
#include "input.h" // for Input #include "input.h" // for Input
#include "jail_audio.h" // for JA_StopMusic, JA_PlayMusic #include "jail_audio.h" // for JA_StopMusic, JA_PlayMusic
#include "lang.h" // for getText #include "lang.h" // for getText
#include "param.h" // for param #include "param.h" // for param
#include "screen.h" // for Screen #include "screen.h" // for Screen
#include "section.h" // for name, SectionName, options, SectionOptions #include "section.h" // for Name, name, Options, options
#include "smart_sprite.h" // for SmartSprite #include "smart_sprite.h" // for SmartSprite
#include "text.h" // for Text #include "text.h" // for Text
#include "texture.h" // for Texture #include "texture.h" // for Texture
#include "utils.h" // for ParamGame, Param, Zone, BLOCK #include "utils.h" // for Param, ParamGame, Zone, BLOCK, Color
#include "writer.h" // for Writer #include "writer.h" // for Writer
struct JA_Music_t; struct JA_Music_t; // lines 19-19
// Constructor // Constructor
Intro::Intro(JA_Music_t *music) Intro::Intro(JA_Music_t *music)

View File

@@ -1,14 +1,13 @@
#pragma once #pragma once
#include <SDL2/SDL_events.h> // for SDL_Event
#include <SDL2/SDL_stdinc.h> // for Uint32, Uint8 #include <SDL2/SDL_stdinc.h> // for Uint32, Uint8
#include <memory> // for unique_ptr, shared_ptr
#include <vector> // for vector #include <vector> // for vector
#include <memory> #include "smart_sprite.h" // for SmartSprite
#include "smart_sprite.h" #include "writer.h" // for Writer
#include "texture.h" class Text;
#include "text.h" class Texture;
#include "writer.h" struct JA_Music_t; // lines 11-11
struct JA_Music_t;
/* /*
Esta clase gestiona un estado del programa. Se encarga de mostrar la secuencia Esta clase gestiona un estado del programa. Se encarga de mostrar la secuencia

View File

@@ -2,12 +2,12 @@
#include <SDL2/SDL_rect.h> // for SDL_Rect #include <SDL2/SDL_rect.h> // for SDL_Rect
#include <SDL2/SDL_stdinc.h> // for Uint16 #include <SDL2/SDL_stdinc.h> // for Uint16
#include <memory> // for shared_ptr, unique_ptr
#include <string> // for string #include <string> // for string
#include <vector> // for vector #include <vector> // for vector
#include <memory> #include "animated_sprite.h" // for AnimatedSprite
#include "utils.h" // for Circle #include "utils.h" // for Circle
#include "animated_sprite.h" class Texture;
#include "texture.h"
// Tipos de objetos // Tipos de objetos
constexpr int ITEM_POINTS_1_DISK = 1; constexpr int ITEM_POINTS_1_DISK = 1;

View File

@@ -1,15 +1,16 @@
#include "logo.h" #include "logo.h"
#include <SDL2/SDL_events.h> // for SDL_PollEvent, SDL_Event, SDL_QUIT, SDL...
#include <SDL2/SDL_render.h> // for SDL_Renderer #include <SDL2/SDL_render.h> // for SDL_Renderer
#include <SDL2/SDL_timer.h> // for SDL_GetTicks #include <SDL2/SDL_timer.h> // for SDL_GetTicks
#include <SDL2/SDL_video.h> // for SDL_WINDOWEVENT_SIZE_CHANGED #include <SDL2/SDL_video.h> // for SDL_WINDOWEVENT_SIZE_CHANGED
#include <string> // for basic_string #include <utility> // for move
#include "asset.h" // for Asset #include "asset.h" // for Asset
#include "global_inputs.h" // for globalInputs::check #include "global_inputs.h" // for check
#include "input.h" // for Input #include "input.h" // for Input
#include "jail_audio.h" // for JA_StopMusic #include "jail_audio.h" // for JA_StopMusic
#include "param.h" // for param #include "param.h" // for param
#include "screen.h" // for Screen #include "screen.h" // for Screen
#include "section.h" // for name, SectionName, options, SectionOptions #include "section.h" // for Name, name, Options, options
#include "sprite.h" // for Sprite #include "sprite.h" // for Sprite
#include "texture.h" // for Texture #include "texture.h" // for Texture
@@ -114,12 +115,12 @@ void Logo::updateJAILGAMES()
{ {
for (int i = 0; i < (int)jail_sprite_.size(); ++i) for (int i = 0; i < (int)jail_sprite_.size(); ++i)
{ {
if (jail_sprite_[i]->getPosX() != dest_.x) if (jail_sprite_[i]->getIntPosX() != dest_.x)
{ {
if (i % 2 == 0) if (i % 2 == 0)
{ {
jail_sprite_[i]->incPosX(-SPEED); jail_sprite_[i]->incPosX(-SPEED);
if (jail_sprite_[i]->getPosX() < dest_.x) if (jail_sprite_[i]->getIntPosX() < dest_.x)
{ {
jail_sprite_[i]->setPosX(dest_.x); jail_sprite_[i]->setPosX(dest_.x);
} }
@@ -127,7 +128,7 @@ void Logo::updateJAILGAMES()
else else
{ {
jail_sprite_[i]->incPosX(SPEED); jail_sprite_[i]->incPosX(SPEED);
if (jail_sprite_[i]->getPosX() > dest_.x) if (jail_sprite_[i]->getIntPosX() > dest_.x)
{ {
jail_sprite_[i]->setPosX(dest_.x); jail_sprite_[i]->setPosX(dest_.x);
} }

View File

@@ -1,13 +1,12 @@
#pragma once #pragma once
#include <SDL2/SDL_events.h> // for SDL_Event
#include <SDL2/SDL_rect.h> // for SDL_Point #include <SDL2/SDL_rect.h> // for SDL_Point
#include <SDL2/SDL_stdinc.h> // for Uint32 #include <SDL2/SDL_stdinc.h> // for Uint32
#include <memory> // for unique_ptr, shared_ptr
#include <vector> // for vector #include <vector> // for vector
#include <memory> #include "sprite.h" // for Sprite
#include "utils.h" // for Color #include "utils.h" // for Color
#include "sprite.h" class Texture;
#include "texture.h"
/* /*
Esta clase gestiona un estado del programa. Se encarga de dibujar por pantalla el Esta clase gestiona un estado del programa. Se encarga de dibujar por pantalla el

View File

@@ -7,8 +7,8 @@ Actualizando a la versión "Arcade Edition" en 08/05/2024
*/ */
#include <iostream> // for basic_ostream, char_traits, operator<<, cout #include <iostream> // for char_traits, basic_ostream, operator<<, cout
#include <string> // for basic_string, operator<<, string #include <memory> // for make_unique, unique_ptr
#include "director.h" // for Director #include "director.h" // for Director
int main(int argc, char *argv[]) int main(int argc, char *argv[])
@@ -16,14 +16,11 @@ int main(int argc, char *argv[])
std::cout << "Game start" << std::endl; std::cout << "Game start" << std::endl;
// Crea el objeto Director // Crea el objeto Director
Director *director = new Director(argc, argv); auto director = std::make_unique<Director>(argc, const_cast<const char **>(argv));
// Bucle principal // Bucle principal
const auto exit = director->run(); const auto exit = director->run();
// Destruye el objeto Director
delete director;
const auto endType = exit == 0 ? "keyboard" : "controller"; const auto endType = exit == 0 ? "keyboard" : "controller";
std::cout << "\nGame end with " << endType << std::endl; std::cout << "\nGame end with " << endType << std::endl;

View File

@@ -3,9 +3,9 @@
#include <SDL2/SDL_rect.h> // for SDL_Rect, SDL_Point #include <SDL2/SDL_rect.h> // for SDL_Rect, SDL_Point
#include <SDL2/SDL_render.h> // for SDL_RendererFlip #include <SDL2/SDL_render.h> // for SDL_RendererFlip
#include <SDL2/SDL_stdinc.h> // for Uint16 #include <SDL2/SDL_stdinc.h> // for Uint16
#include <memory> #include <memory> // for shared_ptr
#include "sprite.h" // for Sprite #include "sprite.h" // for Sprite
#include "texture.h" class Texture;
// Clase MovingSprite. Añade posicion y velocidad en punto flotante // Clase MovingSprite. Añade posicion y velocidad en punto flotante
class MovingSprite : public Sprite class MovingSprite : public Sprite
@@ -41,6 +41,9 @@ public:
explicit MovingSprite(float x = 0, float y = 0, int w = 0, int h = 0, float velx = 0, float vely = 0, float accelx = 0, float accely = 0, std::shared_ptr<Texture> texture = nullptr); explicit MovingSprite(float x = 0, float y = 0, int w = 0, int h = 0, float velx = 0, float vely = 0, float accelx = 0, float accely = 0, std::shared_ptr<Texture> texture = nullptr);
explicit MovingSprite(std::shared_ptr<Texture> texture = nullptr); explicit MovingSprite(std::shared_ptr<Texture> texture = nullptr);
// Destructor
virtual ~MovingSprite() = default;
// Mueve el sprite // Mueve el sprite
void move(); void move();

View File

@@ -1,10 +1,9 @@
#include "notify.h" #include "notify.h"
#include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888
#include <string> // for basic_string, char_traits, string #include <string> // for string
#include "jail_audio.h" // for JA_DeleteSound, JA_LoadSound, JA_Pla... #include "jail_audio.h" // for JA_DeleteSound, JA_LoadSound, JA_Pla...
#include "options.h" // for options #include "param.h" // for param
#include "param.h"
#include "sprite.h" // for Sprite #include "sprite.h" // for Sprite
#include "text.h" // for Text #include "text.h" // for Text
#include "texture.h" // for Texture #include "texture.h" // for Texture

View File

@@ -2,14 +2,14 @@
#include <SDL2/SDL_rect.h> // for SDL_Rect #include <SDL2/SDL_rect.h> // for SDL_Rect
#include <SDL2/SDL_render.h> // for SDL_Renderer #include <SDL2/SDL_render.h> // for SDL_Renderer
#include <string> // for basic_string, string #include <memory> // for shared_ptr, unique_ptr
#include <string> // for string, basic_string
#include <vector> // for vector #include <vector> // for vector
#include <memory>
#include "utils.h" // for Color #include "utils.h" // for Color
#include "text.h" class Sprite;
#include "texture.h" class Text;
#include "sprite.h" class Texture;
struct JA_Sound_t; struct JA_Sound_t; // lines 12-12
class Notify class Notify
{ {

View File

@@ -1,8 +1,7 @@
#include "on_screen_help.h" #include "on_screen_help.h"
#include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888
#include <memory> // for make_unique, unique_ptr #include <memory> // for make_unique, make_shared, unique_ptr
#include <string> // for basic_string
#include "asset.h" // for Asset #include "asset.h" // for Asset
#include "lang.h" // for getText #include "lang.h" // for getText
#include "param.h" // for param #include "param.h" // for param
@@ -10,7 +9,7 @@
#include "sprite.h" // for Sprite #include "sprite.h" // for Sprite
#include "text.h" // for Text #include "text.h" // for Text
#include "texture.h" // for Texture #include "texture.h" // for Texture
#include "utils.h" // for easeInOutSine, ParamGame, Param #include "utils.h" // for easeInOutSine, Param, ParamGame
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado // [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
OnScreenHelp *OnScreenHelp::onScreenHelp = nullptr; OnScreenHelp *OnScreenHelp::onScreenHelp = nullptr;

View File

@@ -3,9 +3,8 @@
#include <SDL2/SDL_rect.h> // for SDL_Rect #include <SDL2/SDL_rect.h> // for SDL_Rect
#include <SDL2/SDL_render.h> // for SDL_Texture #include <SDL2/SDL_render.h> // for SDL_Texture
#include <vector> // for vector #include <vector> // for vector
#include <memory> class Sprite;
#include "sprite.h" // lines 10-10 class Text;
#include "text.h"
enum class OnScreenHelpStatus enum class OnScreenHelpStatus
{ {

View File

@@ -195,7 +195,7 @@ void loadParamsFromFile(const std::string &file_path)
auto comment_pos = line.find('#'); auto comment_pos = line.find('#');
if (comment_pos != std::string::npos) if (comment_pos != std::string::npos)
{ {
line = line.substr(0, comment_pos); line.resize(comment_pos);
} }
// Usa un stream para separar palabras // Usa un stream para separar palabras

View File

@@ -2,14 +2,15 @@
#include <SDL2/SDL_rect.h> // for SDL_Rect #include <SDL2/SDL_rect.h> // for SDL_Rect
#include <SDL2/SDL_stdinc.h> // for Uint32 #include <SDL2/SDL_stdinc.h> // for Uint32
#include <memory> // for unique_ptr #include <memory> // for unique_ptr, shared_ptr
#include <string> // for string, basic_string #include <string> // for string
#include <vector> // for vector #include <vector> // for vector
#include "animated_sprite.h" // for AnimatedSprite #include "animated_sprite.h" // for AnimatedSprite
#include "enter_name.h" // for EnterName #include "enter_name.h" // for EnterName
#include "utils.h" // for Circle #include "utils.h" // for Circle
#include "texture.h" // lines 12-12 class Texture;
enum class ScoreboardMode; enum class InputType : int;
enum class ScoreboardMode; // lines 12-12
// Estados del jugador // Estados del jugador
enum class PlayerStatus enum class PlayerStatus

View File

@@ -3,13 +3,13 @@
#include <SDL2/SDL_rect.h> // for SDL_Point, SDL_Rect #include <SDL2/SDL_rect.h> // for SDL_Point, SDL_Rect
#include <SDL2/SDL_render.h> // for SDL_Renderer, SDL_Texture #include <SDL2/SDL_render.h> // for SDL_Renderer, SDL_Texture
#include <SDL2/SDL_stdinc.h> // for Uint32 #include <SDL2/SDL_stdinc.h> // for Uint32
#include <memory> // for unique_ptr #include <memory> // for unique_ptr, shared_ptr
#include <string> // for string, basic_string #include <string> // for string
#include <vector> // for vector #include <vector> // for vector
#include "utils.h" // for Color #include "utils.h" // for Color
#include "sprite.h" // lines 11-11 class Sprite;
#include "text.h" // lines 12-12 class Text;
#include "texture.h" // lines 13-13 class Texture;
// Defines // Defines
constexpr int SCOREBOARD_LEFT_PANEL = 0; constexpr int SCOREBOARD_LEFT_PANEL = 0;
@@ -103,7 +103,7 @@ private:
// [SINGLETON] Ahora el constructor y el destructor son privados // [SINGLETON] Ahora el constructor y el destructor son privados
// Constructor // Constructor
Scoreboard(SDL_Renderer *renderer); explicit Scoreboard(SDL_Renderer *renderer);
// Destructor // Destructor
~Scoreboard(); ~Scoreboard();

View File

@@ -1,8 +1,8 @@
#pragma once #pragma once
#include <memory> // for shared_ptr
#include "animated_sprite.h" // for AnimatedSprite #include "animated_sprite.h" // for AnimatedSprite
#include "texture.h" class Texture;
#include <memory>
// Clase SmartSprite // Clase SmartSprite
class SmartSprite : public AnimatedSprite class SmartSprite : public AnimatedSprite

View File

@@ -21,13 +21,13 @@ void Sprite::render()
} }
// Obten el valor de la variable // Obten el valor de la variable
int Sprite::getPosX() const int Sprite::getIntPosX() const
{ {
return pos_.x; return pos_.x;
} }
// Obten el valor de la variable // Obten el valor de la variable
int Sprite::getPosY() const int Sprite::getIntPosY() const
{ {
return pos_.y; return pos_.y;
} }

View File

@@ -20,14 +20,14 @@ public:
explicit Sprite(std::shared_ptr<Texture> texture = nullptr); explicit Sprite(std::shared_ptr<Texture> texture = nullptr);
// Destructor // Destructor
~Sprite() = default; virtual ~Sprite() = default;
// Muestra el sprite por pantalla // Muestra el sprite por pantalla
virtual void render(); virtual void render();
// Obten el valor de la variable // Obten el valor de la variable
int getPosX() const; int getIntPosX() const;
int getPosY() const; int getIntPosY() const;
int getWidth() const; int getWidth() const;
int getHeight() const; int getHeight() const;

View File

@@ -1,5 +1,6 @@
#include "text.h" #include "text.h"
#include <fstream> // for char_traits, basic_ostream, basic_ifstream, ope... #include <SDL2/SDL_rect.h> // for SDL_Rect
#include <fstream> // for basic_ostream, basic_ifstream, basic_istream
#include <iostream> // for cout #include <iostream> // for cout
#include "sprite.h" // for Sprite #include "sprite.h" // for Sprite
#include "texture.h" // for Texture #include "texture.h" // for Texture
@@ -81,7 +82,7 @@ TextFile LoadTextFile(std::string file_path)
} }
// Constructor // Constructor
Text::Text(std::string bitmap_file, std::string text_file, SDL_Renderer *renderer) Text::Text(const std::string &bitmap_file, const std::string &text_file, SDL_Renderer *renderer)
{ {
// Carga los offsets desde el fichero // Carga los offsets desde el fichero
auto tf = LoadTextFile(text_file); auto tf = LoadTextFile(text_file);
@@ -105,7 +106,7 @@ Text::Text(std::string bitmap_file, std::string text_file, SDL_Renderer *rendere
} }
// Constructor // Constructor
Text::Text(std::string text_file, std::shared_ptr<Texture> texture) Text::Text(const std::string &text_file, std::shared_ptr<Texture> texture)
{ {
// Carga los offsets desde el fichero // Carga los offsets desde el fichero
auto tf = LoadTextFile(text_file); auto tf = LoadTextFile(text_file);

View File

@@ -2,11 +2,11 @@
#include <SDL2/SDL_render.h> // for SDL_Renderer #include <SDL2/SDL_render.h> // for SDL_Renderer
#include <SDL2/SDL_stdinc.h> // for Uint8 #include <SDL2/SDL_stdinc.h> // for Uint8
#include <memory> // for shared_ptr, unique_ptr
#include <string> // for string #include <string> // for string
#include <memory> #include "sprite.h" // for Sprite
#include "utils.h" #include "utils.h" // for Color
#include "sprite.h" class Texture;
#include "texture.h"
constexpr int TEXT_COLOR = 1; constexpr int TEXT_COLOR = 1;
constexpr int TEXT_SHADOW = 2; constexpr int TEXT_SHADOW = 2;
@@ -44,8 +44,8 @@ private:
public: public:
// Constructor // Constructor
Text(std::string bitmap_file, std::string text_file, SDL_Renderer *renderer); Text(const std::string &bitmap_file, const std::string &text_file, SDL_Renderer *renderer);
Text(std::string text_file, std::shared_ptr<Texture> texture); Text(const std::string &text_file, std::shared_ptr<Texture> texture);
Text(TextFile *text_file, std::shared_ptr<Texture> texture); Text(TextFile *text_file, std::shared_ptr<Texture> texture);
// Destructor // Destructor
@@ -64,7 +64,7 @@ public:
void writeCentered(int x, int y, const std::string &text, int kerning = 1, int lenght = -1); void writeCentered(int x, int y, const std::string &text, int kerning = 1, int lenght = -1);
// Escribe texto con extras // Escribe texto con extras
void writeDX(Uint8 flags, int x, int y, const std::string &text, int kerning = 1, Color textColor = {255, 255, 255}, Uint8 shadow_distance = 1, Color shadow_color = {0, 0, 0}, int lenght = -1); void writeDX(Uint8 flags, int x, int y, const std::string &text, int kerning = 1, Color textColor = Color(), Uint8 shadow_distance = 1, Color shadow_color = Color(), int lenght = -1);
// Obtiene la longitud en pixels de una cadena // Obtiene la longitud en pixels de una cadena
int lenght(const std::string &text, int kerning = 1) const; int lenght(const std::string &text, int kerning = 1) const;

View File

@@ -56,7 +56,6 @@ Texture::~Texture()
// Carga una imagen desde un fichero // Carga una imagen desde un fichero
bool Texture::loadFromFile(const std::string &path) bool Texture::loadFromFile(const std::string &path)
{ {
const std::string file_name = path.substr(path.find_last_of("\\/") + 1);
int req_format = STBI_rgb_alpha; int req_format = STBI_rgb_alpha;
int width, height, orig_format; int width, height, orig_format;
unsigned char *data = stbi_load(path.c_str(), &width, &height, &orig_format, req_format); unsigned char *data = stbi_load(path.c_str(), &width, &height, &orig_format, req_format);
@@ -70,6 +69,7 @@ bool Texture::loadFromFile(const std::string &path)
else else
{ {
#ifdef VERBOSE #ifdef VERBOSE
const std::string file_name = path.substr(path.find_last_of("\\/") + 1);
std::cout << "Image loaded: " << file_name << std::endl; std::cout << "Image loaded: " << file_name << std::endl;
#endif #endif
} }
@@ -96,7 +96,7 @@ bool Texture::loadFromFile(const std::string &path)
SDL_Texture *newTexture = nullptr; SDL_Texture *newTexture = nullptr;
// Carga la imagen desde una ruta específica // Carga la imagen desde una ruta específica
auto loadedSurface = SDL_CreateRGBSurfaceWithFormatFrom(static_cast<void*>(data), width, height, depth, pitch, pixel_format); auto loadedSurface = SDL_CreateRGBSurfaceWithFormatFrom(static_cast<void *>(data), width, height, depth, pitch, pixel_format);
if (loadedSurface == nullptr) if (loadedSurface == nullptr)
{ {
#ifdef VERBOSE #ifdef VERBOSE
@@ -137,9 +137,9 @@ bool Texture::createBlank(int width, int height, SDL_PixelFormatEnum format, SDL
texture_ = SDL_CreateTexture(renderer_, format, access, width, height); texture_ = SDL_CreateTexture(renderer_, format, access, width, height);
if (!texture_) if (!texture_)
{ {
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Unable to create blank texture! SDL Error: " << SDL_GetError() << std::endl; std::cout << "Unable to create blank texture! SDL Error: " << SDL_GetError() << std::endl;
#endif #endif
} }
else else
{ {
@@ -239,14 +239,14 @@ SDL_Texture *Texture::getSDLTexture()
} }
// Crea una nueva surface // Crea una nueva surface
Surface Texture::newSurface(int w, int h) /*Surface Texture::newSurface(int w, int h)
{ {
Surface surf = static_cast<Surface>(malloc(sizeof(surface_s))); Surface surf = static_cast<Surface>(malloc(sizeof(surface_s)));
surf->w = w; surf->w = w;
surf->h = h; surf->h = h;
surf->data = static_cast<Uint8 *>(malloc(w * h)); surf->data = static_cast<Uint8 *>(malloc(w * h));
return surf; return surf;
} }*/
// Elimina una surface // Elimina una surface
void Texture::deleteSurface(Surface surface) void Texture::deleteSurface(Surface surface)
@@ -312,7 +312,7 @@ void Texture::flipSurface()
// Vuelca los datos // Vuelca los datos
Uint32 *pixels; Uint32 *pixels;
int pitch; int pitch;
SDL_LockTexture(texture_, nullptr, reinterpret_cast<void**>(&pixels), &pitch); SDL_LockTexture(texture_, nullptr, reinterpret_cast<void **>(&pixels), &pitch);
for (int i = 0; i < width_ * height_; ++i) for (int i = 0; i < width_ * height_; ++i)
{ {
pixels[i] = palettes_[paletteIndex_][surface_->data[i]]; pixels[i] = palettes_[paletteIndex_][surface_->data[i]];
@@ -344,7 +344,7 @@ std::vector<Uint32> Texture::loadPal(const std::string &file_name)
fread(buffer, size, 1, f); fread(buffer, size, 1, f);
fclose(f); fclose(f);
auto pal = LoadPalette(buffer); const auto *pal = LoadPalette(buffer);
if (!pal) if (!pal)
{ {
return palette; return palette;
@@ -361,9 +361,9 @@ std::vector<Uint32> Texture::loadPal(const std::string &file_name)
} }
// Añade una paleta a la lista // Añade una paleta a la lista
void Texture::addPalette(std::string path) void Texture::addPalette(const std::string &path)
{ {
palettes_.push_back(loadPal(path.c_str())); palettes_.push_back(loadPal(path));
setPaletteColor((int)palettes_.size() - 1, 0, 0x00000000); setPaletteColor((int)palettes_.size() - 1, 0, 0x00000000);
} }

View File

@@ -33,7 +33,7 @@ private:
int paletteIndex_; // Indice de la paleta en uso int paletteIndex_; // Indice de la paleta en uso
// Crea una nueva surface // Crea una nueva surface
Surface newSurface(int w, int h); //Surface newSurface(int w, int h);
// Elimina una surface // Elimina una surface
void deleteSurface(Surface surface); void deleteSurface(Surface surface);
@@ -91,7 +91,7 @@ public:
SDL_Texture *getSDLTexture(); SDL_Texture *getSDLTexture();
// Añade una paleta a la lista // Añade una paleta a la lista
void addPalette(std::string path); void addPalette(const std::string &path);
// Establece un color de la paleta // Establece un color de la paleta
void setPaletteColor(int palette, int index, Uint32 color); void setPaletteColor(int palette, int index, Uint32 color);

View File

@@ -2,6 +2,7 @@
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_stdinc.h> // for SDL_sinf #include <SDL2/SDL_stdinc.h> // for SDL_sinf
#include <stdlib.h> // for rand #include <stdlib.h> // for rand
#include <memory> // for unique_ptr, make_shared, make_unique
#include "screen.h" // for Screen #include "screen.h" // for Screen
#include "sprite.h" // for Sprite #include "sprite.h" // for Sprite
#include "texture.h" // for Texture #include "texture.h" // for Texture

View File

@@ -1,20 +1,24 @@
#include "title.h" #include "title.h"
#include <SDL2/SDL_events.h> // for SDL_PollEvent, SDL_Event, SDL_KEYDOWN
#include <SDL2/SDL_keycode.h> // for SDLK_1, SDLK_2, SDLK_3 #include <SDL2/SDL_keycode.h> // for SDLK_1, SDLK_2, SDLK_3
#include <SDL2/SDL_rect.h> // for SDL_Rect
#include <SDL2/SDL_render.h> // for SDL_Renderer #include <SDL2/SDL_render.h> // for SDL_Renderer
#include <SDL2/SDL_timer.h> // for SDL_GetTicks #include <SDL2/SDL_timer.h> // for SDL_GetTicks
#include <string> // for allocator, basic_string, char_traits #include <string> // for char_traits, operator+, to_string, bas...
#include <utility> // for move
#include <vector> // for vector #include <vector> // for vector
#include "asset.h" // for Asset #include "asset.h" // for Asset
#include "global_inputs.h" // for globalInputs::check #include "global_inputs.h" // for check
#include "input.h" // for Input, inputs_e, INPUT_DO_NOT_ALLOW_RE... #include "input.h" // for Input, InputType, INPUT_DO_NOT_ALLOW_R...
#include "jail_audio.h" // for JA_GetMusicState, JA_Music_state, JA_P... #include "jail_audio.h" // for JA_GetMusicState, JA_Music_state, JA_P...
#include "lang.h" // for getText #include "lang.h" // for getText
#include "options.h" // for options #include "options.h" // for options
#include "param.h" // for param #include "param.h" // for param
#include "screen.h" // for Screen #include "screen.h" // for Screen
#include "section.h" // for SectionOptions, options, SectionName, name #include "section.h" // for Options, options, Name, name
#include "texture.h" // for Texture
struct JA_Music_t; #include "utils.h" // for Param, OptionsController, Color, Param...
struct JA_Music_t; // lines 17-17
// Constructor // Constructor
Title::Title(JA_Music_t *music) Title::Title(JA_Music_t *music)

View File

@@ -1,24 +1,18 @@
#pragma once #pragma once
#include <SDL2/SDL_events.h> // for SDL_Event
#include <SDL2/SDL_stdinc.h> // for Uint32 #include <SDL2/SDL_stdinc.h> // for Uint32
#include <memory> #include <memory> // for unique_ptr, shared_ptr
#include "define_buttons.h" #include "define_buttons.h" // for DefineButtons
#include "fade.h" #include "fade.h" // for Fade
#include "game_logo.h" #include "game_logo.h" // for GameLogo
#include "text.h" #include "sprite.h" // for Sprite
#include "tiled_bg.h" #include "text.h" // for Text
#include "utils.h" // for Section #include "tiled_bg.h" // for Tiledbg
#include "sprite.h" class Input; // lines 17-17
#include "texture.h" class Screen; // lines 18-18
#include "section.h" class Texture; // lines 20-20
namespace section { enum class Name; }
class Asset; struct JA_Music_t; // lines 21-21
class Input;
class Screen;
class Sprite;
class Texture;
struct JA_Music_t;
// Textos // Textos
constexpr const char TEXT_COPYRIGHT[] = "@2020,2024 JailDesigner"; constexpr const char TEXT_COPYRIGHT[] = "@2020,2024 JailDesigner";

View File

@@ -1,11 +1,10 @@
#include "utils.h" #include "utils.h"
#include <stdlib.h> // for free, malloc #include <algorithm> // for min, clamp, find_if_not, transform
#include <algorithm> // for max, min #include <cctype> // for tolower, isspace
#include <cctype> // for isspace #include <cmath> // for cos, pow, M_PI
#include <iterator> // for distance #include <compare> // for operator<
#include <cmath> struct JA_Music_t; // lines 7-7
struct JA_Music_t; // lines 3-3 struct JA_Sound_t; // lines 8-8
struct JA_Sound_t; // lines 4-4
// Colores // Colores
const Color bg_color = {0x27, 0x27, 0x36}; const Color bg_color = {0x27, 0x27, 0x36};

View File

@@ -3,16 +3,19 @@
#include <SDL2/SDL_gamecontroller.h> // for SDL_GameControllerButton #include <SDL2/SDL_gamecontroller.h> // for SDL_GameControllerButton
#include <SDL2/SDL_rect.h> // for SDL_Rect, SDL_Point #include <SDL2/SDL_rect.h> // for SDL_Rect, SDL_Point
#include <SDL2/SDL_render.h> // for SDL_Renderer #include <SDL2/SDL_render.h> // for SDL_Renderer
#include <SDL2/SDL_stdinc.h> // for Uint8, Uint32 #include <SDL2/SDL_stdinc.h> // for Uint8
#include <stdint.h> // for int32_t #include <stdint.h> // for int32_t
#include <string> // for string, basic_string #include <string> // for string
#include <vector> // for vector #include <vector> // for vector
#include "input.h" // for inputs_e enum class InputType : int;
#include "lang.h" enum class ScreenFilter; // lines 14-14
struct JA_Music_t; enum class ScreenVideoMode; // lines 15-15
struct JA_Sound_t; namespace lang
enum class ScreenFilter; {
enum class ScreenVideoMode; enum class Code : int;
}
struct JA_Music_t; // lines 12-12
struct JA_Sound_t; // lines 13-13
// Dificultad del juego // Dificultad del juego
enum class GameDifficulty enum class GameDifficulty
@@ -35,6 +38,7 @@ struct Circle
struct Color struct Color
{ {
Uint8 r, g, b; Uint8 r, g, b;
constexpr Color(int red = 255, int green = 255, int blue = 255) : r(red), g(green), b(blue) {}
}; };
// Posiciones de las notificaciones // Posiciones de las notificaciones
@@ -47,13 +51,6 @@ enum class NotifyPosition
RIGHT, RIGHT,
}; };
// Estructura para saber la seccion y subseccion del programa
/*struct Section
{
section::Name name;
section::Options options;
};*/
// Estructura para las entradas de la tabla de recirds // Estructura para las entradas de la tabla de recirds
struct HiScoreEntry struct HiScoreEntry
{ {

View File

@@ -1,4 +1,5 @@
#include "writer.h" #include "writer.h"
#include "text.h" // for Text
// Constructor // Constructor
Writer::Writer(std::shared_ptr<Text> text) Writer::Writer(std::shared_ptr<Text> text)
@@ -79,7 +80,7 @@ void Writer::setKerning(int value)
} }
// Establece el valor de la variable // Establece el valor de la variable
void Writer::setCaption(std::string text) void Writer::setCaption(const std::string &text)
{ {
caption_ = text; caption_ = text;
lenght_ = text.length(); lenght_ = text.length();

View File

@@ -1,8 +1,8 @@
#pragma once #pragma once
#include <string> // for string, basic_string #include <memory> // for shared_ptr
#include <memory> #include <string> // for string
#include "text.h" class Text;
// Clase Writer. Pinta texto en pantalla letra a letra a partir de una cadena y un objeto Text // Clase Writer. Pinta texto en pantalla letra a letra a partir de una cadena y un objeto Text
class Writer class Writer
@@ -48,7 +48,7 @@ public:
void setKerning(int value); void setKerning(int value);
// Establece el valor de la variable // Establece el valor de la variable
void setCaption(std::string text); void setCaption(const std::string &text);
// Establece el valor de la variable // Establece el valor de la variable
void setSpeed(int value); void setSpeed(int value);