Afegides recomanacions de cppcheck
Optimitzada la funció updateBalloonSpeed() i eliminades funcions sobrants o redundants
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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> 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> texture)
|
||||
: sprite_(std::make_unique<Sprite>(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<int>(kind_);
|
||||
sprite_ = std::make_unique<Sprite>(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<int>(kind);
|
||||
sprite_->setSpriteClip((kind_index + sprite_offset) * width_, 0, sprite_->getWidth(), sprite_->getHeight());
|
||||
|
||||
collider_.r = width_ / 2;
|
||||
|
||||
@@ -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_; // 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:
|
||||
|
||||
@@ -46,7 +46,7 @@ private:
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
DefineButtons(std::unique_ptr<Text> text);
|
||||
explicit DefineButtons(std::unique_ptr<Text> text);
|
||||
|
||||
// Destructor
|
||||
~DefineButtons() = default;
|
||||
|
||||
@@ -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<std::string> 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<std::string> 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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -54,7 +54,7 @@ private:
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Fade(SDL_Renderer *renderer);
|
||||
explicit Fade(SDL_Renderer *renderer);
|
||||
|
||||
// Destructor
|
||||
~Fade();
|
||||
|
||||
131
source/game.cpp
131
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<Balloon>(x[luck], posY, POWER_BALL, vx[luck], enemy_speed_, 300, balloon_textures_[4], balloon_animations_[4]);
|
||||
auto b = std::make_unique<Balloon>(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> 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> &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> &player)
|
||||
screen_->shake();
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
// Si no tiene cafes, muere
|
||||
if (!demo_.enabled)
|
||||
{
|
||||
@@ -1666,7 +1604,7 @@ void Game::killPlayer(std::shared_ptr<Player> &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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ private:
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
HiScoreTable(JA_Music_t *music);
|
||||
explicit HiScoreTable(JA_Music_t *music);
|
||||
|
||||
// Destructor
|
||||
~HiScoreTable();
|
||||
|
||||
@@ -80,7 +80,7 @@ private:
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Instructions(JA_Music_t *music);
|
||||
explicit Instructions(JA_Music_t *music);
|
||||
|
||||
// Destructor
|
||||
~Instructions();
|
||||
|
||||
@@ -52,7 +52,7 @@ private:
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Intro(JA_Music_t *music);
|
||||
explicit Intro(JA_Music_t *music);
|
||||
|
||||
// Destructor
|
||||
~Intro() = default;
|
||||
|
||||
@@ -24,7 +24,7 @@ private:
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
ManageHiScoreTable(std::vector<HiScoreEntry> *table);
|
||||
explicit ManageHiScoreTable(std::vector<HiScoreEntry> *table);
|
||||
|
||||
// Destructor
|
||||
~ManageHiScoreTable() = default;
|
||||
|
||||
@@ -95,7 +95,7 @@ private:
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Title(JA_Music_t *music);
|
||||
explicit Title(JA_Music_t *music);
|
||||
|
||||
// Destructor
|
||||
~Title() = default;
|
||||
|
||||
@@ -27,7 +27,7 @@ private:
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Writer(std::shared_ptr<Text> text);
|
||||
explicit Writer(std::shared_ptr<Text> text);
|
||||
|
||||
// Destructor
|
||||
~Writer() = default;
|
||||
|
||||
Reference in New Issue
Block a user