diff --git a/cppcheck-result-warning-style-performance b/cppcheck-result-warning-style-performance index 48590d1..19ad152 100644 --- a/cppcheck-result-warning-style-performance +++ b/cppcheck-result-warning-style-performance @@ -1,210 +1,36 @@ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.h:14:11: warning: The class 'MovingSprite' defines member variable with name 'x_' also defined in its parent class 'Sprite'. [duplInheritedMember] - float x_; // Posición en el eje X - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/sprite.h:11:9: note: Parent variable 'Sprite::x_' - int x_; // Posición en el eje X donde dibujar el sprite - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.h:14:11: note: Derived variable 'MovingSprite::x_' - float x_; // Posición en el eje X - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.h:15:11: warning: The class 'MovingSprite' defines member variable with name 'y_' also defined in its parent class 'Sprite'. [duplInheritedMember] - float y_; // Posición en el eje Y - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/sprite.h:12:9: note: Parent variable 'Sprite::y_' - int y_; // Posición en el eje Y donde dibujar el sprite - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.h:15:11: note: Derived variable 'MovingSprite::y_' - float y_; // Posición en el eje Y - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.h:51:10: warning: The class 'MovingSprite' defines member function with name 'render' also defined in its parent class 'Sprite'. [duplInheritedMember] - void render(); - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/sprite.h:30:10: note: Parent function 'Sprite::render' - void render(); - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.h:51:10: note: Derived function 'MovingSprite::render' - void render(); - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.h:54:11: warning: The class 'MovingSprite' defines member function with name 'getPosX' also defined in its parent class 'Sprite'. [duplInheritedMember] +/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.h:60:11: warning: The class 'MovingSprite' defines member function with name 'getPosX' also defined in its parent class 'Sprite'. [duplInheritedMember] float getPosX() const; ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/sprite.h:33:9: note: Parent function 'Sprite::getPosX' +/home/sergio/gitea/coffee_crisis_arcade_edition/source/sprite.h:29:9: note: Parent function 'Sprite::getPosX' int getPosX() const; ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.h:54:11: note: Derived function 'MovingSprite::getPosX' +/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.h:60:11: note: Derived function 'MovingSprite::getPosX' float getPosX() const; ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.h:55:11: warning: The class 'MovingSprite' defines member function with name 'getPosY' also defined in its parent class 'Sprite'. [duplInheritedMember] +/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.h:61:11: warning: The class 'MovingSprite' defines member function with name 'getPosY' also defined in its parent class 'Sprite'. [duplInheritedMember] float getPosY() const; ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/sprite.h:34:9: note: Parent function 'Sprite::getPosY' +/home/sergio/gitea/coffee_crisis_arcade_edition/source/sprite.h:30:9: note: Parent function 'Sprite::getPosY' int getPosY() const; ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.h:55:11: note: Derived function 'MovingSprite::getPosY' +/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.h:61:11: note: Derived function 'MovingSprite::getPosY' float getPosY() const; ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.h:122:14: warning: The class 'MovingSprite' defines member function with name 'getRect' also defined in its parent class 'Sprite'. [duplInheritedMember] - SDL_Rect getRect(); - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/sprite.h:44:14: note: Parent function 'Sprite::getRect' - SDL_Rect getRect() const; - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.h:122:14: note: Derived function 'MovingSprite::getRect' - SDL_Rect getRect(); - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/animated_sprite.cpp:519:22: warning: The class 'AnimatedSprite' defines member function with name 'update' also defined in its parent class 'MovingSprite'. [duplInheritedMember] -void AnimatedSprite::update() - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.h:45:10: note: Parent function 'MovingSprite::update' - void update(); - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/animated_sprite.cpp:519:22: note: Derived function 'AnimatedSprite::update' -void AnimatedSprite::update() - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/texture.h:52:5: style: Class 'Texture' has a constructor with 1 argument that is not explicit. [noExplicitConstructor] - Texture(SDL_Renderer *renderer, std::string path = ""); - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/sprite.h:23:5: style: Class 'Sprite' has a constructor with 1 argument that is not explicit. [noExplicitConstructor] - Sprite(int x = 0, int y = 0, int w = 0, int h = 0, std::shared_ptr texture = nullptr); - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/sprite.h:24:5: style: Class 'Sprite' has a constructor with 1 argument that is not explicit. [noExplicitConstructor] - Sprite(SDL_Rect rect, std::shared_ptr texture = nullptr); - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.h:36:5: style: Class 'MovingSprite' has a constructor with 1 argument that is not explicit. [noExplicitConstructor] - 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); - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/animated_sprite.h:40:5: style: Class 'AnimatedSprite' has a constructor with 1 argument that is not explicit. [noExplicitConstructor] - AnimatedSprite(std::shared_ptr texture = nullptr, std::string file = "", std::vector *buffer = nullptr); - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/animated_sprite.h:41:5: style: Class 'AnimatedSprite' has a constructor with 1 argument that is not explicit. [noExplicitConstructor] - AnimatedSprite(AnimatedFile *animation); - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/animated_sprite.cpp:159:78: performance: Function parameter 'file' should be passed by const reference. [passedByValue] -AnimatedSprite::AnimatedSprite(std::shared_ptr texture, std::string file, std::vector *buffer) - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/animated_sprite.cpp:208:42: performance: Function parameter 'name' should be passed by const reference. [passedByValue] -int AnimatedSprite::getIndex(std::string name) - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/animated_sprite.cpp:212:12: performance: Range variable 'a' should be declared as const reference. [iterateByValue] - for (auto a : animations_) - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/animated_sprite.cpp:287:54: performance: Function parameter 'name' should be passed by const reference. [passedByValue] -void AnimatedSprite::setAnimationCounter(std::string name, int num) - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/animated_sprite.cpp:293:52: performance: Function parameter 'name' should be passed by const reference. [passedByValue] -void AnimatedSprite::setAnimationSpeed(std::string name, int speed) - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/animated_sprite.cpp:305:51: performance: Function parameter 'name' should be passed by const reference. [passedByValue] -void AnimatedSprite::setAnimationLoop(std::string name, int loop) - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/animated_sprite.cpp:317:56: performance: Function parameter 'name' should be passed by const reference. [passedByValue] -void AnimatedSprite::setAnimationCompleted(std::string name, bool value) - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/animated_sprite.cpp:335:55: performance: Function parameter 'name' should be passed by const reference. [passedByValue] -SDL_Rect AnimatedSprite::getAnimationClip(std::string name, Uint8 index) - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/animated_sprite.cpp:493:54: performance: Function parameter 'name' should be passed by const reference. [passedByValue] -void AnimatedSprite::setCurrentAnimation(std::string name) - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/animated_sprite.cpp:186:46: style: Parameter 'animation' can be declared as pointer to const [constParameterPointer] -AnimatedSprite::AnimatedSprite(AnimatedFile *animation) - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/animated_sprite.cpp:172:16: style: Consider using std::copy algorithm instead of a raw loop. [useStlAlgorithm] - animations_.push_back(animation); - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/animated_sprite.cpp:197:15: style: Consider using std::copy algorithm instead of a raw loop. [useStlAlgorithm] - animations_.push_back(a); - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/animated_sprite.cpp:18:30: style: Variable 'file_name' is assigned a value that is never used. [unreadVariable] - const std::string file_name = file_path.substr(file_path.find_last_of("\\/") + 1); - ^ /home/sergio/gitea/coffee_crisis_arcade_edition/source/asset.cpp:31:5: performance: Variable 'executable_path_' is assigned in constructor body. Consider performing initialization in initialization list. [useInitializationList] executable_path_ = executable_path.substr(0, executable_path.find_last_of("\\/")); ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/asset.h:48:2: style: Class 'Asset' has a constructor with 1 argument that is not explicit. [noExplicitConstructor] - Asset(std::string path); - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/asset.cpp:11:30: performance: Function parameter 'executable_path' should be passed by const reference. [passedByValue] -void Asset::init(std::string executable_path) - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/asset.cpp:29:26: performance: Function parameter 'executable_path' should be passed by const reference. [passedByValue] -Asset::Asset(std::string executable_path) - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/asset.cpp:36:29: performance: Function parameter 'file' should be passed by const reference. [passedByValue] -void Asset::add(std::string file, AssetType type, bool required, bool absolute) - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/asset.cpp:49:36: performance: Function parameter 'text' should be passed by const reference. [passedByValue] -std::string Asset::get(std::string text) const - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/asset.cpp:51:15: performance: Range variable 'f' should be declared as const reference. [iterateByValue] - for (auto f : file_list_) - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/asset.cpp:86:19: performance: Range variable 'f' should be declared as const reference. [iterateByValue] - for (auto f : file_list_) - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/asset.cpp:101:23: performance: Range variable 'f' should be declared as const reference. [iterateByValue] - for (auto f : file_list_) - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/asset.cpp:120:35: performance: Function parameter 'path' should be passed by const reference. [passedByValue] -bool Asset::checkFile(std::string path) const - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/asset.cpp:123:24: style: Variable 'result' is assigned a value that is never used. [unreadVariable] - std::string result = "ERROR"; - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/asset.cpp:126:33: style: Variable 'file_name' is assigned a value that is never used. [unreadVariable] - const std::string file_name = path.substr(path.find_last_of("\\/") + 1); - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/asset.cpp:131:16: style: Variable 'result' is assigned a value that is never used. [unreadVariable] - result = "OK"; - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/background.cpp:14:5: performance: Variable 'buildings_texture_' is assigned in constructor body. Consider performing initialization in initialization list. [useInitializationList] - buildings_texture_ = std::make_shared(renderer, Asset::get()->get("game_buildings.png")); - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/background.h:110:3: style: Class 'Background' has a constructor with 1 argument that is not explicit. [noExplicitConstructor] - Background(SDL_Renderer *renderer); - ^ /home/sergio/gitea/coffee_crisis_arcade_edition/source/balloon.cpp:13:2: performance: Variable 'sprite_' is assigned in constructor body. Consider performing initialization in initialization list. [useInitializationList] sprite_ = std::make_unique(texture, "", animation); ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/animated_sprite.h:88:10: warning: The class 'AnimatedSprite' defines member function with name 'update' also defined in its parent class 'MovingSprite'. [duplInheritedMember] - void update(); - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.h:45:10: note: Parent function 'MovingSprite::update' - void update(); - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/animated_sprite.h:88:10: note: Derived function 'AnimatedSprite::update' - void update(); - ^ /home/sergio/gitea/coffee_crisis_arcade_edition/source/bullet.cpp:23:5: performance: Variable 'sprite_' is assigned in constructor body. Consider performing initialization in initialization list. [useInitializationList] sprite_ = std::make_unique(SDL_Rect{x, y, BULLET_WIDTH, BULLET_HEIGHT}, texture); ^ /home/sergio/gitea/coffee_crisis_arcade_edition/source/define_buttons.h:49:5: style: Class 'DefineButtons' has a constructor with 1 argument that is not explicit. [noExplicitConstructor] DefineButtons(std::unique_ptr text); ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/smart_sprite.h:35:7: warning: The class 'SmartSprite' defines member function with name 'update' also defined in its parent class 'AnimatedSprite'. [duplInheritedMember] - void update(); - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/animated_sprite.h:88:10: note: Parent function 'AnimatedSprite::update' - void update(); - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/smart_sprite.h:35:7: note: Derived function 'SmartSprite::update' - void update(); - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/smart_sprite.h:35:7: warning: The class 'SmartSprite' defines member function with name 'update' also defined in its parent class 'MovingSprite'. [duplInheritedMember] - void update(); - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.h:45:10: note: Parent function 'MovingSprite::update' - void update(); - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/smart_sprite.h:35:7: note: Derived function 'SmartSprite::update' - void update(); - ^ /home/sergio/gitea/coffee_crisis_arcade_edition/source/fade.h:57:2: style: Class 'Fade' has a constructor with 1 argument that is not explicit. [noExplicitConstructor] Fade(SDL_Renderer *renderer); ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/smart_sprite.h:26:2: style: Class 'SmartSprite' has a constructor with 1 argument that is not explicit. [noExplicitConstructor] - SmartSprite(std::shared_ptr texture); - ^ /home/sergio/gitea/coffee_crisis_arcade_edition/source/hiscore_table.h:73:2: style: Class 'HiScoreTable' has a constructor with 1 argument that is not explicit. [noExplicitConstructor] HiScoreTable(JA_Music_t *music); ^ @@ -403,45 +229,27 @@ bool ManageHiScoreTable::saveToFile(std::string file_path) /home/sergio/gitea/coffee_crisis_arcade_edition/source/manage_hiscore_table.cpp:119:32: style: Variable 'fileName' is assigned a value that is never used. [unreadVariable] const std::string fileName = file_path.substr(file_path.find_last_of("\\/") + 1); ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.cpp:30:2: performance: Variable 'currentFlip_' is assigned in constructor body. Consider performing initialization in initialization list. [useInitializationList] - currentFlip_ = SDL_FLIP_NONE; +/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.cpp:32:2: performance: Variable 'flip_' is assigned in constructor body. Consider performing initialization in initialization list. [useInitializationList] + flip_ = SDL_FLIP_NONE; ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.cpp:69:20: warning: The class 'MovingSprite' defines member function with name 'render' also defined in its parent class 'Sprite'. [duplInheritedMember] -void MovingSprite::render() - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/sprite.h:30:10: note: Parent function 'Sprite::render' - void render(); - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.cpp:69:20: note: Derived function 'MovingSprite::render' -void MovingSprite::render() - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.cpp:78:21: warning: The class 'MovingSprite' defines member function with name 'getPosX' also defined in its parent class 'Sprite'. [duplInheritedMember] +/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.cpp:87:21: warning: The class 'MovingSprite' defines member function with name 'getPosX' also defined in its parent class 'Sprite'. [duplInheritedMember] float MovingSprite::getPosX() const ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/sprite.h:33:9: note: Parent function 'Sprite::getPosX' +/home/sergio/gitea/coffee_crisis_arcade_edition/source/sprite.h:29:9: note: Parent function 'Sprite::getPosX' int getPosX() const; ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.cpp:78:21: note: Derived function 'MovingSprite::getPosX' +/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.cpp:87:21: note: Derived function 'MovingSprite::getPosX' float MovingSprite::getPosX() const ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.cpp:84:21: warning: The class 'MovingSprite' defines member function with name 'getPosY' also defined in its parent class 'Sprite'. [duplInheritedMember] +/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.cpp:93:21: warning: The class 'MovingSprite' defines member function with name 'getPosY' also defined in its parent class 'Sprite'. [duplInheritedMember] float MovingSprite::getPosY() const ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/sprite.h:34:9: note: Parent function 'Sprite::getPosY' +/home/sergio/gitea/coffee_crisis_arcade_edition/source/sprite.h:30:9: note: Parent function 'Sprite::getPosY' int getPosY() const; ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.cpp:84:21: note: Derived function 'MovingSprite::getPosY' +/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.cpp:93:21: note: Derived function 'MovingSprite::getPosY' float MovingSprite::getPosY() const ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.cpp:298:24: warning: The class 'MovingSprite' defines member function with name 'getRect' also defined in its parent class 'Sprite'. [duplInheritedMember] -SDL_Rect MovingSprite::getRect() - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/sprite.h:44:14: note: Parent function 'Sprite::getRect' - SDL_Rect getRect() const; - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.cpp:298:24: note: Derived function 'MovingSprite::getRect' -SDL_Rect MovingSprite::getRect() - ^ /home/sergio/gitea/coffee_crisis_arcade_edition/source/notify.cpp:17:5: performance: Variable 'bgColor' is assigned in constructor body. Consider performing initialization in initialization list. [useInitializationList] bgColor = param.notification.color; ^ @@ -589,27 +397,6 @@ void Screen::showNotification(std::string text1, std::string text2, int icon) /home/sergio/gitea/coffee_crisis_arcade_edition/source/screen.cpp:188:24: note: options.video.mode is overwritten options.video.mode = ScreenVideoMode::WINDOW; ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/smart_sprite.cpp:26:19: warning: The class 'SmartSprite' defines member function with name 'update' also defined in its parent class 'AnimatedSprite'. [duplInheritedMember] -void SmartSprite::update() - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/animated_sprite.h:88:10: note: Parent function 'AnimatedSprite::update' - void update(); - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/smart_sprite.cpp:26:19: note: Derived function 'SmartSprite::update' -void SmartSprite::update() - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/smart_sprite.cpp:26:19: warning: The class 'SmartSprite' defines member function with name 'update' also defined in its parent class 'MovingSprite'. [duplInheritedMember] -void SmartSprite::update() - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/moving_sprite.h:45:10: note: Parent function 'MovingSprite::update' - void update(); - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/smart_sprite.cpp:26:19: note: Derived function 'SmartSprite::update' -void SmartSprite::update() - ^ -/home/sergio/gitea/coffee_crisis_arcade_edition/source/sprite.cpp:8:2: performance: Variable 'spriteClip_' is assigned in constructor body. Consider performing initialization in initialization list. [useInitializationList] - spriteClip_ = {0, 0, w, h}; - ^ /home/sergio/gitea/coffee_crisis_arcade_edition/source/text.cpp:82:49: performance: Function parameter 'text_file' should be passed by const reference. [passedByValue] Text::Text(std::string bitmap_file, std::string text_file, SDL_Renderer *renderer) ^ diff --git a/source/asset.cpp b/source/asset.cpp index 470d8af..21061c3 100644 --- a/source/asset.cpp +++ b/source/asset.cpp @@ -27,8 +27,8 @@ Asset *Asset::get() // Constructor Asset::Asset(const std::string &executable_path) + : executable_path_(executable_path.substr(0, executable_path.find_last_of("\\/"))) { - executable_path_ = executable_path.substr(0, executable_path.find_last_of("\\/")); longest_name_ = 0; } diff --git a/source/balloon.cpp b/source/balloon.cpp index d05e4a6..3fd0126 100644 --- a/source/balloon.cpp +++ b/source/balloon.cpp @@ -8,10 +8,15 @@ // Constructor Balloon::Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16 creation_timer, std::shared_ptr texture, std::vector *animation) - : kind_(kind), speed_(speed) + : sprite_(std::make_unique(texture, "", animation)), + pos_x_(x), + pos_y_(y), + vel_x_(vel_x), + creation_counter_(creation_timer), + creation_counter_ini_(creation_timer), + kind_(kind), + speed_(speed) { - sprite_ = std::make_unique(texture, "", animation); - enabled_ = true; switch (kind_) @@ -24,7 +29,6 @@ Balloon::Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16 power_ = 1; // Inicializa los valores de velocidad y gravedad - vel_x_ = vel_x; vel_y_ = 0; max_vel_y_ = 3.0f; gravity_ = param.balloon_1.grav; @@ -46,7 +50,6 @@ Balloon::Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16 power_ = 3; // Inicializa los valores de velocidad y gravedad - vel_x_ = vel_x; vel_y_ = 0; max_vel_y_ = 3.0f; gravity_ = param.balloon_2.grav; @@ -68,7 +71,6 @@ Balloon::Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16 power_ = 7; // Inicializa los valores de velocidad y gravedad - vel_x_ = vel_x; vel_y_ = 0; max_vel_y_ = 3.0f; gravity_ = param.balloon_3.grav; @@ -90,7 +92,6 @@ Balloon::Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16 power_ = 15; // Inicializa los valores de velocidad y gravedad - vel_x_ = vel_x; vel_y_ = 0; max_vel_y_ = 3.0f; gravity_ = param.balloon_4.grav; @@ -112,7 +113,6 @@ Balloon::Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16 power_ = 1; // Inicializa los valores de velocidad y gravedad - vel_x_ = vel_x; vel_y_ = abs(vel_x) * 2; max_vel_y_ = abs(vel_x) * 2; gravity_ = 0.00f; @@ -134,7 +134,6 @@ Balloon::Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16 power_ = 3; // Inicializa los valores de velocidad y gravedad - vel_x_ = vel_x; vel_y_ = abs(vel_x) * 2; max_vel_y_ = abs(vel_x) * 2; gravity_ = 0.00f; @@ -156,7 +155,6 @@ Balloon::Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16 power_ = 7; // Inicializa los valores de velocidad y gravedad - vel_x_ = vel_x; vel_y_ = abs(vel_x) * 2; max_vel_y_ = abs(vel_x) * 2; gravity_ = 0.00f; @@ -178,7 +176,6 @@ Balloon::Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16 power_ = 15; // Inicializa los valores de velocidad y gravedad - vel_x_ = vel_x; vel_y_ = abs(vel_x) * 2; max_vel_y_ = abs(vel_x) * 2; gravity_ = 0.00f; @@ -200,7 +197,6 @@ Balloon::Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16 power_ = 0; // Inicializa los valores de velocidad y gravedad - vel_x_ = vel_x; vel_y_ = 0; max_vel_y_ = 3.0f; gravity_ = param.balloon_4.grav; @@ -223,10 +219,6 @@ Balloon::Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16 break; } - // Posición inicial - pos_x_ = x; - pos_y_ = y; - // Valores para el efecto de rebote bouncing_.enabled = false; bouncing_.counter = 0; @@ -259,8 +251,6 @@ Balloon::Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16 visible_ = true; invulnerable_ = true; being_created_ = true; - creation_counter_ = creation_timer; - creation_counter_ini_ = creation_timer; // Actualiza valores being_created_ = creation_counter_ == 0 ? false : true; diff --git a/source/bullet.cpp b/source/bullet.cpp index 41160e7..a759576 100644 --- a/source/bullet.cpp +++ b/source/bullet.cpp @@ -11,16 +11,24 @@ constexpr int BULLET_VELX_LEFT = -2; constexpr int BULLET_VELX_RIGHT = 2; // Constructor -Bullet::Bullet(int x, int y, BulletType kind_, bool poweredUp, int owner, SDL_Rect *play_area, std::shared_ptr texture) - : pos_x_(x), pos_y_(y), width_(BULLET_WIDTH), height_(BULLET_HEIGHT), vel_x_(0), vel_y_(BULLET_VELY), - kind_(kind_), owner_(owner), play_area_(play_area) +Bullet::Bullet(int x, int y, BulletType kind, bool powered_up, int owner, SDL_Rect *play_area, std::shared_ptr texture) + : sprite_(std::make_unique(SDL_Rect{x, y, BULLET_WIDTH, BULLET_HEIGHT}, texture)), + pos_x_(x), + pos_y_(y), + width_(BULLET_WIDTH), + height_(BULLET_HEIGHT), + vel_x_(0), + vel_y_(BULLET_VELY), + kind_(kind), + owner_(owner), + play_area_(play_area) { - vel_x_ = (kind_ == BulletType::LEFT) ? BULLET_VELX_LEFT : (kind_ == BulletType::RIGHT) ? BULLET_VELX_RIGHT - : 0; - - auto sprite_offset = poweredUp ? 3 : 0; - auto kind_index = static_cast(kind_); - sprite_ = std::make_unique(SDL_Rect{x, y, BULLET_WIDTH, BULLET_HEIGHT}, texture); + vel_x_ = (kind_ == BulletType::LEFT) ? BULLET_VELX_LEFT + : (kind_ == BulletType::RIGHT) ? BULLET_VELX_RIGHT + : 0; + + auto sprite_offset = powered_up ? 3 : 0; + auto kind_index = static_cast(kind); sprite_->setSpriteClip((kind_index + sprite_offset) * width_, 0, sprite_->getWidth(), sprite_->getHeight()); collider_.r = width_ / 2; diff --git a/source/bullet.h b/source/bullet.h index be13532..c71fced 100644 --- a/source/bullet.h +++ b/source/bullet.h @@ -27,18 +27,21 @@ enum class BulletMoveStatus : Uint8 class Bullet { private: - int pos_x_; // Posición en el eje X - int pos_y_; // Posición en el eje Y - Uint8 width_; // Ancho del objeto - Uint8 height_; // Alto del objeto - int vel_x_; // Velocidad en el eje X - int vel_y_; // Velocidad en el eje Y - BulletType kind_; // Tipo de objeto - int owner_; // Identificador del dueño del objeto - Circle collider_; // Círculo de colisión del objeto - SDL_Rect *play_area_; // Rectángulo con la zona de juego std::unique_ptr sprite_; // Sprite con los gráficos y métodos de pintado + int pos_x_; // Posición en el eje X + int pos_y_; // Posición en el eje Y + Uint8 width_; // Ancho del objeto + Uint8 height_; // Alto del objeto + + int vel_x_; // Velocidad en el eje X + int vel_y_; // Velocidad en el eje Y + + BulletType kind_; // Tipo de objeto + int owner_; // Identificador del dueño del objeto + Circle collider_; // Círculo de colisión del objeto + SDL_Rect *play_area_; // Rectángulo con la zona de juego + void shiftColliders(); // Alinea el círculo de colisión con el objeto public: diff --git a/source/define_buttons.h b/source/define_buttons.h index e0e4c58..09a9653 100644 --- a/source/define_buttons.h +++ b/source/define_buttons.h @@ -46,7 +46,7 @@ private: public: // Constructor - DefineButtons(std::unique_ptr text); + explicit DefineButtons(std::unique_ptr text); // Destructor ~DefineButtons() = default; diff --git a/source/director.cpp b/source/director.cpp index 987af63..163d1cf 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -298,7 +298,7 @@ bool Director::initSDL() Uint32 flags = 0; if (options.video.v_sync) { - flags = flags | SDL_RENDERER_PRESENTVSYNC; + flags = SDL_RENDERER_PRESENTVSYNC; } #ifndef NO_SHADERS // La aceleración se activa según el define @@ -478,9 +478,9 @@ bool Director::setFileList() } // Carga los parametros para configurar el juego -void Director::loadParams(std::string filepath) +void Director::loadParams(const std::string &file_path) { - loadParamsFromFile(filepath); + loadParamsFromFile(file_path); } // Comprueba los parametros del programa @@ -503,7 +503,7 @@ void Director::checkProgramArguments(int argc, char *argv[]) } // Crea la carpeta del sistema donde guardar datos -void Director::createSystemFolder(std::string folder) +void Director::createSystemFolder(const std::string &folder) { #ifdef _WIN32 system_folder_ = std::string(getenv("APPDATA")) + "/" + folder; @@ -569,7 +569,7 @@ void Director::loadSounds() std::vector list = Asset::get()->getListByType(AssetType::SOUND); sounds_.clear(); - for (auto l : list) + for (const auto &l : list) { const size_t lastIndex = l.find_last_of("/") + 1; const std::string name = l.substr(lastIndex, std::string::npos); @@ -587,7 +587,7 @@ void Director::loadMusics() std::vector list = Asset::get()->getListByType(AssetType::MUSIC); musics_.clear(); - for (auto l : list) + for (const auto &l : list) { const size_t lastIndex = l.find_last_of("/") + 1; const std::string name = l.substr(lastIndex, std::string::npos); diff --git a/source/director.h b/source/director.h index 1684638..775ec4b 100644 --- a/source/director.h +++ b/source/director.h @@ -34,7 +34,7 @@ private: void initInput(); // Carga los parametros para configurar el juego - void loadParams(std::string file_path); + void loadParams(const std::string &file_path); // Crea el indice de ficheros bool setFileList(); @@ -49,7 +49,7 @@ private: void checkProgramArguments(int argc, char *argv[]); // Crea la carpeta del sistema donde guardar datos - void createSystemFolder(std::string folder); + void createSystemFolder(const std::string &folder); // Ejecuta la sección con el logo void runLogo(); diff --git a/source/enemy_formations.cpp b/source/enemy_formations.cpp index 0f1d364..f8297dd 100644 --- a/source/enemy_formations.cpp +++ b/source/enemy_formations.cpp @@ -45,333 +45,333 @@ void EnemyFormations::initEnemyFormations() } } - const int creationTime = 300; - int incX = 0; - int incTime = 0; + const int creation_time = 300; + int inc_x = 0; + int inc_time = 0; int j = 0; // #00 - Dos enemigos BALLOON4 uno a cada extremo j = 0; enemy_formation_[j].number_of_enemies = 2; - incX = x4_100; - incTime = 0; + inc_x = x4_100; + inc_time = 0; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x4_0 + (i * incX); + enemy_formation_[j].init[i].x = x4_0 + (i * inc_x); enemy_formation_[j].init[i].y = y4; enemy_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE * (((i % 2) * 2) - 1); enemy_formation_[j].init[i].kind = BALLOON_4; - enemy_formation_[j].init[i].creation_counter = creationTime + (incTime * i); + enemy_formation_[j].init[i].creation_counter = creation_time + (inc_time * i); } // #01 - Dos enemigos BALLOON4 uno a cada cuarto. Ambos van hacia el centro j = 1; enemy_formation_[j].number_of_enemies = 2; - incX = param.game.play_area.center_x; - incTime = 0; + inc_x = param.game.play_area.center_x; + inc_time = 0; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = param.game.play_area.first_quarter_x - (BALLOON_WIDTH_4 / 2) + (i * incX); + enemy_formation_[j].init[i].x = param.game.play_area.first_quarter_x - (BALLOON_WIDTH_4 / 2) + (i * inc_x); enemy_formation_[j].init[i].y = y4; enemy_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE * (((i % 2) * 2) - 1); enemy_formation_[j].init[i].kind = BALLOON_4; - enemy_formation_[j].init[i].creation_counter = creationTime + (incTime * i); + enemy_formation_[j].init[i].creation_counter = creation_time + (inc_time * i); } // #02 - Cuatro enemigos BALLOON2 uno detras del otro. A la izquierda y hacia el centro j = 2; enemy_formation_[j].number_of_enemies = 4; - incX = BALLOON_WIDTH_2 + 1; - incTime = 10; + inc_x = BALLOON_WIDTH_2 + 1; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x2_0 + (i * incX); + enemy_formation_[j].init[i].x = x2_0 + (i * inc_x); enemy_formation_[j].init[i].y = y2; enemy_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE; enemy_formation_[j].init[i].kind = BALLOON_2; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = creation_time - (inc_time * i); } // #03 - Cuatro enemigos BALLOON2 uno detras del otro. A la derecha y hacia el centro j = 3; enemy_formation_[j].number_of_enemies = 4; - incX = BALLOON_WIDTH_2 + 1; - incTime = 10; + inc_x = BALLOON_WIDTH_2 + 1; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x2_100 - (i * incX); + enemy_formation_[j].init[i].x = x2_100 - (i * inc_x); enemy_formation_[j].init[i].y = y2; enemy_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE; enemy_formation_[j].init[i].kind = BALLOON_2; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = creation_time - (inc_time * i); } // #04 - Tres enemigos BALLOON3. 0, 25, 50. Hacia la derecha j = 4; enemy_formation_[j].number_of_enemies = 3; - incX = BALLOON_WIDTH_3 * 2; - incTime = 10; + inc_x = BALLOON_WIDTH_3 * 2; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x3_0 + (i * incX); + enemy_formation_[j].init[i].x = x3_0 + (i * inc_x); enemy_formation_[j].init[i].y = y3; enemy_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE; enemy_formation_[j].init[i].kind = BALLOON_3; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = creation_time - (inc_time * i); } // #05 - Tres enemigos BALLOON3. 50, 75, 100. Hacia la izquierda j = 5; enemy_formation_[j].number_of_enemies = 3; - incX = BALLOON_WIDTH_3 * 2; - incTime = 10; + inc_x = BALLOON_WIDTH_3 * 2; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x3_100 - (i * incX); + enemy_formation_[j].init[i].x = x3_100 - (i * inc_x); enemy_formation_[j].init[i].y = y3; enemy_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE; enemy_formation_[j].init[i].kind = BALLOON_3; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = creation_time - (inc_time * i); } // #06 - Tres enemigos BALLOON3. 0, 0, 0. Hacia la derecha j = 6; enemy_formation_[j].number_of_enemies = 3; - incX = BALLOON_WIDTH_3 + 1; - incTime = 10; + inc_x = BALLOON_WIDTH_3 + 1; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x3_0 + (i * incX); + enemy_formation_[j].init[i].x = x3_0 + (i * inc_x); enemy_formation_[j].init[i].y = y3; enemy_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE; enemy_formation_[j].init[i].kind = BALLOON_3; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = creation_time - (inc_time * i); } // #07 - Tres enemigos BALLOON3. 100, 100, 100. Hacia la izquierda j = 7; enemy_formation_[j].number_of_enemies = 3; - incX = BALLOON_WIDTH_3 + 1; - incTime = 10; + inc_x = BALLOON_WIDTH_3 + 1; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x3_100 - (i * incX); + enemy_formation_[j].init[i].x = x3_100 - (i * inc_x); enemy_formation_[j].init[i].y = y3; enemy_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE; enemy_formation_[j].init[i].kind = BALLOON_3; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = creation_time - (inc_time * i); } // #08 - Seis enemigos BALLOON1. 0, 0, 0, 0, 0, 0. Hacia la derecha j = 8; enemy_formation_[j].number_of_enemies = 6; - incX = BALLOON_WIDTH_1 + 1; - incTime = 10; + inc_x = BALLOON_WIDTH_1 + 1; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x1_0 + (i * incX); + enemy_formation_[j].init[i].x = x1_0 + (i * inc_x); enemy_formation_[j].init[i].y = y1; enemy_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE; enemy_formation_[j].init[i].kind = BALLOON_1; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = creation_time - (inc_time * i); } // #09 - Seis enemigos BALLOON1. 100, 100, 100, 100, 100, 100. Hacia la izquierda j = 9; enemy_formation_[j].number_of_enemies = 6; - incX = BALLOON_WIDTH_1 + 1; - incTime = 10; + inc_x = BALLOON_WIDTH_1 + 1; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x1_100 - (i * incX); + enemy_formation_[j].init[i].x = x1_100 - (i * inc_x); enemy_formation_[j].init[i].y = y1; enemy_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE; enemy_formation_[j].init[i].kind = BALLOON_1; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = creation_time - (inc_time * i); } // #10 - Tres enemigos BALLOON4 seguidos desde la izquierda j = 10; enemy_formation_[j].number_of_enemies = 3; - incX = BALLOON_WIDTH_4 + 1; - incTime = 15; + inc_x = BALLOON_WIDTH_4 + 1; + inc_time = 15; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x4_0 + (i * incX); + enemy_formation_[j].init[i].x = x4_0 + (i * inc_x); enemy_formation_[j].init[i].y = y4; enemy_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE; enemy_formation_[j].init[i].kind = BALLOON_4; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = creation_time - (inc_time * i); } // #11 - Tres enemigos BALLOON4 seguidos desde la derecha j = 11; enemy_formation_[j].number_of_enemies = 3; - incX = BALLOON_WIDTH_4 + 1; - incTime = 15; + inc_x = BALLOON_WIDTH_4 + 1; + inc_time = 15; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x4_100 - (i * incX); + enemy_formation_[j].init[i].x = x4_100 - (i * inc_x); enemy_formation_[j].init[i].y = y4; enemy_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE; enemy_formation_[j].init[i].kind = BALLOON_4; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = creation_time - (inc_time * i); } // #12 - Seis enemigos BALLOON2 uno detras del otro. A la izquierda y hacia el centro j = 12; enemy_formation_[j].number_of_enemies = 6; - incX = BALLOON_WIDTH_2 + 1; - incTime = 10; + inc_x = BALLOON_WIDTH_2 + 1; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x2_0 + (i * incX); + enemy_formation_[j].init[i].x = x2_0 + (i * inc_x); enemy_formation_[j].init[i].y = y2; enemy_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE; enemy_formation_[j].init[i].kind = BALLOON_2; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = creation_time - (inc_time * i); } // #13 - Seis enemigos BALLOON2 uno detras del otro. A la derecha y hacia el centro j = 13; enemy_formation_[j].number_of_enemies = 6; - incX = BALLOON_WIDTH_2 + 1; - incTime = 10; + inc_x = BALLOON_WIDTH_2 + 1; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x2_100 - (i * incX); + enemy_formation_[j].init[i].x = x2_100 - (i * inc_x); enemy_formation_[j].init[i].y = y2; enemy_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE; enemy_formation_[j].init[i].kind = BALLOON_2; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = creation_time - (inc_time * i); } // #14 - Cinco enemigos BALLOON3. Hacia la derecha. Separados j = 14; enemy_formation_[j].number_of_enemies = 5; - incX = BALLOON_WIDTH_3 * 2; - incTime = 10; + inc_x = BALLOON_WIDTH_3 * 2; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x3_0 + (i * incX); + enemy_formation_[j].init[i].x = x3_0 + (i * inc_x); enemy_formation_[j].init[i].y = y3; enemy_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE; enemy_formation_[j].init[i].kind = BALLOON_3; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = creation_time - (inc_time * i); } // #15 - Cinco enemigos BALLOON3. Hacia la izquierda. Separados j = 15; enemy_formation_[j].number_of_enemies = 5; - incX = BALLOON_WIDTH_3 * 2; - incTime = 10; + inc_x = BALLOON_WIDTH_3 * 2; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x3_100 - (i * incX); + enemy_formation_[j].init[i].x = x3_100 - (i * inc_x); enemy_formation_[j].init[i].y = y3; enemy_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE; enemy_formation_[j].init[i].kind = BALLOON_3; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = creation_time - (inc_time * i); } // #16 - Cinco enemigos BALLOON3. Hacia la derecha. Juntos j = 16; enemy_formation_[j].number_of_enemies = 5; - incX = BALLOON_WIDTH_3 + 1; - incTime = 10; + inc_x = BALLOON_WIDTH_3 + 1; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x3_0 + (i * incX); + enemy_formation_[j].init[i].x = x3_0 + (i * inc_x); enemy_formation_[j].init[i].y = y3; enemy_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE; enemy_formation_[j].init[i].kind = BALLOON_3; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = creation_time - (inc_time * i); } // #17 - Cinco enemigos BALLOON3. Hacia la izquierda. Juntos j = 17; enemy_formation_[j].number_of_enemies = 5; - incX = BALLOON_WIDTH_3 + 1; - incTime = 10; + inc_x = BALLOON_WIDTH_3 + 1; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x3_100 - (i * incX); + enemy_formation_[j].init[i].x = x3_100 - (i * inc_x); enemy_formation_[j].init[i].y = y3; enemy_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE; enemy_formation_[j].init[i].kind = BALLOON_3; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = creation_time - (inc_time * i); } // #18 - Doce enemigos BALLOON1. Hacia la derecha. Juntos j = 18; enemy_formation_[j].number_of_enemies = 12; - incX = BALLOON_WIDTH_1 + 1; - incTime = 10; + inc_x = BALLOON_WIDTH_1 + 1; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x1_0 + (i * incX); + enemy_formation_[j].init[i].x = x1_0 + (i * inc_x); enemy_formation_[j].init[i].y = y1; enemy_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE; enemy_formation_[j].init[i].kind = BALLOON_1; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = creation_time - (inc_time * i); } // #19 - Doce enemigos BALLOON1. Hacia la izquierda. Juntos j = 19; enemy_formation_[j].number_of_enemies = 12; - incX = BALLOON_WIDTH_1 + 1; - incTime = 10; + inc_x = BALLOON_WIDTH_1 + 1; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x1_100 - (i * incX); + enemy_formation_[j].init[i].x = x1_100 - (i * inc_x); enemy_formation_[j].init[i].y = y1; enemy_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE; enemy_formation_[j].init[i].kind = BALLOON_1; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = creation_time - (inc_time * i); } // #20 - Dos enemigos BALLOON4 seguidos desde la izquierda/derecha. Simetricos j = 20; enemy_formation_[j].number_of_enemies = 4; - incX = BALLOON_WIDTH_4 + 1; - incTime = 0; + inc_x = BALLOON_WIDTH_4 + 1; + inc_time = 0; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { const int half = enemy_formation_[j].number_of_enemies / 2; if (i < half) { - enemy_formation_[j].init[i].x = x4_0 + (i * incX); + enemy_formation_[j].init[i].x = x4_0 + (i * inc_x); enemy_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE; } else { - enemy_formation_[j].init[i].x = x4_100 - ((i - half) * incX); + enemy_formation_[j].init[i].x = x4_100 - ((i - half) * inc_x); enemy_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE; } enemy_formation_[j].init[i].y = y4; enemy_formation_[j].init[i].kind = BALLOON_4; - enemy_formation_[j].init[i].creation_counter = creationTime + (incTime * i); + enemy_formation_[j].init[i].creation_counter = creation_time + (inc_time * i); } // #21 - Diez enemigos BALLOON2 uno detras del otro. Izquierda/derecha. Simetricos j = 21; enemy_formation_[j].number_of_enemies = 10; - incX = BALLOON_WIDTH_2 + 1; - incTime = 3; + inc_x = BALLOON_WIDTH_2 + 1; + inc_time = 3; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { const int half = enemy_formation_[j].number_of_enemies / 2; if (i < half) { - enemy_formation_[j].init[i].x = x2_0 + (i * incX); + enemy_formation_[j].init[i].x = x2_0 + (i * inc_x); enemy_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE; - enemy_formation_[j].init[i].creation_counter = (creationTime) - (incTime * i); + enemy_formation_[j].init[i].creation_counter = (creation_time) - (inc_time * i); } else { - enemy_formation_[j].init[i].x = x2_100 - ((i - half) * incX); + enemy_formation_[j].init[i].x = x2_100 - ((i - half) * inc_x); enemy_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE; - enemy_formation_[j].init[i].creation_counter = (creationTime) - (incTime * (i - half)); + enemy_formation_[j].init[i].creation_counter = (creation_time) - (inc_time * (i - half)); } enemy_formation_[j].init[i].y = y2; enemy_formation_[j].init[i].kind = BALLOON_2; @@ -380,22 +380,22 @@ void EnemyFormations::initEnemyFormations() // #22 - Diez enemigos BALLOON3. Hacia la derecha/izquierda. Separados. Simetricos j = 22; enemy_formation_[j].number_of_enemies = 10; - incX = BALLOON_WIDTH_3 * 2; - incTime = 10; + inc_x = BALLOON_WIDTH_3 * 2; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { const int half = enemy_formation_[j].number_of_enemies / 2; if (i < half) { - enemy_formation_[j].init[i].x = x3_0 + (i * incX); + enemy_formation_[j].init[i].x = x3_0 + (i * inc_x); enemy_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE; - enemy_formation_[j].init[i].creation_counter = (creationTime) - (incTime * i); + enemy_formation_[j].init[i].creation_counter = (creation_time) - (inc_time * i); } else { - enemy_formation_[j].init[i].x = x3_100 - ((i - half) * incX); + enemy_formation_[j].init[i].x = x3_100 - ((i - half) * inc_x); enemy_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE; - enemy_formation_[j].init[i].creation_counter = (creationTime) - (incTime * (i - half)); + enemy_formation_[j].init[i].creation_counter = (creation_time) - (inc_time * (i - half)); } enemy_formation_[j].init[i].y = y3; enemy_formation_[j].init[i].kind = BALLOON_3; @@ -404,22 +404,22 @@ void EnemyFormations::initEnemyFormations() // #23 - Diez enemigos BALLOON3. Hacia la derecha. Juntos. Simetricos j = 23; enemy_formation_[j].number_of_enemies = 10; - incX = BALLOON_WIDTH_3 + 1; - incTime = 10; + inc_x = BALLOON_WIDTH_3 + 1; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { const int half = enemy_formation_[j].number_of_enemies / 2; if (i < half) { - enemy_formation_[j].init[i].x = x3_0 + (i * incX); + enemy_formation_[j].init[i].x = x3_0 + (i * inc_x); enemy_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE; - enemy_formation_[j].init[i].creation_counter = (creationTime) - (incTime * i); + enemy_formation_[j].init[i].creation_counter = (creation_time) - (inc_time * i); } else { - enemy_formation_[j].init[i].x = x3_100 - ((i - half) * incX); + enemy_formation_[j].init[i].x = x3_100 - ((i - half) * inc_x); enemy_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE; - enemy_formation_[j].init[i].creation_counter = (creationTime) - (incTime * (i - half)); + enemy_formation_[j].init[i].creation_counter = (creation_time) - (inc_time * (i - half)); } enemy_formation_[j].init[i].y = y3; enemy_formation_[j].init[i].kind = BALLOON_3; @@ -428,8 +428,8 @@ void EnemyFormations::initEnemyFormations() // #24 - Treinta enemigos BALLOON1. Del centro hacia los extremos. Juntos. Simetricos j = 24; enemy_formation_[j].number_of_enemies = 30; - incX = 0; - incTime = 5; + inc_x = 0; + inc_time = 5; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { const int half = enemy_formation_[j].number_of_enemies / 2; @@ -437,13 +437,13 @@ void EnemyFormations::initEnemyFormations() { enemy_formation_[j].init[i].x = x1_50; enemy_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE; - enemy_formation_[j].init[i].creation_counter = (creationTime) + (incTime * i); + enemy_formation_[j].init[i].creation_counter = (creation_time) + (inc_time * i); } else { enemy_formation_[j].init[i].x = x1_50; enemy_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE; - enemy_formation_[j].init[i].creation_counter = (creationTime) + (incTime * (i - half)); + enemy_formation_[j].init[i].creation_counter = (creation_time) + (inc_time * (i - half)); } enemy_formation_[j].init[i].y = y1; enemy_formation_[j].init[i].kind = BALLOON_1; @@ -452,8 +452,7 @@ void EnemyFormations::initEnemyFormations() // #25 - Treinta enemigos BALLOON1. Del centro hacia adentro. Juntos. Simetricos j = 25; enemy_formation_[j].number_of_enemies = 30; - incX = BALLOON_WIDTH_1 + 1; - incTime = 5; + inc_time = 5; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { const int half = enemy_formation_[j].number_of_enemies / 2; @@ -461,13 +460,13 @@ void EnemyFormations::initEnemyFormations() { enemy_formation_[j].init[i].x = x1_50 + 20; enemy_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE; - enemy_formation_[j].init[i].creation_counter = (creationTime) - (incTime * i); + enemy_formation_[j].init[i].creation_counter = (creation_time) - (inc_time * i); } else { enemy_formation_[j].init[i].x = x1_50 - 20; enemy_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE; - enemy_formation_[j].init[i].creation_counter = (creationTime) - (incTime * (i - half)); + enemy_formation_[j].init[i].creation_counter = (creation_time) - (inc_time * (i - half)); } enemy_formation_[j].init[i].y = y1; enemy_formation_[j].init[i].kind = BALLOON_1; diff --git a/source/fade.cpp b/source/fade.cpp index 17dbca1..649b648 100644 --- a/source/fade.cpp +++ b/source/fade.cpp @@ -7,8 +7,8 @@ #include "utils.h" // for Param, ParamGame, ParamFade // Constructor -Fade::Fade(SDL_Renderer *renderer_) - : renderer_(renderer_) +Fade::Fade(SDL_Renderer *renderer) + : renderer_(renderer) { // Crea la textura donde dibujar el fade backbuffer_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.width, param.game.height); diff --git a/source/fade.h b/source/fade.h index de58e22..fb7323a 100644 --- a/source/fade.h +++ b/source/fade.h @@ -54,7 +54,7 @@ private: public: // Constructor - Fade(SDL_Renderer *renderer); + explicit Fade(SDL_Renderer *renderer); // Destructor ~Fade(); diff --git a/source/game.cpp b/source/game.cpp index c3500d7..484b312 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -206,7 +206,7 @@ void Game::init(int player_id) counter_ = 0; last_enemy_deploy_ = 0; enemy_deploy_counter_ = 0; - enemy_speed_ = default_enemy_speed_; + balloon_speed_ = default_enemy_speed_; helper_.need_coffee = false; helper_.need_coffee_machine = false; helper_.need_power_ball = false; @@ -558,7 +558,8 @@ void Game::loadMedia() } #ifdef VERBOSE - std::cout << "** RESOURCES FOR GAME SECTION LOADED\n" << std::endl; + std::cout << "** RESOURCES FOR GAME SECTION LOADED\n" + << std::endl; #endif } @@ -742,7 +743,7 @@ void Game::deployEnemyFormation() stage.enemy_pool->set[set]->init[i].y, stage.enemy_pool->set[set]->init[i].kind, stage.enemy_pool->set[set]->init[i].vel_x, - enemy_speed_, + balloon_speed_, stage.enemy_pool->set[set]->init[i].creation_counter); } @@ -850,8 +851,8 @@ void Game::updateStage() } JA_PlaySound(stage_change_sound_); stage_bitmap_counter_ = 0; - enemy_speed_ = default_enemy_speed_; - setBalloonSpeed(enemy_speed_); + balloon_speed_ = default_enemy_speed_; + setBalloonSpeed(balloon_speed_); screen_->flash(flash_color, 5); screen_->shake(); } @@ -947,7 +948,7 @@ void Game::createPowerBall() const int x[values] = {left, left, center, center, right, right}; const float vx[values] = {vel_pos, vel_pos, vel_pos, vel_neg, vel_neg, vel_neg}; - auto b = std::make_unique(x[luck], posY, POWER_BALL, vx[luck], enemy_speed_, 300, balloon_textures_[4], balloon_animations_[4]); + auto b = std::make_unique(x[luck], posY, POWER_BALL, vx[luck], balloon_speed_, 300, balloon_textures_[4], balloon_animations_[4]); balloons_.push_back(std::move(b)); power_ball_enabled_ = true; @@ -966,100 +967,37 @@ void Game::setBalloonSpeed(float speed) } } -// Incrementa la velocidad de los globos -void Game::incBalloonSpeed() -{ - // La velocidad solo se incrementa en el modo normal - if (difficulty_ == GameDifficulty::NORMAL) - { - if (enemy_speed_ == BALLOON_SPEED_1) - { - enemy_speed_ = BALLOON_SPEED_2; - } - - else if (enemy_speed_ == BALLOON_SPEED_2) - { - enemy_speed_ = BALLOON_SPEED_3; - } - - else if (enemy_speed_ == BALLOON_SPEED_3) - { - enemy_speed_ = BALLOON_SPEED_4; - } - - else if (enemy_speed_ == BALLOON_SPEED_4) - { - enemy_speed_ = BALLOON_SPEED_5; - } - - setBalloonSpeed(enemy_speed_); - } -} - -// Decrementa la velocidad de los globos -void Game::decBalloonSpeed() -{ - // La velocidad solo se decrementa en el modo normal - if (difficulty_ == GameDifficulty::NORMAL) - { - if (enemy_speed_ == BALLOON_SPEED_5) - { - enemy_speed_ = BALLOON_SPEED_4; - } - - else if (enemy_speed_ == BALLOON_SPEED_4) - { - enemy_speed_ = BALLOON_SPEED_3; - } - - else if (enemy_speed_ == BALLOON_SPEED_3) - { - enemy_speed_ = BALLOON_SPEED_2; - } - - else if (enemy_speed_ == BALLOON_SPEED_2) - { - enemy_speed_ = BALLOON_SPEED_1; - } - - setBalloonSpeed(enemy_speed_); - } -} - // Actualiza la velocidad de los globos en funcion del poder acumulado de la fase void Game::updateBalloonSpeed() { const float percent = (float)current_power_ / (float)enemy_formations_->getStage(current_stage_).power_to_complete; - if (enemy_speed_ == BALLOON_SPEED_1) + float old_balloon_speed = balloon_speed_; + + // Comprueba si se ha de modificar la velocidad de los globos + if (balloon_speed_ == BALLOON_SPEED_1 && percent > 0.2f) { - if (percent > 0.2f) - { - incBalloonSpeed(); - } + balloon_speed_ = BALLOON_SPEED_2; } - else if (enemy_speed_ == BALLOON_SPEED_2) + else if (balloon_speed_ == BALLOON_SPEED_2 && percent > 0.4f) { - if (percent > 0.4f) - { - incBalloonSpeed(); - } + balloon_speed_ = BALLOON_SPEED_3; } - else if (enemy_speed_ == BALLOON_SPEED_3) + else if (balloon_speed_ == BALLOON_SPEED_3 && percent > 0.6f) { - if (percent > 0.6f) - { - incBalloonSpeed(); - } + balloon_speed_ = BALLOON_SPEED_4; } - else if (enemy_speed_ == BALLOON_SPEED_4) + else if (balloon_speed_ == BALLOON_SPEED_4 && percent > 0.8f) { - if (percent > 0.8f) - { - incBalloonSpeed(); - } + balloon_speed_ = BALLOON_SPEED_5; + } + + // Si ha habido cambio, se aplica a todos los globos + if (old_balloon_speed != balloon_speed_) + { + setBalloonSpeed(balloon_speed_); } } @@ -1087,11 +1025,11 @@ void Game::popBalloon(std::shared_ptr balloon) } else { // En cualquier otro caso, crea dos globos de un tipo inferior - auto balloon_left = createBalloon(0, balloon->getPosY(), balloon->getKind() - 1, BALLOON_VELX_NEGATIVE, enemy_speed_, 0); + auto balloon_left = createBalloon(0, balloon->getPosY(), balloon->getKind() - 1, BALLOON_VELX_NEGATIVE, balloon_speed_, 0); balloon_left->allignTo(balloon->getPosX() + (balloon->getWidth() / 2)); balloon_left->setVelY(balloon_left->getClass() == BALLOON_CLASS ? -2.50f : BALLOON_VELX_NEGATIVE); - auto balloon_right = createBalloon(0, balloon->getPosY(), balloon->getKind() - 1, BALLOON_VELX_POSITIVE, enemy_speed_, 0); + auto balloon_right = createBalloon(0, balloon->getPosY(), balloon->getKind() - 1, BALLOON_VELX_POSITIVE, balloon_speed_, 0); balloon_right->allignTo(balloon->getPosX() + (balloon->getWidth() / 2)); balloon_right->setVelY(balloon_right->getClass() == BALLOON_CLASS ? -2.50f : BALLOON_VELX_NEGATIVE); @@ -1646,7 +1584,7 @@ void Game::killPlayer(std::shared_ptr &player) // Si tiene cafes if (player->hasExtraHit()) - { + { // Lo pierde player->removeExtraHit(); throwCoffee(player->getPosX() + (player->getWidth() / 2), player->getPosY() + (player->getHeight() / 2)); @@ -1654,7 +1592,7 @@ void Game::killPlayer(std::shared_ptr &player) screen_->shake(); } else - { + { // Si no tiene cafes, muere if (!demo_.enabled) { @@ -1666,7 +1604,7 @@ void Game::killPlayer(std::shared_ptr &player) JA_PlaySound(coffee_out_sound_); player->setStatusPlaying(PlayerStatus::DYING); if (!demo_.enabled) - { + { // En el modo DEMO ni se para la musica ni se añade la puntuación a la tabla allPlayersAreNotPlaying() ? JA_StopMusic() : JA_ResumeMusic(); } @@ -1851,7 +1789,10 @@ void Game::update() updateMenace(); // Actualiza la velocidad de los enemigos - updateBalloonSpeed(); + if (difficulty_ == GameDifficulty::NORMAL) + { + updateBalloonSpeed(); + } // Actualiza el tramo final de juego, una vez completado updateGameCompleted(); @@ -2370,7 +2311,7 @@ void Game::initPaths() // Letrero de STAGE # constexpr auto first_part = STAGE_COUNTER / 4; // 50 - constexpr auto second_part = first_part * 3; // 150 + constexpr auto second_part = first_part * 3; // 150 const auto center_point = param.game.play_area.center_y - (BLOCK * 2); const auto distance = (param.game.play_area.rect.h) - (param.game.play_area.center_y - 16); @@ -2418,7 +2359,7 @@ void Game::initPaths() get_ready_bitmap_path_[i] = (int)finish1; } - else if (i< STAGE_COUNTER) + else if (i < STAGE_COUNTER) { get_ready_bitmap_path_[i] = sin[(int)((i - second_part) * 1.8f)]; get_ready_bitmap_path_[i] *= distance2; @@ -2563,7 +2504,7 @@ void Game::checkEvents() stage.enemy_pool->set[set]->init[i].y, stage.enemy_pool->set[set]->init[i].kind, stage.enemy_pool->set[set]->init[i].vel_x, - enemy_speed_, + balloon_speed_, stage.enemy_pool->set[set]->init[i].creation_counter); } } diff --git a/source/game.h b/source/game.h index fec94ae..7d3812a 100644 --- a/source/game.h +++ b/source/game.h @@ -188,7 +188,7 @@ private: int balloons_popped_; // Lleva la cuenta de los globos explotados int last_enemy_deploy_; // Guarda cual ha sido la última formación desplegada para no repetir; int enemy_deploy_counter_; // Cuando se lanza una formación, se le da un valor y no sale otra hasta que llegue a cero - float enemy_speed_; // Velocidad a la que se mueven los enemigos + float balloon_speed_; // Velocidad a la que se mueven los enemigos float default_enemy_speed_; // Velocidad base de los enemigos, sin incrementar Helper helper_; // Variable para gestionar las ayudas bool power_ball_enabled_; // Indica si hay una powerball ya activa @@ -268,12 +268,6 @@ private: // Establece la velocidad de los globos void setBalloonSpeed(float speed); - // Incrementa la velocidad de los globos - void incBalloonSpeed(); - - // Decrementa la velocidad de los globos - void decBalloonSpeed(); - // Actualiza la velocidad de los globos en funcion del poder acumulado de la fase void updateBalloonSpeed(); diff --git a/source/hiscore_table.h b/source/hiscore_table.h index 8721d63..dac0b4a 100644 --- a/source/hiscore_table.h +++ b/source/hiscore_table.h @@ -70,7 +70,7 @@ private: public: // Constructor - HiScoreTable(JA_Music_t *music); + explicit HiScoreTable(JA_Music_t *music); // Destructor ~HiScoreTable(); diff --git a/source/instructions.h b/source/instructions.h index 1ec620e..e8c6a71 100644 --- a/source/instructions.h +++ b/source/instructions.h @@ -80,7 +80,7 @@ private: public: // Constructor - Instructions(JA_Music_t *music); + explicit Instructions(JA_Music_t *music); // Destructor ~Instructions(); diff --git a/source/intro.h b/source/intro.h index 9c8fc7a..2c2bf5f 100644 --- a/source/intro.h +++ b/source/intro.h @@ -52,7 +52,7 @@ private: public: // Constructor - Intro(JA_Music_t *music); + explicit Intro(JA_Music_t *music); // Destructor ~Intro() = default; diff --git a/source/manage_hiscore_table.h b/source/manage_hiscore_table.h index 525b8fb..7ae1b0f 100644 --- a/source/manage_hiscore_table.h +++ b/source/manage_hiscore_table.h @@ -24,7 +24,7 @@ private: public: // Constructor - ManageHiScoreTable(std::vector *table); + explicit ManageHiScoreTable(std::vector *table); // Destructor ~ManageHiScoreTable() = default; diff --git a/source/title.h b/source/title.h index a0a68cb..9a56482 100644 --- a/source/title.h +++ b/source/title.h @@ -95,7 +95,7 @@ private: public: // Constructor - Title(JA_Music_t *music); + explicit Title(JA_Music_t *music); // Destructor ~Title() = default; diff --git a/source/writer.h b/source/writer.h index e5c29f9..9e1419e 100644 --- a/source/writer.h +++ b/source/writer.h @@ -27,7 +27,7 @@ private: public: // Constructor - Writer(std::shared_ptr text); + explicit Writer(std::shared_ptr text); // Destructor ~Writer() = default;