Afegits destructors virtuals en les classes Sprite
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "balloon.h"
|
||||
#include <math.h> // for abs
|
||||
#include <cmath> // for abs
|
||||
#include "animated_sprite.h" // for AnimatedSprite
|
||||
#include "moving_sprite.h" // for MovingSprite
|
||||
#include "param.h" // for param
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL_stdinc.h> // for Uint8, Uint16, Uint32
|
||||
#include <memory> // for shared_ptr, unique_ptr
|
||||
#include <string> // for string
|
||||
#include <vector> // for vector
|
||||
#include <memory>
|
||||
#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;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include "bullet.h"
|
||||
#include "param.h" // for param
|
||||
#include "sprite.h" // for Sprite
|
||||
#include <memory> // for std::unique_ptr
|
||||
#include <memory> // 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;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL_rect.h> // for SDL_Rect
|
||||
#include <SDL2/SDL_stdinc.h> // for Uint8
|
||||
#include <memory> // for unique_ptr
|
||||
#include "sprite.h" // for Sprite
|
||||
#include "utils.h" // for Circle
|
||||
#include "texture.h" // lines 9-9
|
||||
#include <SDL2/SDL_rect.h> // for SDL_Rect
|
||||
#include <SDL2/SDL_stdinc.h> // for Uint8
|
||||
#include <memory> // 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
|
||||
|
||||
@@ -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 <utility> // 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> text_)
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL_events.h> // for SDL_ControllerButtonEvent
|
||||
#include <SDL2/SDL_gamecontroller.h> // for SDL_GameControllerButton
|
||||
#include <string> // for string, basic_string
|
||||
#include <vector> // for vector
|
||||
#include "input.h" // for inputs_e
|
||||
#include "text.h"
|
||||
#include <memory>
|
||||
#include <SDL2/SDL_events.h> // for SDL_ControllerButtonEvent
|
||||
#include <SDL2/SDL_gamecontroller.h> // for SDL_GameControllerButton
|
||||
#include <memory> // for shared_ptr, unique_ptr
|
||||
#include <string> // for string
|
||||
#include <vector> // for vector
|
||||
class Input;
|
||||
class Text;
|
||||
enum class InputType : int;
|
||||
|
||||
struct DefineButtonsButton
|
||||
{
|
||||
|
||||
@@ -5,36 +5,37 @@
|
||||
#include <SDL2/SDL_error.h> // for SDL_GetError
|
||||
#include <SDL2/SDL_gamecontroller.h> // for SDL_CONTROLLER_BUTTON_B, SDL_CO...
|
||||
#include <SDL2/SDL_hints.h> // for SDL_SetHint, SDL_HINT_RENDER_DR...
|
||||
#include <SDL2/SDL_scancode.h> // for SDL_SCANCODE_DOWN, SDL_SCANCODE_E
|
||||
#include <SDL2/SDL_stdinc.h> // for Uint32
|
||||
#include <SDL2/SDL_scancode.h> // for SDL_SCANCODE_0, SDL_SCANCODE_DOWN
|
||||
#include <SDL2/SDL_stdinc.h> // for SDL_bool, Uint32
|
||||
#include <SDL2/SDL_timer.h> // for SDL_GetTicks
|
||||
#include <errno.h> // for errno, EACCES, EEXIST, ENAMETOO...
|
||||
#include <stdio.h> // for printf, perror, size_t
|
||||
#include <errno.h> // for errno, EEXIST, EACCES, ENAMETOO...
|
||||
#include <stdio.h> // for printf, perror
|
||||
#include <string.h> // for strcmp
|
||||
#include <sys/stat.h> // for stat, mkdir, S_IRWXU
|
||||
#include <sys/stat.h> // for mkdir, stat, S_IRWXU
|
||||
#include <unistd.h> // for getuid
|
||||
#include <cstdlib> // for exit, EXIT_FAILURE, rand, srand
|
||||
#include <iostream> // for basic_ostream, operator<<, cout
|
||||
#include <string> // for basic_string, operator+, allocator
|
||||
#include "asset.h" // for Asset, assetType
|
||||
#include <memory> // for make_unique, unique_ptr
|
||||
#include <string> // 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 <memory>
|
||||
#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 <pwd.h> // for getpwuid, passwd
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL_render.h> // for SDL_Renderer
|
||||
#include <SDL2/SDL_video.h> // for SDL_Window
|
||||
#include <string> // for string, basic_string
|
||||
#include <vector> // for vector
|
||||
#include "lang.h" // for lang_e
|
||||
#include "utils.h" // for MusicFile, SoundFile
|
||||
#include <SDL2/SDL_render.h> // for SDL_Renderer
|
||||
#include <SDL2/SDL_video.h> // for SDL_Window
|
||||
#include <string> // for string
|
||||
#include <vector> // for vector
|
||||
namespace lang { enum class Code : int; }
|
||||
struct MusicFile;
|
||||
struct SoundFile;
|
||||
|
||||
// Textos
|
||||
constexpr char WINDOW_CAPTION[] = "Coffee Crisis Arcade Edition";
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "explosions.h"
|
||||
#include <utility> // for move
|
||||
#include "animated_sprite.h" // for AnimatedSprite
|
||||
class Texture;
|
||||
class Texture; // lines 3-3
|
||||
|
||||
// Constructor
|
||||
Explosions::Explosions()
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <string> // for string
|
||||
#include <vector> // for vector
|
||||
#include "animated_sprite.h"
|
||||
#include <memory>
|
||||
#include "texture.h"
|
||||
#include <memory> // for shared_ptr, unique_ptr
|
||||
#include <string> // for string
|
||||
#include <vector> // for vector
|
||||
class AnimatedSprite;
|
||||
class Texture;
|
||||
|
||||
struct ExplosionTexture
|
||||
{
|
||||
|
||||
@@ -1,39 +1,41 @@
|
||||
#include "game.h"
|
||||
#include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND
|
||||
#include <SDL2/SDL_keycode.h> // for SDLK_1, SDLK_2, SDLK_3, SDLK_h
|
||||
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888
|
||||
#include <SDL2/SDL_rwops.h> // for SDL_RWFromFile, SDL_RWclose, SDL_R...
|
||||
#include <SDL2/SDL_timer.h> // for SDL_GetTicks
|
||||
#include <SDL2/SDL_video.h> // for SDL_WINDOWEVENT_FOCUS_GAINED, SDL_...
|
||||
#include <stdlib.h> // for rand
|
||||
#include <algorithm> // for min
|
||||
#include <fstream> // for basic_ifstream
|
||||
#include <iostream> // for char_traits, basic_istream, ifstream
|
||||
#include <numeric>
|
||||
#include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND
|
||||
#include <SDL2/SDL_events.h> // for SDL_PollEvent, SDL_Event, SDL_KEYDOWN
|
||||
#include <SDL2/SDL_keycode.h> // for SDLK_1, SDLK_2, SDLK_3, SDLK_4
|
||||
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888
|
||||
#include <SDL2/SDL_rwops.h> // for SDL_RWFromFile, SDL_RWclose, SDL_R...
|
||||
#include <SDL2/SDL_timer.h> // for SDL_GetTicks
|
||||
#include <SDL2/SDL_video.h> // for SDL_WINDOWEVENT_FOCUS_GAINED, SDL_...
|
||||
#include <stdlib.h> // for rand
|
||||
#include <algorithm> // for min, remove_if
|
||||
#include <fstream> // for basic_ostream, operator<<, basic_i...
|
||||
#include <iostream> // for cout
|
||||
#include <numeric> // for accumulate
|
||||
#include <utility> // 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)
|
||||
|
||||
@@ -1,31 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL_events.h> // for SDL_Event
|
||||
#include <SDL2/SDL_render.h> // for SDL_Renderer, SDL_Texture
|
||||
#include <SDL2/SDL_stdinc.h> // for Uint32
|
||||
#include <memory> // for shared_ptr, unique_ptr
|
||||
#include <string> // for string
|
||||
#include <vector> // for vector
|
||||
#include "section.h" // for SectionOptions
|
||||
#include "balloon.h" // for Balloon
|
||||
#include "player.h" // for Player
|
||||
#include "utils.h" // for DemoKeys, Color, HiScoreEntry
|
||||
#include <memory>
|
||||
#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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "game_logo.h"
|
||||
#include <SDL2/SDL_render.h> // for SDL_FLIP_HORIZONTAL
|
||||
#include <algorithm> // for max
|
||||
#include <string> // 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<Texture>(Screen::get()->getRenderer(), Asset::get()->get("title_coffee.png"))),
|
||||
crisis_texture_(std::make_shared<Texture>(Screen::get()->getRenderer(), Asset::get()->get("title_crisis.png"))),
|
||||
arcade_edition_texture_(std::make_shared<Texture>(Screen::get()->getRenderer(), Asset::get()->get("title_arcade_edition.png"))),
|
||||
|
||||
|
||||
dust_left_sprite_(std::make_unique<AnimatedSprite>(dust_texture_, Asset::get()->get("title_dust.ani"))),
|
||||
dust_right_sprite_(std::make_unique<AnimatedSprite>(dust_texture_, Asset::get()->get("title_dust.ani"))),
|
||||
|
||||
|
||||
coffee_sprite_(std::make_unique<SmartSprite>(coffee_texture_)),
|
||||
crisis_sprite_(std::make_unique<SmartSprite>(crisis_texture_)),
|
||||
|
||||
|
||||
arcade_edition_sprite_(std::make_unique<Sprite>((param.game.width - arcade_edition_texture_->getWidth()) / 2, param.title.arcade_edition_position, arcade_edition_texture_->getWidth(), arcade_edition_texture_->getHeight(), arcade_edition_texture_)),
|
||||
|
||||
|
||||
crash_sound_(JA_LoadSound(Asset::get()->get("title.wav").c_str())),
|
||||
|
||||
|
||||
x_(x),
|
||||
y_(y)
|
||||
{
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL_render.h> // for SDL_Renderer
|
||||
#include <memory>
|
||||
#include "texture.h"
|
||||
#include "animated_sprite.h"
|
||||
#include "smart_sprite.h"
|
||||
#include "sprite.h"
|
||||
|
||||
struct JA_Sound_t;
|
||||
#include <memory> // for unique_ptr, shared_ptr
|
||||
class AnimatedSprite;
|
||||
class SmartSprite;
|
||||
class Sprite;
|
||||
class Texture;
|
||||
struct JA_Sound_t; // lines 10-10
|
||||
|
||||
// Clase GameLogo
|
||||
class GameLogo
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "hiscore_table.h"
|
||||
#include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND
|
||||
#include <SDL2/SDL_events.h> // for SDL_PollEvent, SDL_Event, SDL_QUIT
|
||||
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888
|
||||
#include <SDL2/SDL_timer.h> // for SDL_GetTicks
|
||||
#include <SDL2/SDL_video.h> // for SDL_WINDOWEVENT_SIZE_CHANGED
|
||||
@@ -7,15 +8,17 @@
|
||||
#include <vector> // 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)
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL_events.h> // for SDL_Event
|
||||
#include <SDL2/SDL_rect.h> // for SDL_Rect
|
||||
#include <SDL2/SDL_render.h> // for SDL_Renderer, SDL_Texture
|
||||
#include <SDL2/SDL_stdinc.h> // for Uint16, Uint32
|
||||
#include <memory>
|
||||
#include <string> // for string
|
||||
#include "fade.h"
|
||||
#include "section.h" // for SectionOptions
|
||||
#include "background.h"
|
||||
#include "text.h"
|
||||
#include <memory> // for unique_ptr
|
||||
#include <string> // for string
|
||||
class Background;
|
||||
class Fade;
|
||||
class Text;
|
||||
enum class FadeMode : Uint8;
|
||||
struct JA_Music_t; // lines 14-14
|
||||
|
||||
struct JA_Music_t;
|
||||
|
||||
|
||||
@@ -41,6 +41,9 @@ public:
|
||||
explicit MovingSprite(float x = 0, float y = 0, int w = 0, int h = 0, float velx = 0, float vely = 0, float accelx = 0, float accely = 0, std::shared_ptr<Texture> texture = nullptr);
|
||||
explicit MovingSprite(std::shared_ptr<Texture> texture = nullptr);
|
||||
|
||||
// Destructor
|
||||
virtual ~MovingSprite() = default;
|
||||
|
||||
// Mueve el sprite
|
||||
void move();
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
explicit Sprite(std::shared_ptr<Texture> texture = nullptr);
|
||||
|
||||
// Destructor
|
||||
~Sprite() = default;
|
||||
virtual ~Sprite() = default;
|
||||
|
||||
// Muestra el sprite por pantalla
|
||||
virtual void render();
|
||||
|
||||
Reference in New Issue
Block a user