Pasaeta de include-what-you-use

Acabada de perfilar la classe PathSprite
Menjeades declaracions de utils.h als fitxers que toca
This commit is contained in:
2024-10-28 20:45:24 +01:00
parent 0fe371653a
commit 787cb6366f
55 changed files with 768 additions and 805 deletions

View File

@@ -0,0 +1,8 @@
#!/bin/bash
SOURCEPATH=../source/
for i in "$SOURCEPATH"/*.cpp
do
include-what-you-use -D DEBUG -D VERBOSE -std=c++20 -Wall "$i"
done

View File

@@ -1,11 +1,11 @@
#include "animated_sprite.h" #include "animated_sprite.h"
#include <algorithm> // para copy #include <stddef.h> // Para size_t
#include <fstream> // para basic_ostream, operator<<, basic_istream, basic... #include <fstream> // Para basic_ostream, basic_istream, operator<<, basic...
#include <iostream> // para cout #include <iostream> // Para cout, cerr
#include <iterator> // para back_insert_iterator, back_inserter #include <sstream> // Para basic_stringstream
#include <sstream> // para basic_stringstream #include <stdexcept> // Para runtime_error
#include "texture.h" // para Texture #include "texture.h" // Para Texture
#include "utils.h" #include "utils.h" // Para printWithDots
// Carga las animaciones en un vector(Animations) desde un fichero // Carga las animaciones en un vector(Animations) desde un fichero
AnimationsFileBuffer loadAnimationsFromFile(const std::string &file_path) AnimationsFileBuffer loadAnimationsFromFile(const std::string &file_path)

View File

@@ -1,12 +1,11 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // para SDL_Rect #include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <SDL2/SDL_stdinc.h> // para Uint8 #include <memory> // Para shared_ptr
#include <memory> // para shared_ptr #include <string> // Para string
#include <string> // para string #include <vector> // Para vector
#include <vector> // para vector #include "moving_sprite.h" // Para MovingSprite
#include "moving_sprite.h" // para MovingSprite class Texture; // lines 9-9
class Texture;
struct Animation struct Animation
{ {

View File

@@ -1,12 +1,9 @@
#include "asset.h" #include "asset.h"
#include "utils.h" #include <algorithm> // Para find_if, max
#include <SDL2/SDL_rwops.h> // para SDL_RWFromFile, SDL_RWclose, SDL_RWops #include <fstream> // Para basic_ostream, operator<<, basic_ifstream, endl
#include <SDL2/SDL_stdinc.h> // para SDL_max #include <iostream> // Para cout
#include <stddef.h> // para size_t #include <string> // Para allocator, char_traits, string, operator+, oper...
#include <iostream> // para basic_ostream, operator<<, cout, endl #include "utils.h" // Para getFileName, printWithDots
#include <fstream>
#include <string>
#include <algorithm> // Para std::find_if
// [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
Asset *Asset::asset_ = nullptr; Asset *Asset::asset_ = nullptr;

View File

@@ -1,14 +1,13 @@
#include "background.h" #include "background.h"
#include <SDL2/SDL_blendmode.h> // para SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_pixels.h> // para SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <algorithm> // para clamp, max #include <algorithm> // Para clamp, max
#include "asset.h" // para Asset #include "moving_sprite.h" // Para MovingSprite
#include "moving_sprite.h" // para MovingSprite #include "param.h" // Para Param, ParamBackground, param
#include "param.h" // para param #include "resource.h" // Para Resource
#include "resource.h" // para Resource #include "screen.h" // Para Screen
#include "screen.h" #include "sprite.h" // Para Sprite
#include "sprite.h" // para Sprite #include "texture.h" // Para Texture
#include "texture.h" // para Texture
// Constructor // Constructor
Background::Background() Background::Background()

View File

@@ -1,11 +1,10 @@
#include "balloon.h" #include "balloon.h"
#include <cmath> // para abs #include <algorithm> // Para clamp
#include <algorithm> // para clamp #include <cmath> // Para fabs
#include "animated_sprite.h" // para SpriteAnimated #include "animated_sprite.h" // Para AnimatedSprite
#include "moving_sprite.h" // para MovingSprite #include "param.h" // Para Param, param, ParamBalloon, ParamGame
#include "param.h" // para param #include "sprite.h" // Para Sprite
#include "sprite.h" // para Sprite #include "texture.h" // Para Texture
#include "texture.h" // para Texture
// Constructor // Constructor
Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel_x, float speed, Uint16 creation_timer, std::shared_ptr<Texture> texture, const std::vector<std::string> &animation) Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel_x, float speed, Uint16 creation_timer, std::shared_ptr<Texture> texture, const std::vector<std::string> &animation)

View File

@@ -1,13 +1,12 @@
#pragma once #pragma once
#include <SDL2/SDL_stdinc.h> // para Uint8, Uint16, Uint32 #include <SDL2/SDL_stdinc.h> // Para Uint8, Uint16, Uint32
#include <memory> // para shared_ptr, unique_ptr #include <memory> // Para shared_ptr, unique_ptr
#include <string> // para string #include <string> // Para string
#include <vector> // para vector #include <vector> // Para vector
#include "animated_sprite.h" // para SpriteAnimated #include "animated_sprite.h" // Para AnimatedSprite
#include "utils.h" // para Circle #include "utils.h" // Para Circle
#include "param.h" class Texture; // lines 10-10
class Texture;
// 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

@@ -1,8 +1,9 @@
#include "bullet.h" #include "bullet.h"
#include <memory> // para unique_ptr, make_unique, shared_ptr #include <SDL2/SDL_rect.h> // Para SDL_Rect
#include "param.h" // para param #include <memory> // Para unique_ptr, make_unique, shared_ptr
#include "sprite.h" // para Sprite #include "param.h" // Para Param, ParamGame, param
class Texture; #include "sprite.h" // Para Sprite
class Texture; // lines 5-5
// Constructor // Constructor
Bullet::Bullet(int x, int y, BulletType bullet_type, bool powered_up, int owner, std::shared_ptr<Texture> texture) Bullet::Bullet(int x, int y, BulletType bullet_type, bool powered_up, int owner, std::shared_ptr<Texture> texture)

View File

@@ -1,11 +1,10 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // para SDL_Rect #include <SDL2/SDL_stdinc.h> // Para Uint8
#include <SDL2/SDL_stdinc.h> // para Uint8 #include <memory> // Para shared_ptr, unique_ptr
#include <memory> // para shared_ptr, unique_ptr #include "sprite.h" // Para Sprite
#include "sprite.h" // para Sprite #include "utils.h" // Para Circle
#include "utils.h" // para Circle class Texture; // lines 8-8
class Texture;
// Tipos de balas // Tipos de balas
enum class BulletType : Uint8 enum class BulletType : Uint8
@@ -36,9 +35,9 @@ private:
std::unique_ptr<Sprite> sprite_; // Sprite con los gráficos y métodos de pintado std::unique_ptr<Sprite> sprite_; // Sprite con los gráficos y métodos de pintado
int pos_x_; // Posición en el eje X int pos_x_; // Posición en el eje X
int pos_y_; // Posición en el eje Y int pos_y_; // Posición en el eje Y
int vel_x_; // Velocidad en el eje X int vel_x_; // Velocidad en el eje X
BulletType bullet_type_; // Tipo de objeto BulletType bullet_type_; // Tipo de objeto
int owner_; // Identificador del dueño del objeto int owner_; // Identificador del dueño del objeto

View File

@@ -1,12 +1,11 @@
#include "define_buttons.h" #include "define_buttons.h"
#include <utility> // para move #include <utility> // Para move
#include "input.h" // para Input, InputType #include "input.h" // Para Input, InputType
#include "lang.h" // para getText #include "lang.h" // Para getText
#include "options.h" // para options #include "options.h" // Para OptionsController, Options, options
#include "param.h" // para param #include "param.h" // Para Param, param, ParamGame, ParamTitle
#include "section.h" // para Name, Options, name, options #include "section.h" // Para Name, Options, name, options
#include "text.h" // para Text #include "text.h" // Para Text
#include "utils.h" // para OptionsController, Options, Param, ParamGame
// Constructor // Constructor
DefineButtons::DefineButtons(std::unique_ptr<Text> text_) DefineButtons::DefineButtons(std::unique_ptr<Text> text_)

View File

@@ -1,44 +1,46 @@
#include "director.h" #include "director.h"
#include <SDL2/SDL.h> // para SDL_Init, SDL_Quit, SDL_INIT_EV... #include <SDL2/SDL.h> // Para SDL_Init, SDL_Quit, SDL_INIT_EV...
#include <SDL2/SDL_audio.h> // para AUDIO_S16 #include <SDL2/SDL_audio.h> // Para AUDIO_S16
#include <SDL2/SDL_blendmode.h> // para SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_error.h> // para SDL_GetError #include <SDL2/SDL_error.h> // Para SDL_GetError
#include <SDL2/SDL_gamecontroller.h> // para SDL_CONTROLLER_BUTTON_B, SDL_CO... #include <SDL2/SDL_gamecontroller.h> // Para SDL_CONTROLLER_BUTTON_B, SDL_CO...
#include <SDL2/SDL_hints.h> // para SDL_SetHint, SDL_HINT_RENDER_DR... #include <SDL2/SDL_hints.h> // Para SDL_SetHint, SDL_HINT_RENDER_DR...
#include <SDL2/SDL_scancode.h> // para SDL_SCANCODE_0, SDL_SCANCODE_DOWN #include <SDL2/SDL_scancode.h> // Para SDL_SCANCODE_0, SDL_SCANCODE_DOWN
#include <SDL2/SDL_stdinc.h> // para SDL_bool, Uint32 #include <SDL2/SDL_stdinc.h> // Para SDL_bool, Uint32
#include <SDL2/SDL_timer.h> // para SDL_GetTicks #include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <cstdlib> // para system #include <errno.h> // Para errno, EEXIST, EACCES, ENAMETOO...
#include <errno.h> // para errno, EEXIST, EACCES, ENAMETOO... #include <stdio.h> // Para printf, perror
#include <stdio.h> // para printf, perror #include <string.h> // Para strcmp
#include <string.h> // para strcmp #include <sys/stat.h> // Para mkdir, stat, S_IRWXU
#include <sys/stat.h> // para mkdir, stat, S_IRWXU #include <unistd.h> // Para getuid
#include <unistd.h> // para getuid #include <cstdlib> // Para exit, EXIT_FAILURE, rand, srand
#include <cstdlib> // para exit, EXIT_FAILURE, rand, srand #include <iostream> // Para basic_ostream, operator<<, cout
#include <iostream> // para basic_ostream, operator<<, cout #include <memory> // Para make_unique, unique_ptr, make_s...
#include <memory> // para make_unique, unique_ptr #include <stdexcept> // Para runtime_error
#include <string> // para operator+, allocator, char_traits #include <string> // Para operator+, allocator, char_traits
#include "asset.h" // para Asset, AssetType #include <vector> // Para vector
#include "dbgtxt.h" // para dbg_init #include "asset.h" // Para Asset, AssetType
#include "game.h" // para Game, GAME_MODE_DEMO_OFF, GAME_... #include "dbgtxt.h" // Para dbg_init
#include "global_inputs.h" // para init #include "game.h" // Para Game, GAME_MODE_DEMO_OFF, GAME_...
#include "hiscore_table.h" // para HiScoreTable #include "global_inputs.h" // Para init
#include "input.h" // para Input, InputType #include "hiscore_table.h" // Para HiScoreTable
#include "instructions.h" // para Instructions #include "input.h" // Para Input, InputType
#include "intro.h" // para Intro #include "instructions.h" // Para Instructions
#include "jail_audio.h" // para JA_LoadMusic, JA_LoadSound, JA_... #include "intro.h" // Para Intro
#include "lang.h" // para Code, loadFromFile #include "jail_audio.h" // Para JA_EnableMusic, JA_EnableSound
#include "logo.h" // para Logo #include "lang.h" // Para Code, loadFromFile
#include "manage_hiscore_table.h" // para ManageHiScoreTable #include "logo.h" // Para Logo
#include "notifier.h" // para Notifier #include "manage_hiscore_table.h" // Para ManageHiScoreTable
#include "on_screen_help.h" // para OnScreenHelp #include "notifier.h" // Para Notifier
#include "options.h" // para options, loadOptionsFile, saveO... #include "on_screen_help.h" // Para OnScreenHelp
#include "param.h" // para param, loadParamsFromFile #include "options.h" // Para Options, options, OptionsContro...
#include "resource.h" //for Resource #include "param.h" // Para Param, ParamGame, param, loadPa...
#include "screen.h" // para Screen #include "resource.h" // Para Resource
#include "section.h" // para Name, name, Options, options #include "screen.h" // Para Screen
#include "title.h" // para Title #include "section.h" // Para Name, Options, name, options
#include "utils.h" // para MusicFile, SoundFile, Options #include "text.h" // Para Text
#include "title.h" // Para Title
#include "utils.h" // Para Overrides, overrides
#ifndef _WIN32 #ifndef _WIN32
#include <pwd.h> // para getpwuid, passwd #include <pwd.h> // para getpwuid, passwd

View File

@@ -1,15 +1,12 @@
#pragma once #pragma once
#include <SDL2/SDL_render.h> // para SDL_Renderer #include <SDL2/SDL_render.h> // Para SDL_Renderer
#include <SDL2/SDL_video.h> // para SDL_Window #include <SDL2/SDL_video.h> // Para SDL_Window
#include <string> // para string #include <string> // Para string
#include <vector> // para vector
namespace lang namespace lang
{ {
enum class Code : int; enum class Code : int;
} } // lines 9-9
struct ResourceMusic;
struct ResourceSound;
// Textos // Textos
constexpr char WINDOW_CAPTION[] = "Coffee Crisis Arcade Edition"; constexpr char WINDOW_CAPTION[] = "Coffee Crisis Arcade Edition";
@@ -18,8 +15,8 @@ class Director
{ {
private: private:
// Objetos y punteros // Objetos y punteros
SDL_Window *window_; // La ventana donde dibujamos SDL_Window *window_; // La ventana donde dibujamos
SDL_Renderer *renderer_; // El renderizador de la ventana SDL_Renderer *renderer_; // El renderizador de la ventana
#ifndef VERBOSE #ifndef VERBOSE
std::streambuf *orig_buf; // Puntero al buffer de flujo original para restaurar std::cout std::streambuf *orig_buf; // Puntero al buffer de flujo original para restaurar std::cout
#endif #endif

View File

@@ -1,5 +1,6 @@
#include "enter_name.h" #include "enter_name.h"
#include <algorithm> // para max, min #include <stddef.h> // Para size_t
#include <algorithm> // Para max, min
// Constructor // Constructor
EnterName::EnterName() EnterName::EnterName()

View File

@@ -1,20 +1,6 @@
#include "explosions.h" #include "explosions.h"
#include <utility> // para move #include "animated_sprite.h" // Para AnimatedSprite
#include "animated_sprite.h" // para SpriteAnimated class Texture; // lines 4-4
class Texture; // lines 3-3
// Constructor
Explosions::Explosions()
{
textures_.clear();
explosions_.clear();
}
// Destructor
Explosions::~Explosions()
{
explosions_.clear();
}
// Actualiza la lógica de la clase // Actualiza la lógica de la clase
void Explosions::update() void Explosions::update()

View File

@@ -1,10 +1,10 @@
#pragma once #pragma once
#include <memory> // para shared_ptr, unique_ptr #include <memory> // Para unique_ptr, shared_ptr
#include <string> // para string #include <string> // Para string
#include <vector> // para vector #include <vector> // Para vector
class AnimatedSprite; #include "animated_sprite.h" // Para AnimatedSprite
class Texture; class Texture; // lines 7-7
struct ExplosionTexture struct ExplosionTexture
{ {
@@ -33,10 +33,10 @@ private:
public: public:
// Constructor // Constructor
Explosions(); Explosions() = default;
// Destructor // Destructor
~Explosions(); ~Explosions() = default;
// Actualiza la lógica de la clase // Actualiza la lógica de la clase
void update(); void update();

View File

@@ -1,11 +1,10 @@
#include "fade.h" #include "fade.h"
#include <SDL2/SDL_blendmode.h> // para SDL_BLENDMODE_BLEND, SDL_BLENDMODE_NONE #include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND, SDL_BLENDMODE_NONE
#include <SDL2/SDL_pixels.h> // para SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <stdlib.h> // para rand #include <stdlib.h> // Para rand
#include <algorithm> // para min, max #include <algorithm> // Para min, max
#include "param.h" // para param #include "param.h" // Para Param, param, ParamGame, ParamFade
#include "screen.h" #include "screen.h" // Para Screen
#include "utils.h" // para Param, ParamGame, ParamFade
// Constructor // Constructor
Fade::Fade() Fade::Fade()

View File

@@ -1,44 +1,39 @@
#include "game.h" #include "game.h"
#include <SDL2/SDL_blendmode.h> // para SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_events.h> // para SDL_PollEvent, SDL_Event, SDL_KEYDOWN #include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_KEYDOWN
#include <SDL2/SDL_keycode.h> // para SDLK_1, SDLK_2, SDLK_3, SDLK_4 #include <SDL2/SDL_keycode.h> // Para SDLK_1, SDLK_2, SDLK_3, SDLK_4
#include <SDL2/SDL_pixels.h> // para SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_rwops.h> // para SDL_RWFromFile, SDL_RWclose, SDL_R... #include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <SDL2/SDL_timer.h> // para SDL_GetTicks #include <SDL2/SDL_video.h> // Para SDL_WINDOWEVENT_FOCUS_GAINED, SDL_...
#include <SDL2/SDL_video.h> // para SDL_WINDOWEVENT_FOCUS_GAINED, SDL_... #include <stdlib.h> // Para rand, size_t
#include <stdlib.h> // para rand #include <algorithm> // Para find_if, clamp, min, remove_if
#include <algorithm> // para min, remove_if #include <iterator> // Para distance, size
#include <fstream> // para basic_ostream, operator<<, basic_i... #include <numeric> // Para accumulate
#include <iostream> // para cout #include "asset.h" // Para Asset
#include <numeric> // para accumulate #include "background.h" // Para Background
#include <utility> // para move #include "balloon.h" // Para Balloon, BALLOON_SCORE, BALLOON_VE...
#include "asset.h" // para Asset #include "balloon_formations.h" // Para BalloonFormations, BalloonFormatio...
#include "background.h" // para Background #include "bullet.h" // Para Bullet, BulletType, BulletMoveStatus
#include "balloon.h" // para Balloon, BALLOON_SCORE_1, BALLOON_... #include "explosions.h" // Para Explosions
#include "balloon_formations.h" // para Stage, BalloonFormationParams, Bal... #include "fade.h" // Para Fade, FadeType
#include "bullet.h" // para Bullet, BulletType, BulletMoveStatus #include "global_inputs.h" // Para check
#include "explosions.h" // para Explosions #include "input.h" // Para InputType, Input, INPUT_DO_NOT_ALL...
#include "fade.h" // para Fade, FadeType #include "item.h" // Para Item, ItemType
#include "global_inputs.h" // para check #include "jail_audio.h" // Para JA_PlaySound, JA_GetMusicState
#include "input.h" // para InputType, Input, INPUT_DO_NOT_ALL... #include "lang.h" // Para getText
#include "item.h" // para Item, ItemType::COFFEE_MACHINE, ItemType::CLOCK #include "manage_hiscore_table.h" // Para ManageHiScoreTable
#include "jail_audio.h" // para JA_PlaySound #include "notifier.h" // Para Notifier
#include "lang.h" // para getText #include "param.h" // Para Param, param, ParamGame, ParamFade
#include "manage_hiscore_table.h" // para ManageHiScoreTable #include "path_sprite.h" // Para PathSprite, PathType
#include "notifier.h" // para Notifier #include "player.h" // Para Player, PlayerStatus
#include "param.h" // para param #include "resource.h" // Para Resource
#include "path_sprite.h" // para PathSprite #include "scoreboard.h" // Para Scoreboard, ScoreboardMode, SCOREB...
#include "player.h" // para Player, PlayerStatus #include "screen.h" // Para Screen
#include "resource.h" // para Resource #include "section.h" // Para Name, name, Options, options
#include "scoreboard.h" // para Scoreboard, ScoreboardMode, SCOREB... #include "smart_sprite.h" // Para SmartSprite
#include "screen.h" // para Screen #include "text.h" // Para Text, TEXT_CENTER
#include "section.h" // para Name, name, Options, options #include "texture.h" // Para Texture
#include "smart_sprite.h" // para SpriteSmart struct JA_Sound_t; // lines 40-40
#include "text.h" // para Text, TEXT_CENTER
#include "texture.h" // para Texture
struct JA_Music_t; // lines 35-35
struct JA_Sound_t; // lines 36-36
#include "dbgtxt.h"
// Constructor // Constructor
Game::Game(int player_id, int current_stage, bool demo) Game::Game(int player_id, int current_stage, bool demo)
@@ -1579,8 +1574,8 @@ void Game::checkEvents()
{ {
const auto x = players_.at(0)->getPosX(); const auto x = players_.at(0)->getPosX();
createPathSprite(game_text_textures_.at(3)); createPathSprite(game_text_textures_.at(3));
path_sprites_.back()->addVerticalPath({x,220}, {x,170}, 100, 5); path_sprites_.back()->addPath(220, 160, PathType::VERTICAL, x, 100, easeOutQuint, 0);
path_sprites_.back()->addVerticalPath({x,170}, {x,-20}, 120, 5); path_sprites_.back()->addPath(160, -21, PathType::VERTICAL, x, 80, easeInQuint, 0);
break; break;
} }
default: default:

View File

@@ -1,32 +1,31 @@
#pragma once #pragma once
#include <SDL2/SDL_render.h> // para SDL_Renderer, SDL_Texture #include <SDL2/SDL_render.h> // Para SDL_Renderer, SDL_Texture
#include <SDL2/SDL_stdinc.h> // para Uint32 #include <SDL2/SDL_stdinc.h> // Para Uint32, Uint8
#include <memory> // para shared_ptr, unique_ptr #include <memory> // Para shared_ptr, unique_ptr
#include <string> // para string #include <string> // Para string
#include <vector> // para vector #include <vector> // Para vector
#include "balloon.h" // para Balloon #include "balloon.h" // Para Balloon
#include "player.h" // para Player #include "manage_hiscore_table.h" // Para HiScoreEntry
#include "utils.h" // para DemoKeys, Color, HiScoreEntry #include "options.h" // Para Options, OptionsGame, options
#include "options.h" // para options #include "player.h" // Para Player
class Asset; #include "utils.h" // Para Demo
class Background; class Asset; // lines 12-12
class BalloonFormations; class Background; // lines 13-13
class Bullet; class BalloonFormations; // lines 14-14
class Explosions; class Bullet; // lines 15-15
class Fade; class Explosions; // lines 16-16
class Input; class Fade; // lines 17-17
class Item; class Input; // lines 18-18
class PathSprite; class Item; // lines 19-19
class Scoreboard; class PathSprite; // lines 20-20
class Screen; class Scoreboard; // lines 21-21
class SmartSprite; class Screen; // lines 22-22
class Text; class SmartSprite; // lines 23-23
class Texture; class Text; // lines 24-24
enum class BulletType : Uint8; // lines 26-26 class Texture; // lines 25-25
struct JA_Music_t; // lines 27-27 enum class BulletType : Uint8; // lines 26-26
struct JA_Sound_t; // lines 28-28 enum class ItemType; // lines 27-27
enum class ItemType;
// Modo demo // Modo demo
constexpr bool GAME_MODE_DEMO_OFF = false; constexpr bool GAME_MODE_DEMO_OFF = false;

View File

@@ -1,16 +1,13 @@
#include "game_logo.h" #include "game_logo.h"
#include <SDL2/SDL_render.h> // para SDL_FLIP_HORIZONTAL #include <SDL2/SDL_render.h> // Para SDL_FLIP_HORIZONTAL
#include <algorithm> // para max #include <algorithm> // Para max
#include "animated_sprite.h" // para SpriteAnimated #include "animated_sprite.h" // Para AnimatedSprite
#include "asset.h" // para Asset #include "jail_audio.h" // Para JA_PlaySound
#include "jail_audio.h" // JA_PlaySound #include "param.h" // Para Param, param, ParamGame, ParamTitle
#include "param.h" // para param #include "resource.h" // Para Resource
#include "resource.h" // para Resource #include "smart_sprite.h" // Para SmartSprite
#include "screen.h" // para Screen #include "sprite.h" // Para Sprite
#include "smart_sprite.h" // para SpriteSmart #include "texture.h" // Para Texture
#include "sprite.h" // para Sprite
#include "texture.h" // para Texture
#include "utils.h" // para Param, ParamGame, ParamTitle
// Constructor // Constructor
GameLogo::GameLogo(int x, int y) GameLogo::GameLogo(int x, int y)

View File

@@ -1,11 +1,10 @@
#pragma once #pragma once
#include <memory> // para unique_ptr, shared_ptr #include <memory> // Para unique_ptr, shared_ptr
#include "animated_sprite.h" #include "animated_sprite.h" // Para AnimatedSprite
#include "smart_sprite.h" #include "smart_sprite.h" // Para SmartSprite
class Sprite; #include "sprite.h" // Para Sprite
class Texture; class Texture; // lines 7-7
struct JA_Sound_t; // lines 10-10
// Clase GameLogo // Clase GameLogo
class GameLogo class GameLogo

View File

@@ -1,14 +1,13 @@
#include "global_inputs.h" #include "global_inputs.h"
#include <string> // para basic_string, operator+ #include <string> // Para operator+, string
#include "input.h" // para Input, inputs_e, INPUT_DO_NOT_ALLOW_REPEAT #include "input.h" // Para Input, InputType, INPUT_DO_NOT_ALLOW_REPEAT
#include "jail_audio.h" // para JA_EnableMusic, JA_EnableSound #include "jail_audio.h" // Para JA_EnableMusic, JA_EnableSound
#include "lang.h" // para getText #include "lang.h" // Para getText
#include "notifier.h" // para Notifier #include "notifier.h" // Para Notifier
#include "options.h" // para options #include "on_screen_help.h" // Para OnScreenHelp
#include "on_screen_help.h" #include "options.h" // Para Options, OptionsAudio, options, OptionsM...
#include "screen.h" // para Screen #include "section.h" // Para Name, Options, name, options
#include "section.h" // para SectionOptions, name, SectionName, options #include "utils.h" // Para boolToOnOff, stringInVector
#include "utils.h" // para OptionsAudio, Options, OptionsMusic, boolToOnOff
namespace globalInputs namespace globalInputs
{ {

View File

@@ -1,25 +1,25 @@
#include "hiscore_table.h" #include "hiscore_table.h"
#include <SDL2/SDL_blendmode.h> // para SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_events.h> // para SDL_PollEvent, SDL_Event, SDL_QUIT #include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_QUIT
#include <SDL2/SDL_pixels.h> // para SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_timer.h> // para SDL_GetTicks #include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <SDL2/SDL_video.h> // para SDL_WINDOWEVENT_SIZE_CHANGED #include <SDL2/SDL_video.h> // Para SDL_WINDOWEVENT_SIZE_CHANGED
#include <algorithm> // para max #include <algorithm> // Para max
#include <vector> // para vector #include <vector> // Para vector
#include "asset.h" // para Asset #include "background.h" // Para Background
#include "background.h" // para Background #include "fade.h" // Para Fade, FadeMode, FadeType
#include "fade.h" // para Fade, FadeMode, FadeType #include "global_inputs.h" // Para check
#include "global_inputs.h" // para check #include "input.h" // Para Input
#include "input.h" // para Input #include "jail_audio.h" // Para JA_GetMusicState, JA_Music_state
#include "jail_audio.h" // para JA_GetMusicState, JA_Music_state #include "lang.h" // Para getText
#include "lang.h" // para getText #include "manage_hiscore_table.h" // Para HiScoreEntry
#include "options.h" // para options #include "options.h" // Para Options, OptionsGame, options
#include "param.h" // para param #include "param.h" // Para Param, param, ParamGame, ParamFade
#include "resource.h" // para Resource #include "resource.h" // Para Resource
#include "screen.h" // para Screen #include "screen.h" // Para Screen
#include "section.h" // para Name, name, Options, options #include "section.h" // Para Name, name, Options, options
#include "text.h" // para Text, TEXT_CENTER, TEXT_SHADOW, TEXT... #include "text.h" // Para Text, TEXT_CENTER, TEXT_SHADOW
#include "utils.h" // para Param, ParamGame, Color, HiScoreEntry #include "utils.h" // Para Color, Zone, fade_color, orange_color
// Constructor // Constructor
HiScoreTable::HiScoreTable() HiScoreTable::HiScoreTable()

View File

@@ -1,27 +1,25 @@
#include "instructions.h" #include "instructions.h"
#include <SDL2/SDL_blendmode.h> // para SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_events.h> // para SDL_PollEvent, SDL_Event, SDL_QUIT #include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_QUIT
#include <SDL2/SDL_pixels.h> // para SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_timer.h> // para SDL_GetTicks #include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <SDL2/SDL_video.h> // para SDL_WINDOWEVENT_SIZE_CHANGED #include <SDL2/SDL_video.h> // Para SDL_WINDOWEVENT_SIZE_CHANGED
#include <algorithm> // para max #include <algorithm> // Para max
#include <utility> // para move #include <utility> // Para move
#include "asset.h" // para Asset #include "fade.h" // Para Fade, FadeMode, FadeType
#include "fade.h" // para Fade, FadeMode, FadeType #include "global_inputs.h" // Para check
#include "global_inputs.h" // para check #include "input.h" // Para Input
#include "input.h" // para Input #include "jail_audio.h" // Para JA_GetMusicState, JA_Music_state
#include "jail_audio.h" // para JA_GetMusicState, JA_Music_state #include "lang.h" // Para getText
#include "lang.h" // para getText #include "param.h" // Para Param, param, ParamGame, ParamFade
#include "param.h" // para param #include "resource.h" // Para Resource
#include "resource.h" // para Resource #include "screen.h" // Para Screen
#include "screen.h" // para Screen #include "section.h" // Para Name, name, Options, options
#include "section.h" // para Name, name, Options, options #include "sprite.h" // Para Sprite
#include "sprite.h" // para Sprite #include "text.h" // Para Text, TEXT_CENTER, TEXT_COLOR, TEXT_...
#include "text.h" // para Text, TEXT_CENTER, TEXT_COLOR, TEXT_... #include "texture.h" // Para Texture
#include "texture.h" // para Texture #include "tiled_bg.h" // Para TiledBG, TiledBGMode
#include "tiled_bg.h" // para TiledBG, TILED_MODE_STATIC #include "utils.h" // Para Color, shdw_txt_color, Zone, no_color
#include "utils.h" // para Param, ParamGame, Color, shdw_txt_color
struct JA_Music_t; // lines 22-22
// Constructor // Constructor
Instructions::Instructions() Instructions::Instructions()

View File

@@ -1,16 +1,15 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // para SDL_Point, SDL_Rect #include <SDL2/SDL_rect.h> // Para SDL_Point, SDL_Rect
#include <SDL2/SDL_render.h> // para SDL_Texture, SDL_Renderer #include <SDL2/SDL_render.h> // Para SDL_Texture, SDL_Renderer
#include <SDL2/SDL_stdinc.h> // para Uint32 #include <SDL2/SDL_stdinc.h> // Para Uint32
#include <memory> // para unique_ptr, shared_ptr #include <memory> // Para unique_ptr, shared_ptr
#include <vector> // para vector #include <vector> // Para vector
class Fade; class Fade; // lines 8-8
class Sprite; class Sprite; // lines 9-9
class Text; class Text; // lines 10-10
class Texture; class Texture; // lines 11-11
class TiledBG; class TiledBG; // lines 12-12
struct JA_Music_t; // lines 14-14
/* /*
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,23 +1,21 @@
#include "intro.h" #include "intro.h"
#include <SDL2/SDL_events.h> // para SDL_PollEvent, SDL_Event, SDL_QUIT, SDL... #include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_QUIT, SDL...
#include <SDL2/SDL_timer.h> // para SDL_GetTicks #include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <SDL2/SDL_video.h> // para SDL_WINDOWEVENT_SIZE_CHANGED #include <SDL2/SDL_video.h> // Para SDL_WINDOWEVENT_SIZE_CHANGED
#include <utility> // para move #include <utility> // Para move
#include "asset.h" // para Asset #include "global_inputs.h" // Para check
#include "global_inputs.h" // para check #include "input.h" // Para Input
#include "input.h" // para Input #include "jail_audio.h" // Para JA_StopMusic, JA_PlayMusic
#include "jail_audio.h" // para JA_StopMusic, JA_PlayMusic #include "lang.h" // Para getText
#include "lang.h" // para getText #include "param.h" // Para Param, ParamGame, param
#include "param.h" // para param #include "resource.h" // Para Resource
#include "resource.h" // para Resource #include "screen.h" // Para Screen
#include "screen.h" // para Screen #include "section.h" // Para Name, name, Options, options
#include "section.h" // para Name, name, Options, options #include "smart_sprite.h" // Para SmartSprite
#include "smart_sprite.h" // para SpriteSmart #include "text.h" // Para Text
#include "text.h" // para Text #include "texture.h" // Para Texture
#include "texture.h" // para Texture #include "utils.h" // Para Zone, BLOCK, Color, bg_color
#include "utils.h" // para Param, ParamGame, Zone, BLOCK, Color #include "writer.h" // Para Writer
#include "writer.h" // para Writer
struct JA_Music_t; // lines 19-19
// Constructor // Constructor
Intro::Intro() Intro::Intro()

View File

@@ -1,13 +1,12 @@
#pragma once #pragma once
#include <SDL2/SDL_stdinc.h> // para Uint32, Uint8 #include <SDL2/SDL_stdinc.h> // Para Uint32
#include <memory> // para unique_ptr, shared_ptr #include <memory> // Para unique_ptr, shared_ptr
#include <vector> // para vector #include <vector> // Para vector
#include "smart_sprite.h" // para SpriteSmart #include "smart_sprite.h" // Para SmartSprite
#include "writer.h" // para Writer #include "writer.h" // Para Writer
class Text; class Text; // lines 8-8
class Texture; class Texture; // lines 9-9
struct JA_Music_t; // lines 11-11
/* /*
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

@@ -1,19 +1,17 @@
#include "logo.h" #include "logo.h"
#include <SDL2/SDL_events.h> // para SDL_PollEvent, SDL_Event, SDL_QUIT, SDL... #include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_QUIT, SDL...
#include <SDL2/SDL_render.h> // para SDL_Renderer #include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <SDL2/SDL_timer.h> // para SDL_GetTicks #include <SDL2/SDL_video.h> // Para SDL_WINDOWEVENT_SIZE_CHANGED
#include <SDL2/SDL_video.h> // para SDL_WINDOWEVENT_SIZE_CHANGED #include <utility> // Para move
#include <utility> // para move #include "global_inputs.h" // Para check
#include "asset.h" // para Asset #include "input.h" // Para Input
#include "global_inputs.h" // para check #include "jail_audio.h" // Para JA_StopMusic
#include "input.h" // para Input #include "param.h" // Para Param, ParamGame, param
#include "jail_audio.h" // para JA_StopMusic #include "resource.h" // Para Resource
#include "param.h" // para param #include "screen.h" // Para Screen
#include "resource.h" // para Resource #include "section.h" // Para Name, name, Options, options
#include "screen.h" // para Screen #include "sprite.h" // Para Sprite
#include "section.h" // para Name, name, Options, options #include "texture.h" // Para Texture
#include "sprite.h" // para Sprite
#include "texture.h" // para Texture
// Constructor // Constructor
Logo::Logo() Logo::Logo()

View File

@@ -7,9 +7,8 @@ Actualizando a la versión "Arcade Edition" en 08/05/2024
*/ */
#include <iostream> // para char_traits, basic_ostream, operator<<, cout #include <memory> // Para make_unique, unique_ptr
#include <memory> // para make_unique, unique_ptr #include "director.h" // Para Director
#include "director.h" // para Director
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {

View File

@@ -1,10 +1,9 @@
#include "manage_hiscore_table.h" #include "manage_hiscore_table.h"
#include <SDL2/SDL_error.h> // para SDL_GetError #include <SDL2/SDL_error.h> // Para SDL_GetError
#include <SDL2/SDL_rwops.h> // para SDL_RWread, SDL_RWwrite, SDL_RWFromFile #include <SDL2/SDL_rwops.h> // Para SDL_RWread, SDL_RWwrite, SDL_RWFromFile
#include <stdlib.h> // para free, malloc #include <algorithm> // Para sort
#include <algorithm> // para sort #include <iostream> // Para basic_ostream, operator<<, cout, endl
#include <iostream> // para basic_ostream, char_traits, operator<< #include "utils.h" // Para HiScoreEntry, getFileName
#include "utils.h" // para HiScoreEntry
// Resetea la tabla a los valores por defecto // Resetea la tabla a los valores por defecto
void ManageHiScoreTable::clear() void ManageHiScoreTable::clear()

View File

@@ -2,7 +2,6 @@
#include <string> // para string #include <string> // para string
#include <vector> // para vector #include <vector> // para vector
struct HiScoreEntry;
/* /*
Esta clase sirve para añadir elementos hiScoreEntry_r a un vector (tabla), de manera Esta clase sirve para añadir elementos hiScoreEntry_r a un vector (tabla), de manera
@@ -12,6 +11,17 @@ struct HiScoreEntry;
leer y escribir la tabla a un fichero leer y escribir la tabla a un fichero
*/ */
// Estructura para las entradas de la tabla de recirds
struct HiScoreEntry
{
std::string name; // Nombre
int score; // Puntuación
// Constructor
explicit HiScoreEntry(const std::string &n = "", int s = 0)
: name(n), score(s) {}
};
// Clase ManageHiScoreTable // Clase ManageHiScoreTable
class ManageHiScoreTable class ManageHiScoreTable
{ {

View File

@@ -1,5 +1,6 @@
#include "moving_sprite.h" #include "moving_sprite.h"
#include "texture.h" // para Texture #include <algorithm> // Para max
#include "texture.h" // Para Texture
// Constructor // Constructor
MovingSprite::MovingSprite(std::shared_ptr<Texture> texture, SDL_Rect pos, Rotate rotate, float zoom_w, float zoom_h, SDL_RendererFlip flip) MovingSprite::MovingSprite(std::shared_ptr<Texture> texture, SDL_Rect pos, Rotate rotate, float zoom_w, float zoom_h, SDL_RendererFlip flip)

View File

@@ -1,11 +1,10 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // para SDL_Rect, SDL_Point #include <SDL2/SDL_rect.h> // Para SDL_Rect, SDL_Point
#include <SDL2/SDL_render.h> // para SDL_RendererFlip #include <SDL2/SDL_render.h> // Para SDL_RendererFlip
#include <SDL2/SDL_stdinc.h> // para Uint16 #include <memory> // Para shared_ptr
#include <memory> // para shared_ptr #include "sprite.h" // Para Sprite
#include "sprite.h" // para Sprite class Texture; // lines 8-8
class Texture;
// Clase MovingSprite. Añade movimiento y efectos de rotación, zoom y flip al sprite // Clase MovingSprite. Añade movimiento y efectos de rotación, zoom y flip al sprite
class MovingSprite : public Sprite class MovingSprite : public Sprite

View File

@@ -1,14 +1,13 @@
#include "notifier.h" #include "notifier.h"
#include <SDL2/SDL_blendmode.h> // para SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_pixels.h> // para SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <string> // para string #include <string> // Para string
#include "jail_audio.h" // para JA_DeleteSound, JA_LoadSound, JA_Pla... #include "jail_audio.h" // Para JA_DeleteSound, JA_LoadSound, JA_Pla...
#include "param.h" // para param #include "param.h" // Para Param, param, ParamNotification, Par...
#include "resource.h" // para Resource #include "screen.h" // Para Screen
#include "screen.h" // para Screen #include "sprite.h" // Para Sprite
#include "sprite.h" // para Sprite #include "text.h" // Para Text
#include "text.h" // para Text #include "texture.h" // Para Texture
#include "texture.h" // para Texture
// [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
Notifier *Notifier::notifier_ = nullptr; Notifier *Notifier::notifier_ = nullptr;
@@ -34,35 +33,25 @@ Notifier *Notifier::get()
// Constructor // Constructor
Notifier::Notifier(std::string icon_file, std::shared_ptr<Text> text, const std::string &sound_file) Notifier::Notifier(std::string icon_file, std::shared_ptr<Text> text, const std::string &sound_file)
: renderer_(Screen::get()->getRenderer()), : renderer_(Screen::get()->getRenderer()),
icon_texture_(!icon_file.empty() ? std::make_unique<Texture>(renderer_, icon_file) : nullptr),
text_(text), text_(text),
bg_color_(param.notification.color), bg_color_(param.notification.color),
wait_time_(150), wait_time_(150),
stack_(false), stack_(false),
sound_(JA_LoadSound(sound_file.c_str())) has_icons_(!icon_file.empty()),
{ sound_(JA_LoadSound(sound_file.c_str())) {}
// Inicializa variables
has_icons_ = !icon_file.empty();
// Crea objetos
icon_texture_ = has_icons_ ? std::make_unique<Texture>(renderer_, icon_file) : nullptr;
}
// Destructor // Destructor
Notifier::~Notifier() Notifier::~Notifier()
{ {
// Libera la memoria de los objetos
JA_DeleteSound(sound_); JA_DeleteSound(sound_);
notifications_.clear();
} }
// Dibuja las notificaciones por pantalla // Dibuja las notificaciones por pantalla
void Notifier::render() void Notifier::render()
{ {
for (int i = (int)notifications_.size() - 1; i >= 0; --i) for (int i = (int)notifications_.size() - 1; i >= 0; --i)
{
notifications_[i].sprite->render(); notifications_[i].sprite->render();
}
} }
// Actualiza el estado de las notificaiones // Actualiza el estado de las notificaiones

View File

@@ -1,16 +1,14 @@
#include "on_screen_help.h" #include "on_screen_help.h"
#include <SDL2/SDL_blendmode.h> // para SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_pixels.h> // para SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <memory> // para make_unique, make_shared, unique_ptr #include <memory> // Para make_unique, unique_ptr
#include "asset.h" // para Asset #include "lang.h" // Para getText
#include "lang.h" // para getText #include "param.h" // Para Param, ParamGame, param
#include "param.h" // para param #include "resource.h" // Para Resource
#include "resource.h" // para Resource #include "screen.h" // Para Screen
#include "screen.h" // para Screen #include "sprite.h" // Para Sprite
#include "sprite.h" // para Sprite #include "text.h" // Para Text
#include "text.h" // para Text #include "utils.h" // Para easeInOutSine
#include "texture.h" // para Texture
#include "utils.h" // para 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

@@ -1,7 +1,93 @@
#pragma once #pragma once
#include <string> // para string #include <SDL2/SDL_gamecontroller.h> // Para SDL_GameControllerButton
struct Options; #include <SDL2/SDL_stdinc.h> // Para Uint8
#include "manage_hiscore_table.h"
#include <vector> // Para vector
#include <string>
enum class InputType : int;
enum class ScreenFilter : int;
enum class ScreenVideoMode : int;
namespace lang
{
enum class Code : int;
}
// Dificultad del juego
enum class GameDifficulty
{
EASY = 0,
NORMAL = 1,
HARD = 2,
};
// Estructura para las opciones de la ventana
struct OptionsWindow
{
int size; // Contiene el valor por el que se multiplica el tamaño de la ventana
};
// Estructura con opciones para el video
struct OptionsVideo
{
OptionsWindow window; // Opciones para la ventana del programa
ScreenVideoMode mode; // Contiene el valor del modo de pantalla completa
ScreenFilter filter; // Filtro usado para el escalado de la imagen
bool v_sync; // Indica si se quiere usar vsync o no
bool integer_scale; // Indica si se va a usar el escalado entero
bool shaders; // Indica si se van a usar shaders para los filtros de video
};
// Estructura para las opciones de musica
struct OptionsMusic
{
bool enabled; // Indica si la musica suena o no
int volume; // Volumen al que suena la música
};
// Estructura para las opciones de sonido
struct OptionsSound
{
bool enabled; // Indica si los sonidos suenan o no
int volume; // Volumen al que suenan los sonidos
};
// Estructura para las opciones de audio
struct OptionsAudio
{
OptionsMusic music; // Opciones para la música
OptionsSound sound; // Opciones para los efectos de sonido
};
// Estructura para las opciones del juego
struct OptionsGame
{
GameDifficulty difficulty; // Dificultad del 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
std::vector<HiScoreEntry> hi_score_table; // Tabla con las mejores puntuaciones
};
// Estructura para los controles del juego
struct OptionsController
{
int index; // Indice en el vector de mandos
int player_id; // Jugador asociado al mando
Uint8 device_type; // Indica si se utilizará teclado o mando o ambos
std::string name; // Nombre del dispositivo
bool plugged; // Indica si el mando se encuentra conectado
std::vector<InputType> inputs; // Listado de inputs
std::vector<SDL_GameControllerButton> buttons; // Listado de botones asignados a cada input
};
// Estructura con todas las opciones de configuración del programa
struct Options
{
OptionsGame game; // Opciones para el propio juego
OptionsVideo video; // Opciones relativas a la clase screen
OptionsAudio audio; // Opciones para el audio
std::vector<OptionsController> controller; // Opciones con las asignaciones del mando para cada jugador
};
// Variables // Variables
extern Options options; extern Options options;

View File

@@ -1,7 +1,80 @@
#pragma once #pragma once
#include <string> // para string #include <SDL2/SDL_rect.h> // Para SDL_Rect
struct Param; #include <string> // Para string
#include <vector> // Para vector
#include "utils.h" // Para Color, Zone
// param.game
struct ParamGame
{
int width; // Ancho de la resolucion nativa del juego
int height; // Alto de la resolucion nativa del juego
int item_size; // Tamaño de los items del juego
Zone play_area; // Rectangulo con la posición de la zona de juego
Zone game_area; // Rectangulo con las dimensiones del juego
int enter_name_seconds; // Duración en segundos para introducir el nombre al finalizar la partida
};
// param.fade
struct ParamFade
{
int num_squares_width; // Cantidad total de cuadraditos en horizontal para el FadeType::RANDOM_SQUARE
int num_squares_height; // Cantidad total de cuadraditos en vertical para el FadeType::RANDOM_SQUARE
int random_squares_delay; // Duración entre cada pintado de cuadrados
int random_squares_mult; // Cantidad de cuadrados que se pintaran cada vez
int post_duration; // Duración final del fade
int venetian_size; // Altura de los rectangulos para FadeType::VENETIAN
};
// param.title
struct ParamTitle
{
int press_start_position; // Posición del texto para empezar a jugar
int title_duration; // Tiempo de inactividad del titulo
int arcade_edition_position; // Posición del bitmap
int title_c_c_position; // Posición del bitmap
};
// param.background
struct ParamBackground
{
Color attenuate_color;
int attenuate_alpha;
};
struct ParamBalloon
{
float grav; // Aceleración en el eje Y. Modifica la velocidad
float vel; // Velocidad inicial que tienen al rebotar contra el suelo
// Constructor
explicit ParamBalloon(float grav_val = 0.0f, float vel_val = 0.0f)
: grav(grav_val), vel(vel_val) {}
};
// Estructura para las opciones de las notificaciones
struct ParamNotification
{
NotifyPosition pos_h; // Ubicación de las notificaciones en pantalla
NotifyPosition pos_v; // Ubicación de las notificaciones en pantalla
bool sound; // Indica si las notificaciones suenan
Color color; // Color de las notificaciones
};
// Estructura para almacenar todos los parámetros del juego
struct Param
{
ParamGame game; // Parametros relacionados con el juego
ParamFade fade; // Parametros para ajustar el fade
SDL_Rect scoreboard; // Posición y tamaño del marcador
ParamTitle title; // Parametros con ajustes para la sección Title
ParamBackground background; // Parametros que afectan a la clase Background
std::vector<ParamBalloon> balloon; // Parametros de velocidad y gravedad de cada tipo de globo
ParamNotification notification; // Opciones para las notificaciones
Param() { balloon.reserve(4); }
};
extern Param param; extern Param param;

View File

@@ -1,6 +1,11 @@
#include "path_sprite.h" #include "path_sprite.h"
#include "utils.h" #include <bits/std_abs.h> // Para abs
class Texture; #include <stdlib.h> // Para abs
#include <utility> // Para move
#include "moving_sprite.h" // Para MovingSprite
#include "utils.h" // Para easeOutQuint
#include <functional>
class Texture; // lines 3-3
// Constructor // Constructor
PathSprite::PathSprite(std::shared_ptr<Texture> texture) PathSprite::PathSprite(std::shared_ptr<Texture> texture)
@@ -16,57 +21,49 @@ void PathSprite::update()
} }
} }
// Añade un recorrido vertical // Añade un recorrido
void PathSprite::addVerticalPath(SDL_Point start, SDL_Point end, int steps, int waiting_counter) void PathSprite::addPath(int start, int end, PathType type, int fixed_pos, int steps, const std::function<double(double)> &easingFunction, int waiting_counter)
{ {
paths_.emplace_back(createVerticalPath(start, end, steps), waiting_counter); paths_.emplace_back(createPath(start, end, type, fixed_pos, steps, easingFunction), waiting_counter);
} }
// Añade un recorrido horizontal // Añade un recorrido
void PathSprite::addHorizontalPath(SDL_Point start, SDL_Point end, int steps, int waiting_counter)
{
paths_.emplace_back(createHorizontalPath(start, end, steps), waiting_counter);
}
// Añade un recorrido desde un vector
void PathSprite::addPath(std::vector<SDL_Point> spots, int waiting_counter) void PathSprite::addPath(std::vector<SDL_Point> spots, int waiting_counter)
{ {
paths_.emplace_back(spots, waiting_counter); paths_.emplace_back(std::move(spots), waiting_counter);
} }
std::vector<SDL_Point> PathSprite::createVerticalPath(const SDL_Point& start, const SDL_Point& end, int steps) {
std::vector<SDL_Point> v;
v.reserve(steps);
for (int i = 0; i < steps; ++i) {
double t = static_cast<double>(i) / steps;
double value = start.y + (end.y - start.y) * easeOutQuint(t);
// Ajusta el valor si los puntos tienen signos diferentes
if (start.y > 0 && end.y < 0) {
value = start.y - std::abs(end.y - start.y) * easeOutQuint(t);
} else if (start.y < 0 && end.y > 0) {
value = start.y + std::abs(end.y - start.y) * easeOutQuint(t);
}
v.emplace_back(SDL_Point{start.x, static_cast<int>(value)});
}
return v;
}
// Devuelve un vector con los puntos que conforman la ruta // Devuelve un vector con los puntos que conforman la ruta
std::vector<SDL_Point> PathSprite::createHorizontalPath(SDL_Point start, SDL_Point end, int steps) std::vector<SDL_Point> PathSprite::createPath(int start, int end, PathType type, int fixed_pos, int steps, const std::function<double(double)> &easingFunction)
{ {
std::vector<SDL_Point> v; std::vector<SDL_Point> v;
v.reserve(steps); v.reserve(steps);
for (int i = 0; i < steps; ++i) for (int i = 0; i < steps; ++i)
{ {
double t = static_cast<double>(i) / steps; double t = static_cast<double>(i) / (steps - 1);
double value = static_cast<double>(start.x) + (end.x - start.x) * easeOutQuint(t); double value = start + (end - start) * easingFunction(t);
v.emplace_back(SDL_Point{static_cast<int>(value), start.y});
if (start > 0 && end < 0)
{
value = start - std::abs(end - start) * easingFunction(t);
}
else if (start < 0 && end > 0)
{
value = start + std::abs(end - start) * easingFunction(t);
}
switch (type)
{
case PathType::HORIZONTAL:
v.emplace_back(SDL_Point{static_cast<int>(value), fixed_pos});
break;
case PathType::VERTICAL:
v.emplace_back(SDL_Point{fixed_pos, static_cast<int>(value)});
break;
default:
break;
}
} }
return v; return v;
@@ -84,7 +81,7 @@ void PathSprite::moveThroughCurrentPath()
auto &path = paths_.at(current_path_); auto &path = paths_.at(current_path_);
// Establece la posición // Establece la posición
const SDL_Point p = path.spots.at(path.counter); const auto &p = path.spots.at(path.counter);
MovingSprite::setPos(p.x, p.y); MovingSprite::setPos(p.x, p.y);
// Comprobar si ha terminado el recorrido // Comprobar si ha terminado el recorrido
@@ -99,10 +96,13 @@ void PathSprite::moveThroughCurrentPath()
} }
// Comprobar si ha terminado la espera // Comprobar si ha terminado la espera
if (path.waiting_counter == 0) if (path.on_destination)
path.finished = true; {
else if (path.on_destination) if (path.waiting_counter == 0)
path.finished = true;
else
--path.waiting_counter; --path.waiting_counter;
}
} }
// Cambia de recorrido o finaliza // Cambia de recorrido o finaliza

View File

@@ -1,8 +1,11 @@
#pragma once #pragma once
#include <memory> // para shared_ptr #include <SDL2/SDL_rect.h> // Para SDL_Point
#include "animated_sprite.h" // para SpriteAnimated #include <memory> // Para shared_ptr
class Texture; #include <functional>
#include <vector> // Para vector
#include "animated_sprite.h" // Para AnimatedSprite
class Texture; // lines 5-5
enum class PathType enum class PathType
{ {
@@ -15,20 +18,18 @@ class PathSprite : public AnimatedSprite
{ {
private: private:
// Estructuras // Estructuras
struct Path { struct Path
std::vector<SDL_Point> spots; // Puntos por los que se desplazará el sprite {
int fixed_pos; // Coordenada fija std::vector<SDL_Point> spots; // Puntos por los que se desplazará el sprite
int waiting_counter; // Tiempo de espera una vez en el destino int waiting_counter; // Tiempo de espera una vez en el destino
bool on_destination = false; // Indica si ha llegado al destino bool on_destination = false; // Indica si ha llegado al destino
bool finished = false; // Indica si ha terminado de esperarse bool finished = false; // Indica si ha terminado de esperarse
int counter = 0; // Contador interno int counter = 0; // Contador interno
PathType type; // Tipo de recorrido
// Constructor
Path(const std::vector<SDL_Point>& spots_init, int waiting_counter_init, int fixed_pos_init, PathType type_init)
: spots(spots_init), waiting_counter(waiting_counter_init), fixed_pos(fixed_pos_init), type(type_init) {}
};
// Constructor
Path(const std::vector<SDL_Point> &spots_init, int waiting_counter_init)
: spots(spots_init), waiting_counter(waiting_counter_init) {}
};
// Variables // Variables
bool finished_ = false; // Indica si ya ha terminado bool finished_ = false; // Indica si ya ha terminado
@@ -52,20 +53,12 @@ public:
// Actualiza la posición del sprite // Actualiza la posición del sprite
void update() override; void update() override;
// Añade un recorrido vertical // Añade un recorrido
void addVerticalPath(SDL_Point start, SDL_Point end, int steps, int waiting_counter);
// Añade un recorrido horizontal
void addHorizontalPath(SDL_Point start, SDL_Point end, int steps, int waiting_counter);
// Añade un recorrido desde un vector
void addPath(std::vector<SDL_Point> spots, int waiting_counter); void addPath(std::vector<SDL_Point> spots, int waiting_counter);
void addPath(int start, int end, PathType type, int fixed_pos, int steps, const std::function<double(double)> &easingFunction, int waiting_counter);
// Devuelve un vector con los puntos que conforman la ruta // Devuelve un vector con los puntos que conforman la ruta
std::vector<SDL_Point> createVerticalPath(const SDL_Point &start, const SDL_Point &end, int steps); std::vector<SDL_Point> createPath(int start, int end, PathType type, int fixed_pos, int steps, const std::function<double(double)> &easingFunction);
// Devuelve un vector con los puntos que conforman la ruta
std::vector<SDL_Point> createHorizontalPath(SDL_Point start, SDL_Point end, int steps);
// Habilita el objeto // Habilita el objeto
void enable(); void enable();

View File

@@ -1,14 +1,15 @@
#include "player.h" #include "player.h"
#include <SDL2/SDL_render.h> // para SDL_FLIP_HORIZONTAL, SDL_FLIP_NONE, SDL... #include <SDL2/SDL_render.h> // Para SDL_FLIP_HORIZONTAL, SDL_FLIP_NONE
#include <SDL2/SDL_timer.h> // para SDL_GetTicks #include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <stdlib.h> // para rand #include <stdlib.h> // Para rand
#include <algorithm> // para max, min #include <algorithm> // Para max, min
#include "animated_sprite.h" // para SpriteAnimated #include "animated_sprite.h" // Para AnimatedSprite
#include "input.h" // para inputs_e #include "input.h" // Para InputType
#include "param.h" // para param #include "manage_hiscore_table.h" // Para HiScoreEntry
#include "texture.h" // para Texture #include "options.h" // Para Options, OptionsGame, options
#include "scoreboard.h" // para Texture #include "param.h" // Para Param, ParamGame, param
#include "options.h" #include "scoreboard.h" // Para Scoreboard, ScoreboardMode
#include "texture.h" // Para Texture
// Constructor // Constructor
Player::Player(int id, float x, int y, bool demo, SDL_Rect &play_area, std::vector<std::shared_ptr<Texture>> texture, const std::vector<std::vector<std::string>> &animations) Player::Player(int id, float x, int y, bool demo, SDL_Rect &play_area, std::vector<std::shared_ptr<Texture>> texture, const std::vector<std::vector<std::string>> &animations)

View File

@@ -1,17 +1,16 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // para SDL_Rect #include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <SDL2/SDL_stdinc.h> // para Uint32 #include <SDL2/SDL_stdinc.h> // Para Uint32
#include <memory> // para unique_ptr, shared_ptr #include <memory> // Para unique_ptr, shared_ptr
#include <string> // para string #include <string> // Para string
#include <vector> // para vector #include <vector> // Para vector
#include "animated_sprite.h" // para SpriteAnimated #include "animated_sprite.h" // Para AnimatedSprite
#include "smart_sprite.h" // para SpriteAnimated #include "enter_name.h" // Para EnterName
#include "enter_name.h" // para EnterName #include "utils.h" // Para Circle
#include "utils.h" // para Circle class Texture; // lines 12-12
class Texture; enum class InputType : int; // lines 13-13
enum class InputType : int; enum class ScoreboardMode; // lines 14-14
enum class ScoreboardMode; // lines 12-12
// Estados del jugador // Estados del jugador
enum class PlayerStatus enum class PlayerStatus

View File

@@ -1,9 +1,12 @@
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include "resource.h" #include "resource.h"
#include "asset.h" #include <algorithm> // Para find_if
#include "screen.h" #include <iostream> // Para basic_ostream, operator<<, endl, cout, cerr
#include <stdexcept> // Para runtime_error
#include "asset.h" // Para Asset, AssetType
#include "jail_audio.h" // Para JA_LoadMusic, JA_LoadSound
#include "screen.h" // Para Screen
struct JA_Music_t;
struct JA_Sound_t;
// [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
Resource *Resource::resource_ = nullptr; Resource *Resource::resource_ = nullptr;

View File

@@ -1,14 +1,14 @@
#pragma once #pragma once
#include <SDL2/SDL.h> #include <memory> // Para shared_ptr
#include <vector> #include <string> // Para string
#include <memory> #include <vector> // Para vector
#include <string> #include "animated_sprite.h" // Para AnimationsFileBuffer
#include "jail_audio.h" #include "text.h" // Para TextFile
#include "texture.h" #include "texture.h" // Para Texture
#include "text.h" #include "utils.h" // Para DemoData
#include "utils.h" struct JA_Music_t;
#include "animated_sprite.h" struct JA_Sound_t;
// Estructura para almacenar ficheros de sonido y su nombre // Estructura para almacenar ficheros de sonido y su nombre
struct ResourceSound struct ResourceSound

View File

@@ -1,17 +1,15 @@
#include "scoreboard.h" #include "scoreboard.h"
#include <SDL2/SDL_blendmode.h> // para SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_pixels.h> // para SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_timer.h> // para SDL_GetTicks #include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <math.h> // para roundf #include <math.h> // Para roundf
#include <iomanip> #include <iomanip> // Para operator<<, setfill, setw
#include <sstream> #include <sstream> // Para basic_ostream, basic_ostringstream
#include "asset.h" // para Asset #include "lang.h" // Para getText
#include "lang.h" // para getText #include "resource.h" // Para Resource
#include "resource.h" // para Resource #include "screen.h" // Para Screen
#include "screen.h" #include "sprite.h" // Para Sprite
#include "sprite.h" // para Sprite #include "text.h" // Para Text
#include "text.h" // para Text
#include "texture.h" // para Texture
// [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
Scoreboard *Scoreboard::scoreboard_ = nullptr; Scoreboard *Scoreboard::scoreboard_ = nullptr;

View File

@@ -1,20 +1,20 @@
#include "screen.h" #include "screen.h"
#include <SDL2/SDL_events.h> // para SDL_DISABLE, SDL_ENABLE #include <SDL2/SDL_events.h> // Para SDL_DISABLE, SDL_ENABLE
#include <SDL2/SDL_mouse.h> // para SDL_ShowCursor #include <SDL2/SDL_mouse.h> // Para SDL_ShowCursor
#include <SDL2/SDL_pixels.h> // para SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_timer.h> // para SDL_GetTicks #include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <algorithm> // para max, min #include <algorithm> // Para clamp, max, min
#include <fstream> // para basic_ifstream, ifstream #include <fstream> // Para basic_ifstream, ifstream
#include <iterator> // para istreambuf_iterator, operator!= #include <iterator> // Para istreambuf_iterator, operator==
#include <string> // para basic_string, operator+, to_string, cha... #include <string> // Para allocator, operator+, to_string, char_t...
#include <vector> // para vector #include <vector> // Para vector
#include "asset.h" // para Asset #include "asset.h" // Para Asset
#include "dbgtxt.h" // para dbg_print #include "dbgtxt.h" // Para dbg_print
#include "global_inputs.h" // para servicePressedCounter #include "global_inputs.h" // Para service_pressed_counter
#include "input.h" // para Input, inputs_e, INPUT_DO_NOT_ALLOW_REPEAT #include "input.h" // Para Input, InputType, INPUT_DO_NOT_ALLOW_RE...
#include "notifier.h" // para Notify #include "notifier.h" // Para Notifier
#include "on_screen_help.h" // para OnScreenHelp #include "on_screen_help.h" // Para OnScreenHelp
#include "options.h" // para options #include "options.h" // Para Options, OptionsVideo, options, Options...
#ifndef NO_SHADERS #ifndef NO_SHADERS
#include "jail_shader.h" // para init, render #include "jail_shader.h" // para init, render

View File

@@ -1,14 +1,13 @@
#pragma once #pragma once
#include <SDL2/SDL_blendmode.h> // para SDL_BlendMode #include <SDL2/SDL_blendmode.h> // Para SDL_BlendMode
#include <SDL2/SDL_rect.h> // para SDL_Rect #include <SDL2/SDL_rect.h> // Para SDL_Rect, SDL_Point
#include <SDL2/SDL_render.h> // para SDL_Renderer, SDL_Texture #include <SDL2/SDL_render.h> // Para SDL_Renderer, SDL_Texture
#include <SDL2/SDL_stdinc.h> // para Uint32 #include <SDL2/SDL_stdinc.h> // Para Uint32
#include <SDL2/SDL_video.h> // para SDL_Window #include <SDL2/SDL_video.h> // Para SDL_Window
#include <string> // para basic_string, string #include <string> // Para string
#include "utils.h" // para Color #include "param.h" // Para Param, ParamGame, param
#include <memory> #include "utils.h" // Para Color
#include "param.h" // para param
enum class ScreenFilter : int enum class ScreenFilter : int
{ {

View File

@@ -1,5 +1,6 @@
#include "smart_sprite.h" #include "smart_sprite.h"
class Texture; #include "moving_sprite.h" // Para MovingSprite
class Texture; // lines 2-2
// Constructor // Constructor
SmartSprite::SmartSprite(std::shared_ptr<Texture> texture) SmartSprite::SmartSprite(std::shared_ptr<Texture> texture)

View File

@@ -1,11 +1,11 @@
#include "text.h" #include "text.h"
#include <SDL2/SDL_rect.h> // para SDL_Rect #include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <fstream> // para basic_ostream, basic_ifstream, basic_istream #include <fstream> // Para basic_ifstream, basic_istream, basic_ostream
#include <iostream> // para cout #include <iostream> // Para cerr
#include "resource.h" // para Resource #include <stdexcept> // Para runtime_error
#include "sprite.h" // para Sprite #include "sprite.h" // Para Sprite
#include "texture.h" // para Texture #include "texture.h" // Para Texture
#include "utils.h" // para Color #include "utils.h" // Para Color, getFileName, printWithDots
// Llena una estructuta TextFile desde un fichero // Llena una estructuta TextFile desde un fichero
std::shared_ptr<TextFile> loadTextFile(const std::string &file_path) std::shared_ptr<TextFile> loadTextFile(const std::string &file_path)

View File

@@ -1,12 +1,11 @@
#pragma once #pragma once
#include <SDL2/SDL_render.h> // para SDL_Renderer #include <SDL2/SDL_stdinc.h> // Para Uint8
#include <SDL2/SDL_stdinc.h> // para Uint8 #include <memory> // Para unique_ptr, shared_ptr
#include <memory> // para shared_ptr, unique_ptr #include <string> // Para string
#include <string> // para string #include "sprite.h" // Para Sprite
#include "sprite.h" // para Sprite #include "utils.h" // Para Color
#include "utils.h" // para Color class Texture; // lines 9-9
class Texture;
constexpr int TEXT_COLOR = 1; constexpr int TEXT_COLOR = 1;
constexpr int TEXT_SHADOW = 2; constexpr int TEXT_SHADOW = 2;

View File

@@ -1,15 +1,16 @@
#include "texture.h" #include "texture.h"
#include "utils.h" #include <SDL2/SDL_error.h> // Para SDL_GetError
#include <SDL2/SDL_error.h> // para SDL_GetError #include <SDL2/SDL_surface.h> // Para SDL_CreateRGBSurfaceWithFormatFrom
#include <SDL2/SDL_surface.h> // para SDL_CreateRGBSurfaceWithFormatFrom #include <fcntl.h> // Para SEEK_END, SEEK_SET
#include <fcntl.h> // para SEEK_END, SEEK_SET #include <stdio.h> // Para fseek, fclose, fopen, fread, ftell, FILE
#include <stdio.h> // para fseek, fclose, fopen, fread, ftell, NULL #include <stdlib.h> // Para free, malloc
#include <stdlib.h> // para malloc, free, exit #include <fstream> // Para basic_ostream, operator<<, basic_ifstream
#include <iostream> // para basic_ostream, operator<<, cout, endl #include <iostream> // Para cerr, cout
#include <fstream> #include <stdexcept> // Para runtime_error
#include <sstream> #include "gif.c" // Para LoadGif, LoadPalette
#include "gif.c" // para LoadGif, LoadPalette #include "utils.h" // Para getFileName, printWithDots
#define STB_IMAGE_IMPLEMENTATION #define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h" // para stbi_failure_reason, stbi_image_free #include "stb_image.h" // para stbi_failure_reason, stbi_image_free

View File

@@ -1,12 +1,11 @@
#include "tiled_bg.h" #include "tiled_bg.h"
#include <SDL2/SDL_pixels.h> // para SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <stdlib.h> // para rand #include <stdlib.h> // Para rand
#include <memory> // para unique_ptr, make_shared, make_unique #include <cmath> // Para sin
#include <cmath> // para sinf #include <memory> // Para unique_ptr, make_unique
#include "resource.h" // para Resource #include "resource.h" // Para Resource
#include "screen.h" // para Screen #include "screen.h" // Para Screen
#include "sprite.h" // para Sprite #include "sprite.h" // Para Sprite
#include "texture.h" // para Texture
// Constructor // Constructor
TiledBG::TiledBG(SDL_Rect pos, TiledBGMode mode) TiledBG::TiledBG(SDL_Rect pos, TiledBGMode mode)

View File

@@ -1,8 +1,7 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // para SDL_Rect #include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <SDL2/SDL_render.h> // para SDL_Renderer, SDL_Texture #include <SDL2/SDL_render.h> // Para SDL_Renderer, SDL_Texture
#include <string> // para string, basic_string
// Modos de funcionamiento para el tileado de fondo // Modos de funcionamiento para el tileado de fondo
enum class TiledBGMode : int enum class TiledBGMode : int

View File

@@ -1,26 +1,29 @@
#include "title.h" #include "title.h"
#include <SDL2/SDL_events.h> // para SDL_PollEvent, SDL_Event, SDL_KEYDOWN #include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_KEYDOWN
#include <SDL2/SDL_keycode.h> // para SDLK_1, SDLK_2, SDLK_3 #include <SDL2/SDL_keycode.h> // Para SDLK_1, SDLK_2, SDLK_3
#include <SDL2/SDL_rect.h> // para SDL_Rect #include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <SDL2/SDL_render.h> // para SDL_Renderer #include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <SDL2/SDL_timer.h> // para SDL_GetTicks #include <string> // Para char_traits, operator+, to_string, bas...
#include <string> // para char_traits, operator+, to_string, bas... #include <utility> // Para move
#include <utility> // para move #include <vector> // Para vector
#include <vector> // para vector #include "define_buttons.h" // Para DefineButtons
#include "asset.h" // para Asset #include "fade.h" // Para Fade, FadeType
#include "global_inputs.h" // para check #include "game_logo.h" // Para GameLogo
#include "input.h" // para Input, InputType, INPUT_DO_NOT_ALLOW_R... #include "global_inputs.h" // Para check
#include "jail_audio.h" // para JA_GetMusicState, JA_Music_state, JA_P... #include "input.h" // Para Input, InputType, INPUT_DO_NOT_ALLOW_R...
#include "lang.h" // para getText #include "jail_audio.h" // Para JA_GetMusicState, JA_Music_state, JA_P...
#include "notifier.h" // para Notifier #include "lang.h" // Para getText
#include "options.h" // para options #include "notifier.h" // Para Notifier
#include "param.h" // para param #include "options.h" // Para OptionsController, Options, options
#include "resource.h" // para Resource #include "param.h" // Para Param, param, ParamGame, ParamTitle
#include "screen.h" // para Screen #include "resource.h" // Para Resource
#include "section.h" // para Options, options, Name, name #include "screen.h" // Para Screen
#include "texture.h" // para Texture #include "section.h" // Para Options, options, name, Name
#include "utils.h" // para Param, OptionsController, Color, Param... #include "sprite.h" // Para Sprite
struct JA_Music_t; // lines 17-17 #include "text.h" // Para Text, TEXT_CENTER, TEXT_SHADOW
#include "texture.h" // Para Texture
#include "tiled_bg.h" // Para TiledBG, TiledBGMode
#include "utils.h" // Para Color, Zone, fade_color, no_color, BLOCK
// Constructor // Constructor
Title::Title() Title::Title()

View File

@@ -1,22 +1,15 @@
#pragma once #pragma once
#include <SDL2/SDL_stdinc.h> // para Uint32 #include <SDL2/SDL_stdinc.h> // Para Uint32
#include <memory> // para unique_ptr, shared_ptr #include <memory> // Para unique_ptr, shared_ptr
#include "define_buttons.h" // para DefineButtons #include "section.h" // Para Name
#include "fade.h" // para Fade class DefineButtons;
#include "game_logo.h" // para GameLogo class Fade;
#include "sprite.h" // para Sprite class GameLogo;
#include "text.h" // para Text class Sprite;
#include "tiled_bg.h" // para TiledBG class Text;
class Input; // lines 17-17 class Texture; // lines 14-14
#include "section.h" // para Options, options, Name, name class TiledBG;
class Screen; // lines 18-18
class Texture; // lines 20-20
namespace section
{
enum class Name;
}
struct JA_Music_t; // lines 21-21
// Textos // Textos
constexpr const char TEXT_COPYRIGHT[] = "@2020,2024 JailDesigner"; constexpr const char TEXT_COPYRIGHT[] = "@2020,2024 JailDesigner";

View File

@@ -1,13 +1,13 @@
#include "utils.h" #include "utils.h"
#include <filesystem> #include <SDL2/SDL_rwops.h> // Para SDL_RWFromFile, SDL_RWclose, SDL_RWread
#include <iostream> #include <algorithm> // Para min, clamp, find_if_not, find, transform
#include <string> #include <cctype> // Para tolower, isspace
#include <algorithm> // para min, clamp, find_if_not, transform #include <cmath> // Para cos, pow, M_PI
#include <cctype> // para tolower, isspace #include <compare> // Para operator<
#include <cmath> // para cos, pow, M_PI #include <filesystem> // Para path
#include <compare> // para operator< #include <iostream> // Para basic_ostream, cout, basic_ios, endl, ios
struct JA_Music_t; // lines 7-7 #include <stdexcept> // Para runtime_error
struct JA_Sound_t; // lines 8-8 #include <string> // Para basic_string, string, char_traits, opera...
// Variables // Variables
Overrides overrides = Overrides(); Overrides overrides = Overrides();
@@ -182,6 +182,30 @@ double easeOutQuint(double t)
return 1 - std::pow(1 - t, 5); return 1 - std::pow(1 - t, 5);
} }
// Función de suavizado
double easeInQuint(double t)
{
return pow(t, 5);
}
// Función de suavizado
double easeInOutQuint(double t)
{
return t < 0.5 ? 16 * pow(t, 5) : 1 - pow(-2 * t + 2, 5) / 2;
}
// Función de suavizado
double easeInQuad(double t)
{
return t * t;
}
// Función de suavizado
double easeOutQuad(double t)
{
return 1 - (1 - t) * (1 - t);
}
// Función de suavizado // Función de suavizado
double easeInOutSine(double t) double easeInOutSine(double t)
{ {

View File

@@ -1,34 +1,16 @@
#pragma once #pragma once
#include <SDL2/SDL_gamecontroller.h> // para SDL_GameControllerButton #include <SDL2/SDL_rect.h> // Para SDL_Rect, SDL_Point
#include <SDL2/SDL_rect.h> // para SDL_Rect, SDL_Point #include <SDL2/SDL_render.h> // Para SDL_Renderer
#include <SDL2/SDL_render.h> // para SDL_Renderer #include <SDL2/SDL_stdinc.h> // Para Uint8
#include <SDL2/SDL_stdinc.h> // para Uint8 #include <stdint.h> // Para int32_t
#include <stdint.h> // para int32_t #include <string> // Para string
#include <string> // para string #include <vector> // Para vector
#include <vector> // para vector
enum class InputType : int;
enum class ScreenFilter; // lines 14-14
enum class ScreenVideoMode; // lines 15-15
namespace lang
{
enum class Code : int;
}
struct JA_Music_t; // lines 12-12
struct JA_Sound_t; // lines 13-13
// Constantes // Constantes
constexpr int BLOCK = 8; constexpr int BLOCK = 8;
constexpr int TOTAL_DEMO_DATA = 2000; constexpr int TOTAL_DEMO_DATA = 2000;
// Dificultad del juego
enum class GameDifficulty
{
EASY = 0,
NORMAL = 1,
HARD = 2,
};
// Variables para que los argumentos del programa tengan mas peso que los definidos en otros lugares // Variables para que los argumentos del programa tengan mas peso que los definidos en otros lugares
struct Overrides struct Overrides
{ {
@@ -74,17 +56,6 @@ enum class NotifyPosition
RIGHT, RIGHT,
}; };
// Estructura para las entradas de la tabla de recirds
struct HiScoreEntry
{
std::string name; // Nombre
int score; // Puntuación
// Constructor
explicit HiScoreEntry(const std::string &n = "", int s = 0)
: name(n), score(s) {}
};
struct DemoKeys struct DemoKeys
{ {
Uint8 left; Uint8 left;
@@ -117,74 +88,6 @@ struct Demo
: enabled(e), recording(r), counter(c), keys(k), data(d) {} : enabled(e), recording(r), counter(c), keys(k), data(d) {}
}; };
// Estructura para las opciones de la ventana
struct OptionsWindow
{
int size; // Contiene el valor por el que se multiplica el tamaño de la ventana
};
// Estructura con opciones para el video
struct OptionsVideo
{
OptionsWindow window; // Opciones para la ventana del programa
ScreenVideoMode mode; // Contiene el valor del modo de pantalla completa
ScreenFilter filter; // Filtro usado para el escalado de la imagen
bool v_sync; // Indica si se quiere usar vsync o no
bool integer_scale; // Indica si se va a usar el escalado entero
bool shaders; // Indica si se van a usar shaders para los filtros de video
};
// Estructura para las opciones de musica
struct OptionsMusic
{
bool enabled; // Indica si la musica suena o no
int volume; // Volumen al que suena la música
};
// Estructura para las opciones de sonido
struct OptionsSound
{
bool enabled; // Indica si los sonidos suenan o no
int volume; // Volumen al que suenan los sonidos
};
// Estructura para las opciones de audio
struct OptionsAudio
{
OptionsMusic music; // Opciones para la música
OptionsSound sound; // Opciones para los efectos de sonido
};
// Estructura para las opciones del juego
struct OptionsGame
{
GameDifficulty difficulty; // Dificultad del 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
std::vector<HiScoreEntry> hi_score_table; // Tabla con las mejores puntuaciones
};
// Estructura para los controles del juego
struct OptionsController
{
int index; // Indice en el vector de mandos
int player_id; // Jugador asociado al mando
Uint8 device_type; // Indica si se utilizará teclado o mando o ambos
std::string name; // Nombre del dispositivo
bool plugged; // Indica si el mando se encuentra conectado
std::vector<InputType> inputs; // Listado de inputs
std::vector<SDL_GameControllerButton> buttons; // Listado de botones asignados a cada input
};
// Estructura con todas las opciones de configuración del programa
struct Options
{
OptionsGame game; // Opciones para el propio juego
OptionsVideo video; // Opciones relativas a la clase screen
OptionsAudio audio; // Opciones para el audio
std::vector<OptionsController> controller; // Opciones con las asignaciones del mando para cada jugador
};
// Posiciones dentro de un rectangulo // Posiciones dentro de un rectangulo
struct Zone struct Zone
{ {
@@ -197,80 +100,6 @@ struct Zone
int third_quarter_y; // Anclaje al 75% del eje X int third_quarter_y; // Anclaje al 75% del eje X
}; };
// param.game
struct ParamGame
{
int width; // Ancho de la resolucion nativa del juego
int height; // Alto de la resolucion nativa del juego
int item_size; // Tamaño de los items del juego
Zone play_area; // Rectangulo con la posición de la zona de juego
Zone game_area; // Rectangulo con las dimensiones del juego
int enter_name_seconds; // Duración en segundos para introducir el nombre al finalizar la partida
};
// param.fade
struct ParamFade
{
int num_squares_width; // Cantidad total de cuadraditos en horizontal para el FadeType::RANDOM_SQUARE
int num_squares_height; // Cantidad total de cuadraditos en vertical para el FadeType::RANDOM_SQUARE
int random_squares_delay; // Duración entre cada pintado de cuadrados
int random_squares_mult; // Cantidad de cuadrados que se pintaran cada vez
int post_duration; // Duración final del fade
int venetian_size; // Altura de los rectangulos para FadeType::VENETIAN
};
// param.title
struct ParamTitle
{
int press_start_position; // Posición del texto para empezar a jugar
int title_duration; // Tiempo de inactividad del titulo
int arcade_edition_position; // Posición del bitmap
int title_c_c_position; // Posición del bitmap
};
// param.background
struct ParamBackground
{
Color attenuate_color;
int attenuate_alpha;
};
struct ParamBalloon
{
float grav; // Aceleración en el eje Y. Modifica la velocidad
float vel; // Velocidad inicial que tienen al rebotar contra el suelo
// Constructor
explicit ParamBalloon(float grav_val = 0.0f, float vel_val = 0.0f)
: grav(grav_val), vel(vel_val) {}
};
// Estructura para las opciones de las notificaciones
struct ParamNotification
{
NotifyPosition pos_h; // Ubicación de las notificaciones en pantalla
NotifyPosition pos_v; // Ubicación de las notificaciones en pantalla
bool sound; // Indica si las notificaciones suenan
Color color; // Color de las notificaciones
};
// Estructura para almacenar todos los parámetros del juego
struct Param
{
ParamGame game; // Parametros relacionados con el juego
ParamFade fade; // Parametros para ajustar el fade
SDL_Rect scoreboard; // Posición y tamaño del marcador
ParamTitle title; // Parametros con ajustes para la sección Title
ParamBackground background; // Parametros que afectan a la clase Background
std::vector<ParamBalloon> balloon; // Parametros de velocidad y gravedad de cada tipo de globo
ParamNotification notification; // Opciones para las notificaciones
Param()
{
balloon.reserve(4); // Reservar espacio para 4 elementos
}
};
// Calcula el cuadrado de la distancia entre dos puntos // Calcula el cuadrado de la distancia entre dos puntos
double distanceSquared(int x1, int y1, int x2, int y2); double distanceSquared(int x1, int y1, int x2, int y2);
@@ -312,8 +141,10 @@ std::string trim(const std::string &str);
// Función de suavizado // Función de suavizado
double easeOutQuint(double t); double easeOutQuint(double t);
double easeInQuint(double t);
// Función de suavizado double easeInOutQuint(double t);
double easeInQuad(double t);
double easeOutQuad(double t);
double easeInOutSine(double t); double easeInOutSine(double t);
// Comprueba si una vector contiene una cadena // Comprueba si una vector contiene una cadena