Afegides recomanacions de cppcheck

Optimitzada la funció updateBalloonSpeed() i eliminades funcions sobrants o redundants
This commit is contained in:
2024-10-13 11:03:50 +02:00
parent 22d457285d
commit c11a868289
19 changed files with 221 additions and 499 deletions

View File

@@ -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> texture, std::vector<std::string> *animation)
: kind_(kind), speed_(speed)
: sprite_(std::make_unique<AnimatedSprite>(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<AnimatedSprite>(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;