.
This commit is contained in:
@@ -4,11 +4,17 @@
|
|||||||
#cppcheck --force --enable=warning,style,performance --std=c++20 \
|
#cppcheck --force --enable=warning,style,performance --std=c++20 \
|
||||||
# --suppressions-list=/home/sergio/gitea/coffee_crisis_arcade_edition/linux-utils/cppcheck_suppressions \
|
# --suppressions-list=/home/sergio/gitea/coffee_crisis_arcade_edition/linux-utils/cppcheck_suppressions \
|
||||||
# /home/sergio/gitea/coffee_crisis_arcade_edition/source/ \
|
# /home/sergio/gitea/coffee_crisis_arcade_edition/source/ \
|
||||||
# 2>/home/sergio/cppcheck-result-warning-style-performance
|
# 2>/home/sergio/cppcheck-result-warning-style-performance.txt
|
||||||
|
|
||||||
# all
|
# all
|
||||||
cppcheck --force --enable=all -I /usr/include --std=c++20 \
|
#cppcheck --force --enable=all -I /usr/include --std=c++20 \
|
||||||
--suppress=missingIncludeSystem \
|
#--suppress=missingIncludeSystem \
|
||||||
--suppressions-list=/home/sergio/gitea/coffee_crisis_arcade_edition/linux-utils/cppcheck_suppressions \
|
#--suppressions-list=/home/sergio/gitea/coffee_crisis_arcade_edition/linux-utils/cppcheck_suppressions \
|
||||||
/home/sergio/gitea/coffee_crisis_arcade_edition/source/ \
|
#/home/sergio/gitea/coffee_crisis_arcade_edition/source/ \
|
||||||
2>/home/sergio/cppcheck-result-all
|
#2>/home/sergio/cppcheck-result-all.txt
|
||||||
|
|
||||||
|
# unusedFunction
|
||||||
|
cppcheck --enable=style --std=c++20 \
|
||||||
|
--suppressions-list=./cppcheck_suppressions \
|
||||||
|
../source/ \
|
||||||
|
2>/home/sergio/cppcheck-result-all.txt
|
||||||
@@ -2,3 +2,7 @@
|
|||||||
*:/home/sergio/gitea/coffee_crisis_arcade_edition/source/gif.c
|
*:/home/sergio/gitea/coffee_crisis_arcade_edition/source/gif.c
|
||||||
*:/home/sergio/gitea/coffee_crisis_arcade_edition/source/jail*
|
*:/home/sergio/gitea/coffee_crisis_arcade_edition/source/jail*
|
||||||
*:/usr/include/*
|
*:/usr/include/*
|
||||||
|
*:../source/stb*
|
||||||
|
*:../source/gif.c
|
||||||
|
*:../source/jail*
|
||||||
|
*:/usr/include/*
|
||||||
@@ -106,42 +106,12 @@ void AnimatedSprite::animate()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece la velocidad de una animación
|
|
||||||
void AnimatedSprite::setAnimationSpeed(int index, int speed)
|
|
||||||
{
|
|
||||||
animations_[index].counter = speed;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece si la animación se reproduce en bucle
|
|
||||||
void AnimatedSprite::setAnimationLoop(int index, int loop)
|
|
||||||
{
|
|
||||||
animations_[index].loop = loop;
|
|
||||||
}
|
|
||||||
|
|
||||||
// OLD - Establece el valor de la variable
|
|
||||||
void AnimatedSprite::setAnimationCompleted(int index, bool value)
|
|
||||||
{
|
|
||||||
animations_[index].completed = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Comprueba si ha terminado la animación
|
// Comprueba si ha terminado la animación
|
||||||
bool AnimatedSprite::animationIsCompleted()
|
bool AnimatedSprite::animationIsCompleted()
|
||||||
{
|
{
|
||||||
return animations_[current_animation_].completed;
|
return animations_[current_animation_].completed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve el rectangulo de una animación y frame concreto
|
|
||||||
SDL_Rect AnimatedSprite::getAnimationClip(const std::string &name, Uint8 index)
|
|
||||||
{
|
|
||||||
return animations_[getIndex(name)].frames[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Devuelve el rectangulo de una animación y frame concreto
|
|
||||||
SDL_Rect AnimatedSprite::getAnimationClip(int indexA, Uint8 indexF)
|
|
||||||
{
|
|
||||||
return animations_[indexA].frames[indexF];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece la animacion actual
|
// Establece la animacion actual
|
||||||
void AnimatedSprite::setCurrentAnimation(const std::string &name)
|
void AnimatedSprite::setCurrentAnimation(const std::string &name)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -52,24 +52,9 @@ public:
|
|||||||
// Actualiza las variables del objeto
|
// Actualiza las variables del objeto
|
||||||
void update() override;
|
void update() override;
|
||||||
|
|
||||||
// Establece la velocidad de una animación
|
|
||||||
void setAnimationSpeed(int index, int speed);
|
|
||||||
|
|
||||||
// Establece el frame al que vuelve la animación al finalizar
|
|
||||||
//void setAnimationLoop(const std::string &name, int loop);
|
|
||||||
void setAnimationLoop(int index, int loop);
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
//void setAnimationCompleted(const std::string &name, bool value);
|
|
||||||
void setAnimationCompleted(int index, bool value);
|
|
||||||
|
|
||||||
// Comprueba si ha terminado la animación
|
// Comprueba si ha terminado la animación
|
||||||
bool animationIsCompleted();
|
bool animationIsCompleted();
|
||||||
|
|
||||||
// Devuelve el rectangulo de una animación y frame concreto
|
|
||||||
SDL_Rect getAnimationClip(const std::string &name = "default", Uint8 index = 0);
|
|
||||||
SDL_Rect getAnimationClip(int indexA = 0, Uint8 indexF = 0);
|
|
||||||
|
|
||||||
// Obtiene el indice de la animación a partir del nombre
|
// Obtiene el indice de la animación a partir del nombre
|
||||||
int getIndex(const std::string &name);
|
int getIndex(const std::string &name);
|
||||||
|
|
||||||
|
|||||||
@@ -248,18 +248,6 @@ void Background::setPos(SDL_Rect pos)
|
|||||||
src_rect_.h = pos.h;
|
src_rect_.h = pos.h;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ajusta el valor de la variable
|
|
||||||
void Background::setSrcRect(SDL_Rect value)
|
|
||||||
{
|
|
||||||
src_rect_ = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ajusta el valor de la variable
|
|
||||||
void Background::setDstRect(SDL_Rect value)
|
|
||||||
{
|
|
||||||
dst_rect_ = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece el color_ de atenuación
|
// Establece el color_ de atenuación
|
||||||
void Background::setColor(Color color)
|
void Background::setColor(Color color)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,12 +32,6 @@ class Texture;
|
|||||||
- setTransition(float value)
|
- setTransition(float value)
|
||||||
Porcentaje (entre 0.0f (textura actual) y 1.0f (textura siguiente)) para mostrar entre la textura de fondo actual y la siguiente
|
Porcentaje (entre 0.0f (textura actual) y 1.0f (textura siguiente)) para mostrar entre la textura de fondo actual y la siguiente
|
||||||
|
|
||||||
- setSrcRect(SDL_Rect value)
|
|
||||||
Rectangulo de la textura de fondo que se desea mostrar
|
|
||||||
|
|
||||||
- setDstRecr(SDL_Rect value)
|
|
||||||
Rectangulo de destino donde se mostrará el rectángulo antrior. Automaticamente modifica srcRect para coincidor en tamaño con el destino.
|
|
||||||
|
|
||||||
- setColor(Color color)
|
- setColor(Color color)
|
||||||
Establece el color de la textura de superposición
|
Establece el color de la textura de superposición
|
||||||
|
|
||||||
@@ -133,12 +127,6 @@ public:
|
|||||||
// Ajusta el valor de la variable
|
// Ajusta el valor de la variable
|
||||||
void setTransition(float value);
|
void setTransition(float value);
|
||||||
|
|
||||||
// Ajusta el valor de la variable
|
|
||||||
void setSrcRect(SDL_Rect value);
|
|
||||||
|
|
||||||
// Ajusta el valor de la variable
|
|
||||||
void setDstRect(SDL_Rect value);
|
|
||||||
|
|
||||||
// Establece el color de atenuación
|
// Establece el color de atenuación
|
||||||
void setColor(Color color);
|
void setColor(Color color);
|
||||||
|
|
||||||
|
|||||||
@@ -1527,17 +1527,19 @@ void Game::initPaths()
|
|||||||
|
|
||||||
for (int i = 0; i < first_part; ++i)
|
for (int i = 0; i < first_part; ++i)
|
||||||
{
|
{
|
||||||
stage_bitmap_path_[i] = (sin[(int)((i * 1.8f) + 90)] * (distance) + center_point);
|
int index = static_cast<int>((i * 1.8f) + 90) % 360;
|
||||||
|
stage_bitmap_path_[i] = sin[index] * distance + center_point;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = first_part; i < second_part; ++i)
|
for (int i = first_part; i < second_part; ++i)
|
||||||
{
|
{
|
||||||
stage_bitmap_path_[i] = (int)center_point;
|
stage_bitmap_path_[i] = center_point;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = second_part; i < STAGE_COUNTER_; ++i)
|
for (int i = second_part; i < STAGE_COUNTER_; ++i)
|
||||||
{
|
{
|
||||||
stage_bitmap_path_[i] = (sin[(int)(((i - 149) * 1.8f) + 90)] * (center_point + 17) - 17);
|
int index = static_cast<int>(((i - 149) * 1.8f) + 90) % 360;
|
||||||
|
stage_bitmap_path_[i] = sin[index] * (center_point + 17) - 17;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Letrero de GetReady
|
// Letrero de GetReady
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ private:
|
|||||||
float default_balloon_speed_; // Velocidad base de los enemigos, sin incrementar
|
float default_balloon_speed_; // Velocidad base de los enemigos, sin incrementar
|
||||||
float difficulty_score_multiplier_; // Multiplicador de puntos en función de la dificultad
|
float difficulty_score_multiplier_; // Multiplicador de puntos en función de la dificultad
|
||||||
float get_ready_bitmap_path_[STAGE_COUNTER_]; // Vector con los puntos X por donde se desplaza el texto
|
float get_ready_bitmap_path_[STAGE_COUNTER_]; // Vector con los puntos X por donde se desplaza el texto
|
||||||
float stage_bitmap_path_[STAGE_COUNTER_]; // Vector con los puntos Y por donde se desplaza el texto
|
int stage_bitmap_path_[STAGE_COUNTER_]; // Vector con los puntos Y por donde se desplaza el texto
|
||||||
int balloon_deploy_counter_ = 0; // Cuando se lanza una formación, se le da un valor y no sale otra hasta que llegue a cero
|
int balloon_deploy_counter_ = 0; // Cuando se lanza una formación, se le da un valor y no sale otra hasta que llegue a cero
|
||||||
int balloons_popped_ = 0; // Lleva la cuenta de los globos explotados
|
int balloons_popped_ = 0; // Lleva la cuenta de los globos explotados
|
||||||
int counter_ = 0; // Contador para el juego
|
int counter_ = 0; // Contador para el juego
|
||||||
|
|||||||
@@ -6,10 +6,6 @@ MovingSprite::MovingSprite(std::shared_ptr<Texture> texture, SDL_Rect pos, Rotat
|
|||||||
: Sprite(texture, pos),
|
: Sprite(texture, pos),
|
||||||
x_(pos.x),
|
x_(pos.x),
|
||||||
y_(pos.y),
|
y_(pos.y),
|
||||||
vx_(0.0f),
|
|
||||||
vy_(0.0f),
|
|
||||||
ax_(0.0f),
|
|
||||||
ay_(0.0f),
|
|
||||||
rotate_(rotate),
|
rotate_(rotate),
|
||||||
zoom_w_(zoom_w),
|
zoom_w_(zoom_w),
|
||||||
zoom_h_(zoom_h),
|
zoom_h_(zoom_h),
|
||||||
@@ -19,10 +15,6 @@ MovingSprite::MovingSprite(std::shared_ptr<Texture> texture, SDL_Rect pos)
|
|||||||
: Sprite(texture, pos),
|
: Sprite(texture, pos),
|
||||||
x_(pos.x),
|
x_(pos.x),
|
||||||
y_(pos.y),
|
y_(pos.y),
|
||||||
vx_(0.0f),
|
|
||||||
vy_(0.0f),
|
|
||||||
ax_(0.0f),
|
|
||||||
ay_(0.0f),
|
|
||||||
rotate_(Rotate()),
|
rotate_(Rotate()),
|
||||||
zoom_w_(1.0f),
|
zoom_w_(1.0f),
|
||||||
zoom_h_(1.0f),
|
zoom_h_(1.0f),
|
||||||
@@ -32,10 +24,6 @@ MovingSprite::MovingSprite(std::shared_ptr<Texture> texture)
|
|||||||
: Sprite(texture),
|
: Sprite(texture),
|
||||||
x_(0.0f),
|
x_(0.0f),
|
||||||
y_(0.0f),
|
y_(0.0f),
|
||||||
vx_(0.0f),
|
|
||||||
vy_(0.0f),
|
|
||||||
ax_(0.0f),
|
|
||||||
ay_(0.0f),
|
|
||||||
rotate_(Rotate()),
|
rotate_(Rotate()),
|
||||||
zoom_w_(1.0f),
|
zoom_w_(1.0f),
|
||||||
zoom_h_(1.0f),
|
zoom_h_(1.0f),
|
||||||
@@ -89,24 +77,6 @@ void MovingSprite::render()
|
|||||||
texture_->render(pos_.x, pos_.y, &sprite_clip_, zoom_w_, zoom_h_, rotate_.angle, rotate_.center, flip_);
|
texture_->render(pos_.x, pos_.y, &sprite_clip_, zoom_w_, zoom_h_, rotate_.angle, rotate_.center, flip_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
float MovingSprite::getZoomW() const
|
|
||||||
{
|
|
||||||
return zoom_w_;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
float MovingSprite::getZoomH() const
|
|
||||||
{
|
|
||||||
return zoom_h_;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
double MovingSprite::getAngle() const
|
|
||||||
{
|
|
||||||
return rotate_.angle;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void MovingSprite::setZoomW(float value)
|
void MovingSprite::setZoomW(float value)
|
||||||
{
|
{
|
||||||
@@ -137,12 +107,6 @@ bool MovingSprite::isRotating() const
|
|||||||
return rotate_.enabled;
|
return rotate_.enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
int MovingSprite::getRotateSpeed() const
|
|
||||||
{
|
|
||||||
return rotate_.speed;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece la rotacion
|
// Establece la rotacion
|
||||||
void MovingSprite::rotate()
|
void MovingSprite::rotate()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,11 +27,11 @@ protected:
|
|||||||
float x_; // Posición en el eje X
|
float x_; // Posición en el eje X
|
||||||
float y_; // Posición en el eje Y
|
float y_; // Posición en el eje Y
|
||||||
|
|
||||||
float vx_; // Velocidad en el eje X. Cantidad de pixeles a desplazarse
|
float vx_ = 0.0f; // Velocidad en el eje X. Cantidad de pixeles a desplazarse
|
||||||
float vy_; // Velocidad en el eje Y. Cantidad de pixeles a desplazarse
|
float vy_ = 0.0f; // Velocidad en el eje Y. Cantidad de pixeles a desplazarse
|
||||||
|
|
||||||
float ax_; // Aceleración en el eje X. Variación de la velocidad
|
float ax_ = 0.0f; // Aceleración en el eje X. Variación de la velocidad
|
||||||
float ay_; // Aceleración en el eje Y. Variación de la velocidad
|
float ay_ = 0.0f; // Aceleración en el eje Y. Variación de la velocidad
|
||||||
|
|
||||||
Rotate rotate_; // Variables usada para controlar la rotación del sprite
|
Rotate rotate_; // Variables usada para controlar la rotación del sprite
|
||||||
float zoom_w_; // Zoom aplicado a la anchura
|
float zoom_w_; // Zoom aplicado a la anchura
|
||||||
@@ -79,14 +79,8 @@ public:
|
|||||||
void setAccelX(float value);
|
void setAccelX(float value);
|
||||||
void setAccelY(float value);
|
void setAccelY(float value);
|
||||||
|
|
||||||
// Obten el valor de la variable
|
|
||||||
float getZoomW() const;
|
|
||||||
float getZoomH() const;
|
|
||||||
|
|
||||||
// Obten el valor de la variable
|
// Obten el valor de la variable
|
||||||
bool isRotating() const;
|
bool isRotating() const;
|
||||||
double getAngle() const;
|
|
||||||
int getRotateSpeed() const;
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setZoomW(float value);
|
void setZoomW(float value);
|
||||||
|
|||||||
@@ -237,8 +237,6 @@ void Notifier::showText(std::string text1, std::string text2, int icon, const st
|
|||||||
n.code = code;
|
n.code = code;
|
||||||
n.y = offset;
|
n.y = offset;
|
||||||
n.travel_dist = travel_dist;
|
n.travel_dist = travel_dist;
|
||||||
n.counter = 0;
|
|
||||||
n.status = NotificationStatus::RISING;
|
|
||||||
n.text1 = text1;
|
n.text1 = text1;
|
||||||
n.text2 = text2;
|
n.text2 = text2;
|
||||||
n.shape = shape;
|
n.shape = shape;
|
||||||
|
|||||||
@@ -25,18 +25,6 @@ private:
|
|||||||
FINISHED,
|
FINISHED,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class NotificationPosition
|
|
||||||
{
|
|
||||||
UPPER_LEFT,
|
|
||||||
UPPER_CENTER,
|
|
||||||
UPPER_RIGHT,
|
|
||||||
MIDDLE_LEFT,
|
|
||||||
MIDDLE_RIGHT,
|
|
||||||
BOTTOM_LEFT,
|
|
||||||
BOTTOM_CENTER,
|
|
||||||
BOTTOM_RIGHT,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class NotificationShape
|
enum class NotificationShape
|
||||||
{
|
{
|
||||||
ROUNDED,
|
ROUNDED,
|
||||||
@@ -51,15 +39,16 @@ private:
|
|||||||
std::string text2;
|
std::string text2;
|
||||||
int counter;
|
int counter;
|
||||||
NotificationStatus status;
|
NotificationStatus status;
|
||||||
NotificationPosition position;
|
|
||||||
NotificationShape shape;
|
NotificationShape shape;
|
||||||
SDL_Rect rect;
|
SDL_Rect rect;
|
||||||
int y;
|
int y;
|
||||||
int travel_dist;
|
int travel_dist;
|
||||||
std::string code; // Permite asignar un código a la notificación
|
std::string code; // Permite asignar un código a la notificación
|
||||||
|
|
||||||
// Constructor vacío
|
// Constructor
|
||||||
Notification() = default;
|
explicit Notification()
|
||||||
|
: texture(nullptr), sprite(nullptr), text1(""), text2(""), counter(0), status(NotificationStatus::RISING),
|
||||||
|
shape(NotificationShape::SQUARED), rect{0, 0, 0, 0}, y(0), travel_dist(0), code("") {}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ private:
|
|||||||
Color color; // Color del efecto
|
Color color; // Color del efecto
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
FlashEffect(bool en = false, int cnt = 0, int len = 0, Color col = Color(0xFF, 0xFF, 0xFF))
|
explicit FlashEffect(bool en = false, int cnt = 0, int len = 0, Color col = Color(0xFF, 0xFF, 0xFF))
|
||||||
: enabled(en), counter(cnt), lenght(len), color(col) {}
|
: enabled(en), counter(cnt), lenght(len), color(col) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ private:
|
|||||||
bool enabled; // Indica si el efecto está activo
|
bool enabled; // Indica si el efecto está activo
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
ShakeEffect(bool en = false, int dp = 2, int dl = 3, int cnt = 0, int len = 8, int rem = 0, int origPos = 0, int origWidth = param.game.width)
|
explicit ShakeEffect(bool en = false, int dp = 2, int dl = 3, int cnt = 0, int len = 8, int rem = 0, int origPos = 0, int origWidth = param.game.width)
|
||||||
: desp(dp), delay(dl), counter(cnt), lenght(len), remaining(rem), originalPos(origPos), originalWidth(origWidth), enabled(en) {}
|
: desp(dp), delay(dl), counter(cnt), lenght(len), remaining(rem), originalPos(origPos), originalWidth(origWidth), enabled(en) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -34,18 +34,6 @@ void SmartSprite::setDestY(int y)
|
|||||||
dest_y_ = y;
|
dest_y_ = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
int SmartSprite::getDestX() const
|
|
||||||
{
|
|
||||||
return dest_x_;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
int SmartSprite::getDestY() const
|
|
||||||
{
|
|
||||||
return dest_y_;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Comprueba el movimiento
|
// Comprueba el movimiento
|
||||||
void SmartSprite::checkMove()
|
void SmartSprite::checkMove()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user