diff --git a/source/animated_sprite.h b/source/animated_sprite.h index 607a380..5a4035a 100644 --- a/source/animated_sprite.h +++ b/source/animated_sprite.h @@ -41,7 +41,7 @@ public: explicit AnimatedSprite(const AnimatedFile *animation); // Destructor - ~AnimatedSprite(); + virtual ~AnimatedSprite(); // Calcula el frame correspondiente a la animación actual void animate(); diff --git a/source/balloon.cpp b/source/balloon.cpp index 7928a43..f74914f 100644 --- a/source/balloon.cpp +++ b/source/balloon.cpp @@ -1,5 +1,5 @@ #include "balloon.h" -#include // for abs +#include // for abs #include "animated_sprite.h" // for AnimatedSprite #include "moving_sprite.h" // for MovingSprite #include "param.h" // for param diff --git a/source/balloon.h b/source/balloon.h index 9fc7389..15ad78f 100644 --- a/source/balloon.h +++ b/source/balloon.h @@ -1,12 +1,12 @@ #pragma once #include // for Uint8, Uint16, Uint32 +#include // for shared_ptr, unique_ptr #include // for string #include // for vector -#include -#include "utils.h" // for Circle -#include "animated_sprite.h" -#include "texture.h" +#include "animated_sprite.h" // for AnimatedSprite +#include "utils.h" // for Circle +class Texture; // Cantidad de elementos del vector con los valores de la deformación del globo al rebotar constexpr int MAX_BOUNCE = 10; diff --git a/source/bullet.cpp b/source/bullet.cpp index f2b1d47..8bc9dcd 100644 --- a/source/bullet.cpp +++ b/source/bullet.cpp @@ -1,7 +1,8 @@ #include "bullet.h" -#include "param.h" // for param -#include "sprite.h" // for Sprite -#include // for std::unique_ptr +#include // for unique_ptr, make_unique, shared_ptr +#include "param.h" // for param +#include "sprite.h" // for Sprite +class Texture; constexpr int BULLET_WIDTH = 12; constexpr int BULLET_HEIGHT = 12; diff --git a/source/bullet.h b/source/bullet.h index 13d960d..45c20ae 100644 --- a/source/bullet.h +++ b/source/bullet.h @@ -1,11 +1,11 @@ #pragma once -#include // for SDL_Rect -#include // for Uint8 -#include // for unique_ptr -#include "sprite.h" // for Sprite -#include "utils.h" // for Circle -#include "texture.h" // lines 9-9 +#include // for SDL_Rect +#include // for Uint8 +#include // for shared_ptr, unique_ptr +#include "sprite.h" // for Sprite +#include "utils.h" // for Circle +class Texture; // Enumeración para los diferentes tipos de balas enum class BulletType diff --git a/source/define_buttons.cpp b/source/define_buttons.cpp index bd9b606..fd60bdd 100644 --- a/source/define_buttons.cpp +++ b/source/define_buttons.cpp @@ -1,10 +1,12 @@ #include "define_buttons.h" -#include "lang.h" // for getText -#include "options.h" // for options -#include "param.h" // for param -#include "section.h" // for name, SectionName, options, SectionOptions -#include "text.h" // for Text -#include "utils.h" // for OptionsController, Options, Param, ParamGame +#include // for move +#include "input.h" // for Input, InputType +#include "lang.h" // for getText +#include "options.h" // for options +#include "param.h" // for param +#include "section.h" // for Name, Options, name, options +#include "text.h" // for Text +#include "utils.h" // for OptionsController, Options, Param, ParamGame // Constructor DefineButtons::DefineButtons(std::unique_ptr text_) diff --git a/source/define_buttons.h b/source/define_buttons.h index 09a9653..385be41 100644 --- a/source/define_buttons.h +++ b/source/define_buttons.h @@ -1,12 +1,13 @@ #pragma once -#include // for SDL_ControllerButtonEvent -#include // for SDL_GameControllerButton -#include // for string, basic_string -#include // for vector -#include "input.h" // for inputs_e -#include "text.h" -#include +#include // for SDL_ControllerButtonEvent +#include // for SDL_GameControllerButton +#include // for shared_ptr, unique_ptr +#include // for string +#include // for vector +class Input; +class Text; +enum class InputType : int; struct DefineButtonsButton { diff --git a/source/director.cpp b/source/director.cpp index 4fb96de..a447cdb 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -5,36 +5,37 @@ #include // for SDL_GetError #include // for SDL_CONTROLLER_BUTTON_B, SDL_CO... #include // for SDL_SetHint, SDL_HINT_RENDER_DR... -#include // for SDL_SCANCODE_DOWN, SDL_SCANCODE_E -#include // for Uint32 +#include // for SDL_SCANCODE_0, SDL_SCANCODE_DOWN +#include // for SDL_bool, Uint32 #include // for SDL_GetTicks -#include // for errno, EACCES, EEXIST, ENAMETOO... -#include // for printf, perror, size_t +#include // for errno, EEXIST, EACCES, ENAMETOO... +#include // for printf, perror #include // for strcmp -#include // for stat, mkdir, S_IRWXU +#include // for mkdir, stat, S_IRWXU #include // for getuid #include // for exit, EXIT_FAILURE, rand, srand #include // for basic_ostream, operator<<, cout -#include // for basic_string, operator+, allocator -#include "asset.h" // for Asset, assetType +#include // for make_unique, unique_ptr +#include // for operator+, allocator, char_traits +#include "asset.h" // for Asset, AssetType #include "dbgtxt.h" // for dbg_init #include "game.h" // for Game, GAME_MODE_DEMO_OFF, GAME_... -#include "global_inputs.h" -#include "hiscore_table.h" // for HiScoreTable -#include "input.h" // for inputs_e, Input -#include "instructions.h" // for Instructions -#include "intro.h" // for Intro -#include "jail_audio.h" // for JA_DeleteMusic, JA_DeleteSound -#include "logo.h" // for Logo -#include "manage_hiscore_table.h" // for ManageHiScoreTable -#include "on_screen_help.h" // for OnScreenHelp -#include "options.h" // for options, loadOptionsFile, saveO... -#include "param.h" // for param, loadParamsFromFile -#include "screen.h" // for Screen -#include "section.h" // for SectionName, name, options, SectionOptions -#include "title.h" // for Title -#include "utils.h" // for MusicFile, SoundFile, opt... -#include +#include "global_inputs.h" // for init +#include "hiscore_table.h" // for HiScoreTable +#include "input.h" // for Input, InputType +#include "instructions.h" // for Instructions +#include "intro.h" // for Intro +#include "jail_audio.h" // for JA_LoadMusic, JA_LoadSound, JA_... +#include "lang.h" // for Code, loadFromFile +#include "logo.h" // for Logo +#include "manage_hiscore_table.h" // for ManageHiScoreTable +#include "on_screen_help.h" // for OnScreenHelp +#include "options.h" // for options, loadOptionsFile, saveO... +#include "param.h" // for param, loadParamsFromFile +#include "screen.h" // for Screen +#include "section.h" // for Name, name, Options, options +#include "title.h" // for Title +#include "utils.h" // for MusicFile, SoundFile, Options #ifndef _WIN32 #include // for getpwuid, passwd diff --git a/source/director.h b/source/director.h index 79afd2d..e0033d1 100644 --- a/source/director.h +++ b/source/director.h @@ -1,11 +1,12 @@ #pragma once -#include // for SDL_Renderer -#include // for SDL_Window -#include // for string, basic_string -#include // for vector -#include "lang.h" // for lang_e -#include "utils.h" // for MusicFile, SoundFile +#include // for SDL_Renderer +#include // for SDL_Window +#include // for string +#include // for vector +namespace lang { enum class Code : int; } +struct MusicFile; +struct SoundFile; // Textos constexpr char WINDOW_CAPTION[] = "Coffee Crisis Arcade Edition"; diff --git a/source/explosions.cpp b/source/explosions.cpp index 1321900..0a662c2 100644 --- a/source/explosions.cpp +++ b/source/explosions.cpp @@ -1,6 +1,7 @@ #include "explosions.h" +#include // for move #include "animated_sprite.h" // for AnimatedSprite -class Texture; +class Texture; // lines 3-3 // Constructor Explosions::Explosions() diff --git a/source/explosions.h b/source/explosions.h index ab07124..66649c9 100644 --- a/source/explosions.h +++ b/source/explosions.h @@ -1,10 +1,10 @@ #pragma once -#include // for string -#include // for vector -#include "animated_sprite.h" -#include -#include "texture.h" +#include // for shared_ptr, unique_ptr +#include // for string +#include // for vector +class AnimatedSprite; +class Texture; struct ExplosionTexture { diff --git a/source/game.cpp b/source/game.cpp index 085fd93..4b9d64e 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -1,39 +1,41 @@ #include "game.h" -#include // for SDL_BLENDMODE_BLEND -#include // for SDLK_1, SDLK_2, SDLK_3, SDLK_h -#include // for SDL_PIXELFORMAT_RGBA8888 -#include // for SDL_RWFromFile, SDL_RWclose, SDL_R... -#include // for SDL_GetTicks -#include // for SDL_WINDOWEVENT_FOCUS_GAINED, SDL_... -#include // for rand -#include // for min -#include // for basic_ifstream -#include // for char_traits, basic_istream, ifstream -#include +#include // for SDL_BLENDMODE_BLEND +#include // for SDL_PollEvent, SDL_Event, SDL_KEYDOWN +#include // for SDLK_1, SDLK_2, SDLK_3, SDLK_4 +#include // for SDL_PIXELFORMAT_RGBA8888 +#include // for SDL_RWFromFile, SDL_RWclose, SDL_R... +#include // for SDL_GetTicks +#include // for SDL_WINDOWEVENT_FOCUS_GAINED, SDL_... +#include // for rand +#include // for min, remove_if +#include // for basic_ostream, operator<<, basic_i... +#include // for cout +#include // for accumulate +#include // for move #include "asset.h" // for Asset #include "background.h" // for Background -#include "balloon.h" // for Balloon, BALLOON_SPEED_1, BALLOON_... -#include "bullet.h" // for Bullet, BulletType::LEFT, BulletType::RIGHT -#include "balloon_formations.h" // for Stage, EnemyFormations, enemyIni... +#include "balloon.h" // for Balloon, BALLOON_SCORE_1, BALLOON_... +#include "balloon_formations.h" // for Stage, BalloonFormationParams, Bal... +#include "bullet.h" // for Bullet, BulletType, BulletMoveStatus #include "explosions.h" // for Explosions -#include "fade.h" // for Fade, FadeType::RANDOM_SQUARE, FADE_VEN... -#include "global_inputs.h" // for globalInputs::check -#include "input.h" // for inputs_e, Input, INPUT_DO_NOT_ALLO... +#include "fade.h" // for Fade, FadeType +#include "global_inputs.h" // for check +#include "input.h" // for InputType, Input, INPUT_DO_NOT_ALL... #include "item.h" // for Item, ITEM_COFFEE_MACHINE, ITEM_CLOCK #include "jail_audio.h" // for JA_PlaySound, JA_DeleteSound, JA_L... #include "lang.h" // for getText #include "manage_hiscore_table.h" // for ManageHiScoreTable #include "options.h" // for options #include "param.h" // for param -#include "player.h" // for Player, PlayerStatus::PLAYING, PLA... -#include "scoreboard.h" // for Scoreboard, scoreboard_modes_e +#include "player.h" // for Player, PlayerStatus +#include "scoreboard.h" // for Scoreboard, ScoreboardMode, SCOREB... #include "screen.h" // for Screen +#include "section.h" // for Name, name, Options, options #include "smart_sprite.h" // for SmartSprite #include "text.h" // for Text, TEXT_CENTER #include "texture.h" // for Texture -#include "dbgtxt.h" -struct JA_Music_t; -struct JA_Sound_t; +struct JA_Music_t; // lines 35-35 +struct JA_Sound_t; // lines 36-36 // Constructor Game::Game(int player_id, int current_stage, bool demo, JA_Music_t *music) diff --git a/source/game.h b/source/game.h index cd92313..3d18e1e 100644 --- a/source/game.h +++ b/source/game.h @@ -1,31 +1,29 @@ #pragma once -#include // for SDL_Event #include // for SDL_Renderer, SDL_Texture #include // for Uint32 +#include // for shared_ptr, unique_ptr #include // for string #include // for vector -#include "section.h" // for SectionOptions +#include "balloon.h" // for Balloon +#include "player.h" // for Player #include "utils.h" // for DemoKeys, Color, HiScoreEntry -#include -#include "asset.h" // lines 11-11 -#include "background.h" // lines 12-12 -#include "balloon.h" // lines 13-13 -#include "bullet.h" // lines 14-14 -#include "balloon_formations.h" // lines 15-15 -#include "explosions.h" // lines 16-16 -#include "fade.h" // lines 17-17 -#include "input.h" // lines 18-18 -#include "item.h" // lines 19-19 -#include "player.h" // lines 20-20 -#include "scoreboard.h" // lines 21-21 -#include "screen.h" // lines 22-22 -#include "smart_sprite.h" // lines 23-23 -#include "text.h" // lines 24-24 -#include "texture.h" // lines 24-24 -enum class BulletType; -struct JA_Music_t; // lines 26-26 -struct JA_Sound_t; // lines 27-27 +class Asset; +class Background; +class BalloonFormations; +class Bullet; +class Explosions; +class Fade; +class Input; +class Item; +class Scoreboard; +class Screen; +class SmartSprite; +class Text; +class Texture; +enum class BulletType; // lines 26-26 +struct JA_Music_t; // lines 27-27 +struct JA_Sound_t; // lines 28-28 // Modo demo constexpr bool GAME_MODE_DEMO_OFF = false; diff --git a/source/game_logo.cpp b/source/game_logo.cpp index a66a5cb..d43240c 100644 --- a/source/game_logo.cpp +++ b/source/game_logo.cpp @@ -1,6 +1,6 @@ #include "game_logo.h" +#include // for SDL_FLIP_HORIZONTAL #include // for max -#include // for basic_string #include "animated_sprite.h" // for AnimatedSprite #include "asset.h" // for Asset #include "jail_audio.h" // for JA_DeleteSound, JA_LoadSound, JA_PlaySound @@ -17,17 +17,17 @@ GameLogo::GameLogo(int x, int y) coffee_texture_(std::make_shared(Screen::get()->getRenderer(), Asset::get()->get("title_coffee.png"))), crisis_texture_(std::make_shared(Screen::get()->getRenderer(), Asset::get()->get("title_crisis.png"))), arcade_edition_texture_(std::make_shared(Screen::get()->getRenderer(), Asset::get()->get("title_arcade_edition.png"))), - + dust_left_sprite_(std::make_unique(dust_texture_, Asset::get()->get("title_dust.ani"))), dust_right_sprite_(std::make_unique(dust_texture_, Asset::get()->get("title_dust.ani"))), - + coffee_sprite_(std::make_unique(coffee_texture_)), crisis_sprite_(std::make_unique(crisis_texture_)), - + arcade_edition_sprite_(std::make_unique((param.game.width - arcade_edition_texture_->getWidth()) / 2, param.title.arcade_edition_position, arcade_edition_texture_->getWidth(), arcade_edition_texture_->getHeight(), arcade_edition_texture_)), - + crash_sound_(JA_LoadSound(Asset::get()->get("title.wav").c_str())), - + x_(x), y_(y) { diff --git a/source/game_logo.h b/source/game_logo.h index 878db66..7904d9a 100644 --- a/source/game_logo.h +++ b/source/game_logo.h @@ -1,13 +1,11 @@ #pragma once -#include // for SDL_Renderer -#include -#include "texture.h" -#include "animated_sprite.h" -#include "smart_sprite.h" -#include "sprite.h" - -struct JA_Sound_t; +#include // for unique_ptr, shared_ptr +class AnimatedSprite; +class SmartSprite; +class Sprite; +class Texture; +struct JA_Sound_t; // lines 10-10 // Clase GameLogo class GameLogo diff --git a/source/hiscore_table.cpp b/source/hiscore_table.cpp index 1fdb6f7..ae6624b 100644 --- a/source/hiscore_table.cpp +++ b/source/hiscore_table.cpp @@ -1,5 +1,6 @@ #include "hiscore_table.h" #include // for SDL_BLENDMODE_BLEND +#include // for SDL_PollEvent, SDL_Event, SDL_QUIT #include // for SDL_PIXELFORMAT_RGBA8888 #include // for SDL_GetTicks #include // for SDL_WINDOWEVENT_SIZE_CHANGED @@ -7,15 +8,17 @@ #include // for vector #include "asset.h" // for Asset #include "background.h" // for Background -#include "global_inputs.h" // for globalInputs::check +#include "fade.h" // for Fade, FadeMode, FadeType +#include "global_inputs.h" // for check #include "input.h" // for Input #include "jail_audio.h" // for JA_GetMusicState, JA_Music_state #include "lang.h" // for getText #include "options.h" // for options #include "param.h" // for param #include "screen.h" // for Screen -#include "text.h" // for Text, TEXT_CENTER, TEXT_SHADOW, TEXT_COLOR -#include "utils.h" // for Param, ParamGame, HiScoreEntry +#include "section.h" // for Name, name, Options, options +#include "text.h" // for Text, TEXT_CENTER, TEXT_SHADOW, TEXT... +#include "utils.h" // for Param, ParamGame, Color, HiScoreEntry // Constructor HiScoreTable::HiScoreTable(JA_Music_t *music) diff --git a/source/hiscore_table.h b/source/hiscore_table.h index dac0b4a..a569d66 100644 --- a/source/hiscore_table.h +++ b/source/hiscore_table.h @@ -1,15 +1,15 @@ #pragma once -#include // for SDL_Event #include // for SDL_Rect #include // for SDL_Renderer, SDL_Texture #include // for Uint16, Uint32 -#include -#include // for string -#include "fade.h" -#include "section.h" // for SectionOptions -#include "background.h" -#include "text.h" +#include // for unique_ptr +#include // for string +class Background; +class Fade; +class Text; +enum class FadeMode : Uint8; +struct JA_Music_t; // lines 14-14 struct JA_Music_t; diff --git a/source/moving_sprite.h b/source/moving_sprite.h index d77d25f..6c501f2 100644 --- a/source/moving_sprite.h +++ b/source/moving_sprite.h @@ -41,6 +41,9 @@ public: explicit MovingSprite(float x = 0, float y = 0, int w = 0, int h = 0, float velx = 0, float vely = 0, float accelx = 0, float accely = 0, std::shared_ptr texture = nullptr); explicit MovingSprite(std::shared_ptr texture = nullptr); + // Destructor + virtual ~MovingSprite() = default; + // Mueve el sprite void move(); diff --git a/source/sprite.h b/source/sprite.h index bd5300a..476925a 100644 --- a/source/sprite.h +++ b/source/sprite.h @@ -20,7 +20,7 @@ public: explicit Sprite(std::shared_ptr texture = nullptr); // Destructor - ~Sprite() = default; + virtual ~Sprite() = default; // Muestra el sprite por pantalla virtual void render();