Compare commits
3 Commits
809c10048e
...
2024-10-14
| Author | SHA1 | Date | |
|---|---|---|---|
| 9825c7fb9b | |||
| d0a6e4c572 | |||
| 7c876e1d4d |
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#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 "utils.h" // for Color
|
#include <memory> // for unique_ptr, shared_ptr
|
||||||
#include "moving_sprite.h"
|
#include "utils.h" // for Color
|
||||||
#include "sprite.h"
|
class MovingSprite;
|
||||||
#include "texture.h"
|
class Sprite;
|
||||||
#include <memory>
|
class Texture;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#include "bullet.h"
|
#include "bullet.h"
|
||||||
#include "param.h" // for param
|
#include <memory> // for unique_ptr, make_unique, shared_ptr
|
||||||
#include "sprite.h" // for Sprite
|
#include "param.h" // for param
|
||||||
#include <memory> // for std::unique_ptr
|
#include "sprite.h" // for Sprite
|
||||||
|
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,10 +23,9 @@ 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;
|
||||||
auto kind_index = static_cast<int>(kind);
|
auto kind_index = static_cast<int>(kind);
|
||||||
sprite_->setSpriteClip((kind_index + sprite_offset) * width_, 0, sprite_->getWidth(), sprite_->getHeight());
|
sprite_->setSpriteClip((kind_index + sprite_offset) * width_, 0, sprite_->getWidth(), sprite_->getHeight());
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#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
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
#include "define_buttons.h"
|
#include "define_buttons.h"
|
||||||
#include "lang.h" // for getText
|
#include <utility> // for move
|
||||||
#include "options.h" // for options
|
#include "input.h" // for Input, InputType
|
||||||
#include "param.h" // for param
|
#include "lang.h" // for getText
|
||||||
#include "section.h" // for name, SectionName, options, SectionOptions
|
#include "options.h" // for options
|
||||||
#include "text.h" // for Text
|
#include "param.h" // for param
|
||||||
#include "utils.h" // for OptionsController, Options, Param, ParamGame
|
#include "section.h" // for Name, Options, name, options
|
||||||
|
#include "text.h" // for Text
|
||||||
|
#include "utils.h" // for OptionsController, Options, Param, ParamGame
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
DefineButtons::DefineButtons(std::unique_ptr<Text> text_)
|
DefineButtons::DefineButtons(std::unique_ptr<Text> text_)
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#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 <vector> // for vector
|
#include <string> // for string
|
||||||
#include "input.h" // for inputs_e
|
#include <vector> // for vector
|
||||||
#include "text.h"
|
class Input;
|
||||||
#include <memory>
|
class Text;
|
||||||
|
enum class InputType : int;
|
||||||
|
|
||||||
struct DefineButtonsButton
|
struct DefineButtonsButton
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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 "logo.h" // for Logo
|
#include "lang.h" // for Code, loadFromFile
|
||||||
#include "manage_hiscore_table.h" // for ManageHiScoreTable
|
#include "logo.h" // for Logo
|
||||||
#include "on_screen_help.h" // for OnScreenHelp
|
#include "manage_hiscore_table.h" // for ManageHiScoreTable
|
||||||
#include "options.h" // for options, loadOptionsFile, saveO...
|
#include "on_screen_help.h" // for OnScreenHelp
|
||||||
#include "param.h" // for param, loadParamsFromFile
|
#include "options.h" // for options, loadOptionsFile, saveO...
|
||||||
#include "screen.h" // for Screen
|
#include "param.h" // for param, loadParamsFromFile
|
||||||
#include "section.h" // for SectionName, name, options, SectionOptions
|
#include "screen.h" // for Screen
|
||||||
#include "title.h" // for Title
|
#include "section.h" // for Name, name, Options, options
|
||||||
#include "utils.h" // for MusicFile, SoundFile, opt...
|
#include "title.h" // for Title
|
||||||
#include <memory>
|
#include "utils.h" // for MusicFile, SoundFile, Options
|
||||||
|
|
||||||
#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
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#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();
|
||||||
|
|||||||
@@ -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()
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string> // for string
|
#include <memory> // for shared_ptr, unique_ptr
|
||||||
#include <vector> // for vector
|
#include <string> // for string
|
||||||
#include "animated_sprite.h"
|
#include <vector> // for vector
|
||||||
#include <memory>
|
class AnimatedSprite;
|
||||||
#include "texture.h"
|
class Texture;
|
||||||
|
|
||||||
struct ExplosionTexture
|
struct ExplosionTexture
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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_pixels.h> // for SDL_PIXELFORMAT_RGBA8888
|
#include <SDL2/SDL_keycode.h> // for SDLK_1, SDLK_2, SDLK_3, SDLK_4
|
||||||
#include <SDL2/SDL_rwops.h> // for SDL_RWFromFile, SDL_RWclose, SDL_R...
|
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888
|
||||||
#include <SDL2/SDL_timer.h> // for SDL_GetTicks
|
#include <SDL2/SDL_rwops.h> // for SDL_RWFromFile, SDL_RWclose, SDL_R...
|
||||||
#include <SDL2/SDL_video.h> // for SDL_WINDOWEVENT_FOCUS_GAINED, SDL_...
|
#include <SDL2/SDL_timer.h> // for SDL_GetTicks
|
||||||
#include <stdlib.h> // for rand
|
#include <SDL2/SDL_video.h> // for SDL_WINDOWEVENT_FOCUS_GAINED, SDL_...
|
||||||
#include <algorithm> // for min
|
#include <stdlib.h> // for rand
|
||||||
#include <fstream> // for basic_ifstream
|
#include <algorithm> // for min, remove_if
|
||||||
#include <iostream> // for char_traits, basic_istream, ifstream
|
#include <fstream> // for basic_ostream, operator<<, basic_i...
|
||||||
#include <numeric>
|
#include <iostream> // for cout
|
||||||
|
#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)
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -17,17 +17,17 @@ GameLogo::GameLogo(int x, int y)
|
|||||||
coffee_texture_(std::make_shared<Texture>(Screen::get()->getRenderer(), Asset::get()->get("title_coffee.png"))),
|
coffee_texture_(std::make_shared<Texture>(Screen::get()->getRenderer(), Asset::get()->get("title_coffee.png"))),
|
||||||
crisis_texture_(std::make_shared<Texture>(Screen::get()->getRenderer(), Asset::get()->get("title_crisis.png"))),
|
crisis_texture_(std::make_shared<Texture>(Screen::get()->getRenderer(), Asset::get()->get("title_crisis.png"))),
|
||||||
arcade_edition_texture_(std::make_shared<Texture>(Screen::get()->getRenderer(), Asset::get()->get("title_arcade_edition.png"))),
|
arcade_edition_texture_(std::make_shared<Texture>(Screen::get()->getRenderer(), Asset::get()->get("title_arcade_edition.png"))),
|
||||||
|
|
||||||
dust_left_sprite_(std::make_unique<AnimatedSprite>(dust_texture_, Asset::get()->get("title_dust.ani"))),
|
dust_left_sprite_(std::make_unique<AnimatedSprite>(dust_texture_, Asset::get()->get("title_dust.ani"))),
|
||||||
dust_right_sprite_(std::make_unique<AnimatedSprite>(dust_texture_, Asset::get()->get("title_dust.ani"))),
|
dust_right_sprite_(std::make_unique<AnimatedSprite>(dust_texture_, Asset::get()->get("title_dust.ani"))),
|
||||||
|
|
||||||
coffee_sprite_(std::make_unique<SmartSprite>(coffee_texture_)),
|
coffee_sprite_(std::make_unique<SmartSprite>(coffee_texture_)),
|
||||||
crisis_sprite_(std::make_unique<SmartSprite>(crisis_texture_)),
|
crisis_sprite_(std::make_unique<SmartSprite>(crisis_texture_)),
|
||||||
|
|
||||||
arcade_edition_sprite_(std::make_unique<Sprite>((param.game.width - arcade_edition_texture_->getWidth()) / 2, param.title.arcade_edition_position, arcade_edition_texture_->getWidth(), arcade_edition_texture_->getHeight(), arcade_edition_texture_)),
|
arcade_edition_sprite_(std::make_unique<Sprite>((param.game.width - arcade_edition_texture_->getWidth()) / 2, param.title.arcade_edition_position, arcade_edition_texture_->getWidth(), arcade_edition_texture_->getHeight(), arcade_edition_texture_)),
|
||||||
|
|
||||||
crash_sound_(JA_LoadSound(Asset::get()->get("title.wav").c_str())),
|
crash_sound_(JA_LoadSound(Asset::get()->get("title.wav").c_str())),
|
||||||
|
|
||||||
x_(x),
|
x_(x),
|
||||||
y_(y)
|
y_(y)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#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 <string> // for string
|
#include <memory> // for shared_ptr, unique_ptr
|
||||||
#include <vector> // for vector
|
#include <string> // for string
|
||||||
#include <memory>
|
#include <vector> // for vector
|
||||||
#include "utils.h" // for Circle
|
#include "animated_sprite.h" // for AnimatedSprite
|
||||||
#include "animated_sprite.h"
|
#include "utils.h" // for Circle
|
||||||
#include "texture.h"
|
class Texture;
|
||||||
|
|
||||||
// Tipos de objetos
|
// Tipos de objetos
|
||||||
constexpr int ITEM_POINTS_1_DISK = 1;
|
constexpr int ITEM_POINTS_1_DISK = 1;
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
#include "logo.h"
|
#include "logo.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_render.h> // for SDL_Renderer
|
||||||
#include <SDL2/SDL_video.h> // for SDL_WINDOWEVENT_SIZE_CHANGED
|
#include <SDL2/SDL_timer.h> // for SDL_GetTicks
|
||||||
#include <string> // for basic_string
|
#include <SDL2/SDL_video.h> // for SDL_WINDOWEVENT_SIZE_CHANGED
|
||||||
#include "asset.h" // for Asset
|
#include <utility> // for move
|
||||||
#include "global_inputs.h" // for globalInputs::check
|
#include "asset.h" // for Asset
|
||||||
#include "input.h" // for Input
|
#include "global_inputs.h" // for check
|
||||||
#include "jail_audio.h" // for JA_StopMusic
|
#include "input.h" // for Input
|
||||||
#include "param.h" // for param
|
#include "jail_audio.h" // for JA_StopMusic
|
||||||
#include "screen.h" // for Screen
|
#include "param.h" // for param
|
||||||
#include "section.h" // for name, SectionName, options, SectionOptions
|
#include "screen.h" // for Screen
|
||||||
#include "sprite.h" // for Sprite
|
#include "section.h" // for Name, name, Options, options
|
||||||
#include "texture.h" // for Texture
|
#include "sprite.h" // for Sprite
|
||||||
|
#include "texture.h" // for Texture
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Logo::Logo()
|
Logo::Logo()
|
||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -7,25 +7,22 @@ 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[])
|
||||||
{
|
{
|
||||||
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
|
const auto endType = exit == 0 ? "keyboard" : "controller";
|
||||||
delete director;
|
std::cout << "\nGame end with " << endType << std::endl;
|
||||||
|
|
||||||
const auto endType = exit == 0 ? "keyboard" : "controller";
|
return exit;
|
||||||
std::cout << "\nGame end with " << endType << std::endl;
|
|
||||||
|
|
||||||
return exit;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#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();
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
#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
|
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Notify::Notify(SDL_Renderer *renderer, std::string iconFile, std::string bitmapFile, std::string textFile, const std::string &soundFile)
|
Notify::Notify(SDL_Renderer *renderer, std::string iconFile, std::string bitmapFile, std::string textFile, const std::string &soundFile)
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#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 <vector> // for vector
|
#include <string> // for string, basic_string
|
||||||
#include <memory>
|
#include <vector> // for vector
|
||||||
#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
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
#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
|
#include "screen.h" // for Screen
|
||||||
#include "screen.h" // for Screen
|
#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, Param, ParamGame
|
||||||
#include "utils.h" // for easeInOutSine, ParamGame, Param
|
|
||||||
|
|
||||||
// [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;
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#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
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#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
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#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();
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "animated_sprite.h" // for AnimatedSprite
|
#include <memory> // for shared_ptr
|
||||||
#include "texture.h"
|
#include "animated_sprite.h" // for AnimatedSprite
|
||||||
#include <memory>
|
class Texture;
|
||||||
|
|
||||||
// Clase SmartSprite
|
// Clase SmartSprite
|
||||||
class SmartSprite : public AnimatedSprite
|
class SmartSprite : public AnimatedSprite
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
#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 <iostream> // for cout
|
#include <fstream> // for basic_ostream, basic_ifstream, basic_istream
|
||||||
#include "sprite.h" // for Sprite
|
#include <iostream> // for cout
|
||||||
#include "texture.h" // for Texture
|
#include "sprite.h" // for Sprite
|
||||||
#include "utils.h" // for Color
|
#include "texture.h" // for Texture
|
||||||
|
#include "utils.h" // for Color
|
||||||
|
|
||||||
// Llena una estructuta TextFile desde un fichero
|
// Llena una estructuta TextFile desde un fichero
|
||||||
TextFile LoadTextFile(std::string file_path)
|
TextFile LoadTextFile(std::string file_path)
|
||||||
@@ -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);
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -33,19 +33,19 @@ class Text
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
std::unique_ptr<Sprite> sprite_; // Objeto con los graficos para el texto
|
std::unique_ptr<Sprite> sprite_; // Objeto con los graficos para el texto
|
||||||
std::shared_ptr<Texture> texture_; // Textura con los bitmaps del texto
|
std::shared_ptr<Texture> texture_; // Textura con los bitmaps del texto
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int box_width_; // Anchura de la caja de cada caracter en el png
|
int box_width_; // Anchura de la caja de cada caracter en el png
|
||||||
int box_height_; // Altura de la caja de cada caracter en el png
|
int box_height_; // Altura de la caja de cada caracter en el png
|
||||||
bool fixed_width_; // Indica si el texto se ha de escribir con longitud fija en todas las letras
|
bool fixed_width_; // Indica si el texto se ha de escribir con longitud fija en todas las letras
|
||||||
TextOffset offset_[128]; // Vector con las posiciones y ancho de cada letra
|
TextOffset offset_[128]; // Vector con las posiciones y ancho de cada letra
|
||||||
|
|
||||||
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;
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
#include "tiled_bg.h"
|
#include "tiled_bg.h"
|
||||||
#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 "screen.h" // for Screen
|
#include <memory> // for unique_ptr, make_shared, make_unique
|
||||||
#include "sprite.h" // for Sprite
|
#include "screen.h" // for Screen
|
||||||
#include "texture.h" // for Texture
|
#include "sprite.h" // for Sprite
|
||||||
|
#include "texture.h" // for Texture
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Tiledbg::Tiledbg(std::string texture_path, SDL_Rect pos, int mode)
|
Tiledbg::Tiledbg(std::string texture_path, SDL_Rect pos, int mode)
|
||||||
|
|||||||
@@ -1,20 +1,24 @@
|
|||||||
#include "title.h"
|
#include "title.h"
|
||||||
#include <SDL2/SDL_keycode.h> // for SDLK_1, SDLK_2, SDLK_3
|
#include <SDL2/SDL_events.h> // for SDL_PollEvent, SDL_Event, SDL_KEYDOWN
|
||||||
#include <SDL2/SDL_render.h> // for SDL_Renderer
|
#include <SDL2/SDL_keycode.h> // for SDLK_1, SDLK_2, SDLK_3
|
||||||
#include <SDL2/SDL_timer.h> // for SDL_GetTicks
|
#include <SDL2/SDL_rect.h> // for SDL_Rect
|
||||||
#include <string> // for allocator, basic_string, char_traits
|
#include <SDL2/SDL_render.h> // for SDL_Renderer
|
||||||
#include <vector> // for vector
|
#include <SDL2/SDL_timer.h> // for SDL_GetTicks
|
||||||
#include "asset.h" // for Asset
|
#include <string> // for char_traits, operator+, to_string, bas...
|
||||||
#include "global_inputs.h" // for globalInputs::check
|
#include <utility> // for move
|
||||||
#include "input.h" // for Input, inputs_e, INPUT_DO_NOT_ALLOW_RE...
|
#include <vector> // for vector
|
||||||
#include "jail_audio.h" // for JA_GetMusicState, JA_Music_state, JA_P...
|
#include "asset.h" // for Asset
|
||||||
#include "lang.h" // for getText
|
#include "global_inputs.h" // for check
|
||||||
#include "options.h" // for options
|
#include "input.h" // for Input, InputType, INPUT_DO_NOT_ALLOW_R...
|
||||||
#include "param.h" // for param
|
#include "jail_audio.h" // for JA_GetMusicState, JA_Music_state, JA_P...
|
||||||
#include "screen.h" // for Screen
|
#include "lang.h" // for getText
|
||||||
#include "section.h" // for SectionOptions, options, SectionName, name
|
#include "options.h" // for options
|
||||||
|
#include "param.h" // for param
|
||||||
struct JA_Music_t;
|
#include "screen.h" // for Screen
|
||||||
|
#include "section.h" // for Options, options, Name, name
|
||||||
|
#include "texture.h" // for Texture
|
||||||
|
#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)
|
||||||
|
|||||||
@@ -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> // for unique_ptr, shared_ptr
|
||||||
#include <memory>
|
#include "define_buttons.h" // for DefineButtons
|
||||||
#include "define_buttons.h"
|
#include "fade.h" // for Fade
|
||||||
#include "fade.h"
|
#include "game_logo.h" // for GameLogo
|
||||||
#include "game_logo.h"
|
#include "sprite.h" // for Sprite
|
||||||
#include "text.h"
|
#include "text.h" // for Text
|
||||||
#include "tiled_bg.h"
|
#include "tiled_bg.h" // for Tiledbg
|
||||||
#include "utils.h" // for Section
|
class Input; // lines 17-17
|
||||||
#include "sprite.h"
|
class Screen; // lines 18-18
|
||||||
#include "texture.h"
|
class Texture; // lines 20-20
|
||||||
#include "section.h"
|
namespace section { enum class Name; }
|
||||||
|
struct JA_Music_t; // lines 21-21
|
||||||
class Asset;
|
|
||||||
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";
|
||||||
|
|||||||
@@ -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};
|
||||||
|
|||||||
@@ -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
|
||||||
{
|
{
|
||||||
@@ -114,7 +111,7 @@ struct OptionsAudio
|
|||||||
struct OptionsGame
|
struct OptionsGame
|
||||||
{
|
{
|
||||||
GameDifficulty difficulty; // Dificultad del juego
|
GameDifficulty difficulty; // Dificultad del juego
|
||||||
lang::Code language; // Idioma usado en el juego
|
lang::Code language; // Idioma usado en el juego
|
||||||
bool autofire; // Indica si el jugador ha de pulsar repetidamente para disparar o basta con mantener pulsado
|
bool autofire; // Indica si el jugador ha de pulsar repetidamente para disparar o basta con mantener pulsado
|
||||||
std::vector<HiScoreEntry> hi_score_table; // Tabla con las mejores puntuaciones
|
std::vector<HiScoreEntry> hi_score_table; // Tabla con las mejores puntuaciones
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user