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

View File

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

View File

@@ -1,12 +1,9 @@
#include "asset.h"
#include "utils.h"
#include <SDL2/SDL_rwops.h> // para SDL_RWFromFile, SDL_RWclose, SDL_RWops
#include <SDL2/SDL_stdinc.h> // para SDL_max
#include <stddef.h> // para size_t
#include <iostream> // para basic_ostream, operator<<, cout, endl
#include <fstream>
#include <string>
#include <algorithm> // Para std::find_if
#include <algorithm> // Para find_if, max
#include <fstream> // Para basic_ostream, operator<<, basic_ifstream, endl
#include <iostream> // Para cout
#include <string> // Para allocator, char_traits, string, operator+, oper...
#include "utils.h" // Para getFileName, printWithDots
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
Asset *Asset::asset_ = nullptr;

View File

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

View File

@@ -1,11 +1,10 @@
#include "balloon.h"
#include <cmath> // para abs
#include <algorithm> // para clamp
#include "animated_sprite.h" // para SpriteAnimated
#include "moving_sprite.h" // para MovingSprite
#include "param.h" // para param
#include "sprite.h" // para Sprite
#include "texture.h" // para Texture
#include <algorithm> // Para clamp
#include <cmath> // Para fabs
#include "animated_sprite.h" // Para AnimatedSprite
#include "param.h" // Para Param, param, ParamBalloon, ParamGame
#include "sprite.h" // Para Sprite
#include "texture.h" // Para Texture
// 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)

View File

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

View File

@@ -1,8 +1,9 @@
#include "bullet.h"
#include <memory> // para unique_ptr, make_unique, shared_ptr
#include "param.h" // para param
#include "sprite.h" // para Sprite
class Texture;
#include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <memory> // Para unique_ptr, make_unique, shared_ptr
#include "param.h" // Para Param, ParamGame, param
#include "sprite.h" // Para Sprite
class Texture; // lines 5-5
// Constructor
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
#include <SDL2/SDL_rect.h> // para SDL_Rect
#include <SDL2/SDL_stdinc.h> // para Uint8
#include <memory> // para shared_ptr, unique_ptr
#include "sprite.h" // para Sprite
#include "utils.h" // para Circle
class Texture;
#include <SDL2/SDL_stdinc.h> // Para Uint8
#include <memory> // Para shared_ptr, unique_ptr
#include "sprite.h" // Para Sprite
#include "utils.h" // Para Circle
class Texture; // lines 8-8
// Tipos de balas
enum class BulletType : Uint8

View File

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

View File

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

View File

@@ -1,15 +1,12 @@
#pragma once
#include <SDL2/SDL_render.h> // para SDL_Renderer
#include <SDL2/SDL_video.h> // para SDL_Window
#include <string> // para string
#include <vector> // para vector
#include <SDL2/SDL_render.h> // Para SDL_Renderer
#include <SDL2/SDL_video.h> // Para SDL_Window
#include <string> // Para string
namespace lang
{
enum class Code : int;
}
struct ResourceMusic;
struct ResourceSound;
} // lines 9-9
// Textos
constexpr char WINDOW_CAPTION[] = "Coffee Crisis Arcade Edition";

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,16 +1,15 @@
#pragma once
#include <SDL2/SDL_rect.h> // para SDL_Point, SDL_Rect
#include <SDL2/SDL_render.h> // para SDL_Texture, SDL_Renderer
#include <SDL2/SDL_stdinc.h> // para Uint32
#include <memory> // para unique_ptr, shared_ptr
#include <vector> // para vector
class Fade;
class Sprite;
class Text;
class Texture;
class TiledBG;
struct JA_Music_t; // lines 14-14
#include <SDL2/SDL_rect.h> // Para SDL_Point, SDL_Rect
#include <SDL2/SDL_render.h> // Para SDL_Texture, SDL_Renderer
#include <SDL2/SDL_stdinc.h> // Para Uint32
#include <memory> // Para unique_ptr, shared_ptr
#include <vector> // Para vector
class Fade; // lines 8-8
class Sprite; // lines 9-9
class Text; // lines 10-10
class Texture; // lines 11-11
class TiledBG; // lines 12-12
/*
Esta clase gestiona un estado del programa. Se encarga de poner en pantalla

View File

@@ -1,23 +1,21 @@
#include "intro.h"
#include <SDL2/SDL_events.h> // para SDL_PollEvent, SDL_Event, SDL_QUIT, SDL...
#include <SDL2/SDL_timer.h> // para SDL_GetTicks
#include <SDL2/SDL_video.h> // para SDL_WINDOWEVENT_SIZE_CHANGED
#include <utility> // para move
#include "asset.h" // para Asset
#include "global_inputs.h" // para check
#include "input.h" // para Input
#include "jail_audio.h" // para JA_StopMusic, JA_PlayMusic
#include "lang.h" // para getText
#include "param.h" // para param
#include "resource.h" // para Resource
#include "screen.h" // para Screen
#include "section.h" // para Name, name, Options, options
#include "smart_sprite.h" // para SpriteSmart
#include "text.h" // para Text
#include "texture.h" // para Texture
#include "utils.h" // para Param, ParamGame, Zone, BLOCK, Color
#include "writer.h" // para Writer
struct JA_Music_t; // lines 19-19
#include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_QUIT, SDL...
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <SDL2/SDL_video.h> // Para SDL_WINDOWEVENT_SIZE_CHANGED
#include <utility> // Para move
#include "global_inputs.h" // Para check
#include "input.h" // Para Input
#include "jail_audio.h" // Para JA_StopMusic, JA_PlayMusic
#include "lang.h" // Para getText
#include "param.h" // Para Param, ParamGame, param
#include "resource.h" // Para Resource
#include "screen.h" // Para Screen
#include "section.h" // Para Name, name, Options, options
#include "smart_sprite.h" // Para SmartSprite
#include "text.h" // Para Text
#include "texture.h" // Para Texture
#include "utils.h" // Para Zone, BLOCK, Color, bg_color
#include "writer.h" // Para Writer
// Constructor
Intro::Intro()

View File

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

View File

@@ -1,19 +1,17 @@
#include "logo.h"
#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_video.h> // para SDL_WINDOWEVENT_SIZE_CHANGED
#include <utility> // para move
#include "asset.h" // para Asset
#include "global_inputs.h" // para check
#include "input.h" // para Input
#include "jail_audio.h" // para JA_StopMusic
#include "param.h" // para param
#include "resource.h" // para Resource
#include "screen.h" // para Screen
#include "section.h" // para Name, name, Options, options
#include "sprite.h" // para Sprite
#include "texture.h" // para Texture
#include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_QUIT, SDL...
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <SDL2/SDL_video.h> // Para SDL_WINDOWEVENT_SIZE_CHANGED
#include <utility> // Para move
#include "global_inputs.h" // Para check
#include "input.h" // Para Input
#include "jail_audio.h" // Para JA_StopMusic
#include "param.h" // Para Param, ParamGame, param
#include "resource.h" // Para Resource
#include "screen.h" // Para Screen
#include "section.h" // Para Name, name, Options, options
#include "sprite.h" // Para Sprite
#include "texture.h" // Para Texture
// Constructor
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 "director.h" // para Director
#include <memory> // Para make_unique, unique_ptr
#include "director.h" // Para Director
int main(int argc, char *argv[])
{

View File

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

View File

@@ -2,7 +2,6 @@
#include <string> // para string
#include <vector> // para vector
struct HiScoreEntry;
/*
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
*/
// 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
class ManageHiScoreTable
{

View File

@@ -1,5 +1,6 @@
#include "moving_sprite.h"
#include "texture.h" // para Texture
#include <algorithm> // Para max
#include "texture.h" // Para Texture
// Constructor
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
#include <SDL2/SDL_rect.h> // para SDL_Rect, SDL_Point
#include <SDL2/SDL_render.h> // para SDL_RendererFlip
#include <SDL2/SDL_stdinc.h> // para Uint16
#include <memory> // para shared_ptr
#include "sprite.h" // para Sprite
class Texture;
#include <SDL2/SDL_rect.h> // Para SDL_Rect, SDL_Point
#include <SDL2/SDL_render.h> // Para SDL_RendererFlip
#include <memory> // Para shared_ptr
#include "sprite.h" // Para Sprite
class Texture; // lines 8-8
// Clase MovingSprite. Añade movimiento y efectos de rotación, zoom y flip al sprite
class MovingSprite : public Sprite

View File

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

View File

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

View File

@@ -1,7 +1,93 @@
#pragma once
#include <string> // para string
struct Options;
#include <SDL2/SDL_gamecontroller.h> // Para SDL_GameControllerButton
#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
extern Options options;

View File

@@ -1,7 +1,80 @@
#pragma once
#include <string> // para string
struct Param;
#include <SDL2/SDL_rect.h> // Para SDL_Rect
#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;

View File

@@ -1,6 +1,11 @@
#include "path_sprite.h"
#include "utils.h"
class Texture;
#include <bits/std_abs.h> // Para abs
#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
PathSprite::PathSprite(std::shared_ptr<Texture> texture)
@@ -16,57 +21,49 @@ void PathSprite::update()
}
}
// Añade un recorrido vertical
void PathSprite::addVerticalPath(SDL_Point start, SDL_Point end, int steps, int waiting_counter)
// Añade un recorrido
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
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
// Añade un recorrido
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
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;
v.reserve(steps);
for (int i = 0; i < steps; ++i)
{
double t = static_cast<double>(i) / steps;
double value = static_cast<double>(start.x) + (end.x - start.x) * easeOutQuint(t);
v.emplace_back(SDL_Point{static_cast<int>(value), start.y});
double t = static_cast<double>(i) / (steps - 1);
double value = start + (end - start) * easingFunction(t);
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;
@@ -84,7 +81,7 @@ void PathSprite::moveThroughCurrentPath()
auto &path = paths_.at(current_path_);
// 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);
// Comprobar si ha terminado el recorrido
@@ -99,11 +96,14 @@ void PathSprite::moveThroughCurrentPath()
}
// Comprobar si ha terminado la espera
if (path.on_destination)
{
if (path.waiting_counter == 0)
path.finished = true;
else if (path.on_destination)
else
--path.waiting_counter;
}
}
// Cambia de recorrido o finaliza
void PathSprite::goToNextPathOrDie()

View File

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

View File

@@ -1,14 +1,15 @@
#include "player.h"
#include <SDL2/SDL_render.h> // para SDL_FLIP_HORIZONTAL, SDL_FLIP_NONE, SDL...
#include <SDL2/SDL_timer.h> // para SDL_GetTicks
#include <stdlib.h> // para rand
#include <algorithm> // para max, min
#include "animated_sprite.h" // para SpriteAnimated
#include "input.h" // para inputs_e
#include "param.h" // para param
#include "texture.h" // para Texture
#include "scoreboard.h" // para Texture
#include "options.h"
#include <SDL2/SDL_render.h> // Para SDL_FLIP_HORIZONTAL, SDL_FLIP_NONE
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <stdlib.h> // Para rand
#include <algorithm> // Para max, min
#include "animated_sprite.h" // Para AnimatedSprite
#include "input.h" // Para InputType
#include "manage_hiscore_table.h" // Para HiScoreEntry
#include "options.h" // Para Options, OptionsGame, options
#include "param.h" // Para Param, ParamGame, param
#include "scoreboard.h" // Para Scoreboard, ScoreboardMode
#include "texture.h" // Para Texture
// 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)

View File

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

View File

@@ -1,9 +1,12 @@
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include "resource.h"
#include "asset.h"
#include "screen.h"
#include <algorithm> // Para find_if
#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
Resource *Resource::resource_ = nullptr;

View File

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

View File

@@ -1,17 +1,15 @@
#include "scoreboard.h"
#include <SDL2/SDL_blendmode.h> // para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_pixels.h> // para SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_timer.h> // para SDL_GetTicks
#include <math.h> // para roundf
#include <iomanip>
#include <sstream>
#include "asset.h" // para Asset
#include "lang.h" // para getText
#include "resource.h" // para Resource
#include "screen.h"
#include "sprite.h" // para Sprite
#include "text.h" // para Text
#include "texture.h" // para Texture
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <math.h> // Para roundf
#include <iomanip> // Para operator<<, setfill, setw
#include <sstream> // Para basic_ostream, basic_ostringstream
#include "lang.h" // Para getText
#include "resource.h" // Para Resource
#include "screen.h" // Para Screen
#include "sprite.h" // Para Sprite
#include "text.h" // Para Text
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
Scoreboard *Scoreboard::scoreboard_ = nullptr;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,26 +1,29 @@
#include "title.h"
#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_rect.h> // para SDL_Rect
#include <SDL2/SDL_render.h> // para SDL_Renderer
#include <SDL2/SDL_timer.h> // para SDL_GetTicks
#include <string> // para char_traits, operator+, to_string, bas...
#include <utility> // para move
#include <vector> // para vector
#include "asset.h" // para Asset
#include "global_inputs.h" // para check
#include "input.h" // para Input, InputType, INPUT_DO_NOT_ALLOW_R...
#include "jail_audio.h" // para JA_GetMusicState, JA_Music_state, JA_P...
#include "lang.h" // para getText
#include "notifier.h" // para Notifier
#include "options.h" // para options
#include "param.h" // para param
#include "resource.h" // para Resource
#include "screen.h" // para Screen
#include "section.h" // para Options, options, Name, name
#include "texture.h" // para Texture
#include "utils.h" // para Param, OptionsController, Color, Param...
struct JA_Music_t; // lines 17-17
#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_rect.h> // Para SDL_Rect
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <string> // Para char_traits, operator+, to_string, bas...
#include <utility> // Para move
#include <vector> // Para vector
#include "define_buttons.h" // Para DefineButtons
#include "fade.h" // Para Fade, FadeType
#include "game_logo.h" // Para GameLogo
#include "global_inputs.h" // Para check
#include "input.h" // Para Input, InputType, INPUT_DO_NOT_ALLOW_R...
#include "jail_audio.h" // Para JA_GetMusicState, JA_Music_state, JA_P...
#include "lang.h" // Para getText
#include "notifier.h" // Para Notifier
#include "options.h" // Para OptionsController, Options, options
#include "param.h" // Para Param, param, ParamGame, ParamTitle
#include "resource.h" // Para Resource
#include "screen.h" // Para Screen
#include "section.h" // Para Options, options, name, Name
#include "sprite.h" // Para Sprite
#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
Title::Title()

View File

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

View File

@@ -1,13 +1,13 @@
#include "utils.h"
#include <filesystem>
#include <iostream>
#include <string>
#include <algorithm> // para min, clamp, find_if_not, transform
#include <cctype> // para tolower, isspace
#include <cmath> // para cos, pow, M_PI
#include <compare> // para operator<
struct JA_Music_t; // lines 7-7
struct JA_Sound_t; // lines 8-8
#include <SDL2/SDL_rwops.h> // Para SDL_RWFromFile, SDL_RWclose, SDL_RWread
#include <algorithm> // Para min, clamp, find_if_not, find, transform
#include <cctype> // Para tolower, isspace
#include <cmath> // Para cos, pow, M_PI
#include <compare> // Para operator<
#include <filesystem> // Para path
#include <iostream> // Para basic_ostream, cout, basic_ios, endl, ios
#include <stdexcept> // Para runtime_error
#include <string> // Para basic_string, string, char_traits, opera...
// Variables
Overrides overrides = Overrides();
@@ -182,6 +182,30 @@ double easeOutQuint(double t)
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
double easeInOutSine(double t)
{

View File

@@ -1,34 +1,16 @@
#pragma once
#include <SDL2/SDL_gamecontroller.h> // para SDL_GameControllerButton
#include <SDL2/SDL_rect.h> // para SDL_Rect, SDL_Point
#include <SDL2/SDL_render.h> // para SDL_Renderer
#include <SDL2/SDL_stdinc.h> // para Uint8
#include <stdint.h> // para int32_t
#include <string> // para string
#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
#include <SDL2/SDL_rect.h> // Para SDL_Rect, SDL_Point
#include <SDL2/SDL_render.h> // Para SDL_Renderer
#include <SDL2/SDL_stdinc.h> // Para Uint8
#include <stdint.h> // Para int32_t
#include <string> // Para string
#include <vector> // Para vector
// Constantes
constexpr int BLOCK = 8;
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
struct Overrides
{
@@ -74,17 +56,6 @@ enum class NotifyPosition
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
{
Uint8 left;
@@ -117,74 +88,6 @@ struct Demo
: 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
struct Zone
{
@@ -197,80 +100,6 @@ struct Zone
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
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
double easeOutQuint(double t);
// Función de suavizado
double easeInQuint(double t);
double easeInOutQuint(double t);
double easeInQuad(double t);
double easeOutQuad(double t);
double easeInOutSine(double t);
// Comprueba si una vector contiene una cadena