jugant amb clang-tidy
This commit is contained in:
1
.clang-format-ignore
Normal file
1
.clang-format-ignore
Normal file
@@ -0,0 +1 @@
|
|||||||
|
source/external/**
|
||||||
@@ -2,8 +2,8 @@ Checks: >
|
|||||||
readability-identifier-naming
|
readability-identifier-naming
|
||||||
|
|
||||||
WarningsAsErrors: '*'
|
WarningsAsErrors: '*'
|
||||||
# Excluir directorios third_party, external, vendor, etc.
|
# Solo incluir archivos de tu código fuente
|
||||||
HeaderFilterRegex: '^(?!.*(third_party|external|vendor|libs)).*'
|
HeaderFilterRegex: '^source/(sections|ui)/.*'
|
||||||
FormatStyle: file
|
FormatStyle: file
|
||||||
|
|
||||||
CheckOptions:
|
CheckOptions:
|
||||||
|
|||||||
@@ -74,20 +74,20 @@ Background::Background()
|
|||||||
|
|
||||||
// Inicializa objetos
|
// Inicializa objetos
|
||||||
{
|
{
|
||||||
constexpr float top_clouds_speed = 0.1f;
|
constexpr float TOP_CLOUDS_SPEED = 0.1f;
|
||||||
constexpr float bottom_clouds_speed = 0.05f;
|
constexpr float BOTTOM_CLOUDS_SPEED = 0.05f;
|
||||||
|
|
||||||
top_clouds_sprite_a_->setSpriteClip(0, 0, top_clouds_texture_->getWidth(), top_clouds_texture_->getHeight());
|
top_clouds_sprite_a_->setSpriteClip(0, 0, top_clouds_texture_->getWidth(), top_clouds_texture_->getHeight());
|
||||||
top_clouds_sprite_a_->setVelX(-top_clouds_speed);
|
top_clouds_sprite_a_->setVelX(-TOP_CLOUDS_SPEED);
|
||||||
|
|
||||||
top_clouds_sprite_b_->setSpriteClip(0, 0, top_clouds_texture_->getWidth(), top_clouds_texture_->getHeight());
|
top_clouds_sprite_b_->setSpriteClip(0, 0, top_clouds_texture_->getWidth(), top_clouds_texture_->getHeight());
|
||||||
top_clouds_sprite_b_->setVelX(-top_clouds_speed);
|
top_clouds_sprite_b_->setVelX(-TOP_CLOUDS_SPEED);
|
||||||
|
|
||||||
bottom_clouds_sprite_a_->setSpriteClip(0, 0, bottom_clouds_texture_->getWidth(), bottom_clouds_texture_->getHeight());
|
bottom_clouds_sprite_a_->setSpriteClip(0, 0, bottom_clouds_texture_->getWidth(), bottom_clouds_texture_->getHeight());
|
||||||
bottom_clouds_sprite_a_->setVelX(-bottom_clouds_speed);
|
bottom_clouds_sprite_a_->setVelX(-BOTTOM_CLOUDS_SPEED);
|
||||||
|
|
||||||
bottom_clouds_sprite_b_->setSpriteClip(0, 0, bottom_clouds_texture_->getWidth(), bottom_clouds_texture_->getHeight());
|
bottom_clouds_sprite_b_->setSpriteClip(0, 0, bottom_clouds_texture_->getWidth(), bottom_clouds_texture_->getHeight());
|
||||||
bottom_clouds_sprite_b_->setVelX(-bottom_clouds_speed);
|
bottom_clouds_sprite_b_->setVelX(-BOTTOM_CLOUDS_SPEED);
|
||||||
|
|
||||||
buildings_sprite_->setY(base_ - buildings_sprite_->getHeight());
|
buildings_sprite_->setY(base_ - buildings_sprite_->getHeight());
|
||||||
grass_sprite_->setY(base_ - grass_sprite_->getHeight());
|
grass_sprite_->setY(base_ - grass_sprite_->getHeight());
|
||||||
@@ -317,13 +317,13 @@ void Background::updateClouds() {
|
|||||||
// Precalcula el vector con el recorrido del sol
|
// Precalcula el vector con el recorrido del sol
|
||||||
void Background::createSunPath() {
|
void Background::createSunPath() {
|
||||||
constexpr float CENTER_X = 170;
|
constexpr float CENTER_X = 170;
|
||||||
const float center_y = base_ - 80;
|
const float CENTER_Y = base_ - 80;
|
||||||
constexpr float RADIUS = 120;
|
constexpr float RADIUS = 120;
|
||||||
|
|
||||||
// Generar puntos de la curva desde 90 a 180 grados
|
// Generar puntos de la curva desde 90 a 180 grados
|
||||||
for (double theta = M_PI / 2; theta <= M_PI; theta += 0.01) {
|
for (double theta = M_PI / 2; theta <= M_PI; theta += 0.01) {
|
||||||
float x = CENTER_X + (RADIUS * cos(theta));
|
float x = CENTER_X + (RADIUS * cos(theta));
|
||||||
float y = center_y - (RADIUS * sin(theta));
|
float y = CENTER_Y - (RADIUS * sin(theta));
|
||||||
sun_path_.push_back({x, y});
|
sun_path_.push_back({x, y});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,13 +338,13 @@ void Background::createSunPath() {
|
|||||||
// Precalcula el vector con el recorrido de la luna
|
// Precalcula el vector con el recorrido de la luna
|
||||||
void Background::createMoonPath() {
|
void Background::createMoonPath() {
|
||||||
constexpr float CENTER_X = 100;
|
constexpr float CENTER_X = 100;
|
||||||
const float center_y = base_ - 50;
|
const float CENTER_Y = base_ - 50;
|
||||||
constexpr float RADIUS = 140;
|
constexpr float RADIUS = 140;
|
||||||
|
|
||||||
// Generar puntos de la curva desde 0 a 90 grados
|
// Generar puntos de la curva desde 0 a 90 grados
|
||||||
for (double theta = 0; theta <= M_PI / 2; theta += 0.01) {
|
for (double theta = 0; theta <= M_PI / 2; theta += 0.01) {
|
||||||
float x = CENTER_X + (RADIUS * cos(theta));
|
float x = CENTER_X + (RADIUS * cos(theta));
|
||||||
float y = center_y - (RADIUS * sin(theta));
|
float y = CENTER_Y - (RADIUS * sin(theta));
|
||||||
moon_path_.push_back({x, y});
|
moon_path_.push_back({x, y});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,15 +30,15 @@ Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel
|
|||||||
vy_ = 0;
|
vy_ = 0;
|
||||||
max_vy_ = 3.0f;
|
max_vy_ = 3.0f;
|
||||||
|
|
||||||
const int index = static_cast<int>(size_);
|
const int INDEX = static_cast<int>(size_);
|
||||||
gravity_ = param.balloon.settings.at(index).grav;
|
gravity_ = param.balloon.settings.at(INDEX).grav;
|
||||||
default_vy_ = param.balloon.settings.at(index).vel;
|
default_vy_ = param.balloon.settings.at(INDEX).vel;
|
||||||
h_ = w_ = BALLOON_SIZE[index];
|
h_ = w_ = BALLOON_SIZE[INDEX];
|
||||||
power_ = BALLOON_POWER[index];
|
power_ = BALLOON_POWER[INDEX];
|
||||||
menace_ = BALLOON_MENACE[index];
|
menace_ = BALLOON_MENACE[INDEX];
|
||||||
score_ = BALLOON_SCORE[index];
|
score_ = BALLOON_SCORE[INDEX];
|
||||||
bouncing_sound_ = BALLOON_BOUNCING_SOUND[index];
|
bouncing_sound_ = BALLOON_BOUNCING_SOUND[INDEX];
|
||||||
popping_sound_ = BALLOON_POPPING_SOUND[index];
|
popping_sound_ = BALLOON_POPPING_SOUND[INDEX];
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -47,19 +47,19 @@ Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel
|
|||||||
default_vy_ = max_vy_ = vy_ = fabs(vx_ * 2.0f);
|
default_vy_ = max_vy_ = vy_ = fabs(vx_ * 2.0f);
|
||||||
gravity_ = 0.00f;
|
gravity_ = 0.00f;
|
||||||
|
|
||||||
const int index = static_cast<int>(size_);
|
const int INDEX = static_cast<int>(size_);
|
||||||
h_ = w_ = BALLOON_SIZE[index];
|
h_ = w_ = BALLOON_SIZE[INDEX];
|
||||||
power_ = BALLOON_POWER[index];
|
power_ = BALLOON_POWER[INDEX];
|
||||||
menace_ = BALLOON_MENACE[index];
|
menace_ = BALLOON_MENACE[INDEX];
|
||||||
score_ = BALLOON_SCORE[index];
|
score_ = BALLOON_SCORE[INDEX];
|
||||||
bouncing_sound_ = BALLOON_BOUNCING_SOUND[index];
|
bouncing_sound_ = BALLOON_BOUNCING_SOUND[INDEX];
|
||||||
popping_sound_ = BALLOON_POPPING_SOUND[index];
|
popping_sound_ = BALLOON_POPPING_SOUND[INDEX];
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case BalloonType::POWERBALL: {
|
case BalloonType::POWERBALL: {
|
||||||
constexpr int index = 3;
|
constexpr int INDEX = 3;
|
||||||
h_ = w_ = BALLOON_SIZE[4];
|
h_ = w_ = BALLOON_SIZE[4];
|
||||||
bouncing_sound_ = BALLOON_BOUNCING_SOUND[3];
|
bouncing_sound_ = BALLOON_BOUNCING_SOUND[3];
|
||||||
popping_sound_ = "power_ball_explosion.wav";
|
popping_sound_ = "power_ball_explosion.wav";
|
||||||
@@ -67,8 +67,8 @@ Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel
|
|||||||
|
|
||||||
vy_ = 0;
|
vy_ = 0;
|
||||||
max_vy_ = 3.0f;
|
max_vy_ = 3.0f;
|
||||||
gravity_ = param.balloon.settings.at(index).grav;
|
gravity_ = param.balloon.settings.at(INDEX).grav;
|
||||||
default_vy_ = param.balloon.settings.at(index).vel;
|
default_vy_ = param.balloon.settings.at(INDEX).vel;
|
||||||
|
|
||||||
sprite_->setRotate(creation_timer <= 0);
|
sprite_->setRotate(creation_timer <= 0);
|
||||||
sprite_->setRotateAmount(vx_ > 0.0f ? 2.0 : -2.0);
|
sprite_->setRotateAmount(vx_ > 0.0f ? 2.0 : -2.0);
|
||||||
@@ -96,9 +96,9 @@ Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel
|
|||||||
// Centra el globo en la posición X
|
// Centra el globo en la posición X
|
||||||
void Balloon::alignTo(int x) {
|
void Balloon::alignTo(int x) {
|
||||||
x_ = static_cast<float>(x - (w_ / 2));
|
x_ = static_cast<float>(x - (w_ / 2));
|
||||||
const int min_x = play_area_.x;
|
const int MIN_X = play_area_.x;
|
||||||
const int max_x = play_area_.w - w_;
|
const int MAX_X = play_area_.w - w_;
|
||||||
x_ = std::clamp(x_, static_cast<float>(min_x), static_cast<float>(max_x));
|
x_ = std::clamp(x_, static_cast<float>(MIN_X), static_cast<float>(MAX_X));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pinta el globo en la pantalla
|
// Pinta el globo en la pantalla
|
||||||
@@ -146,13 +146,13 @@ void Balloon::move() {
|
|||||||
x_ += vx_ * speed_;
|
x_ += vx_ * speed_;
|
||||||
|
|
||||||
// Colisión en las partes laterales de la zona de juego
|
// Colisión en las partes laterales de la zona de juego
|
||||||
const int clip = 2;
|
const int CLIP = 2;
|
||||||
const float min_x = play_area_.x - clip;
|
const float MIN_X = play_area_.x - CLIP;
|
||||||
const float max_x = play_area_.x + play_area_.w - w_ + clip;
|
const float MAX_X = play_area_.x + play_area_.w - w_ + CLIP;
|
||||||
if (x_ < min_x || x_ > max_x) {
|
if (x_ < MIN_X || x_ > MAX_X) {
|
||||||
if (bouncing_sound_enabled_)
|
if (bouncing_sound_enabled_)
|
||||||
playSound(bouncing_sound_);
|
playSound(bouncing_sound_);
|
||||||
x_ = std::clamp(x_, min_x, max_x);
|
x_ = std::clamp(x_, MIN_X, MAX_X);
|
||||||
vx_ = -vx_;
|
vx_ = -vx_;
|
||||||
// Activa el efecto de rebote o invierte la rotación
|
// Activa el efecto de rebote o invierte la rotación
|
||||||
if (type_ == BalloonType::POWERBALL) {
|
if (type_ == BalloonType::POWERBALL) {
|
||||||
@@ -167,22 +167,22 @@ void Balloon::move() {
|
|||||||
|
|
||||||
// Colisión en la parte superior solo si el globo va de subida
|
// Colisión en la parte superior solo si el globo va de subida
|
||||||
if (vy_ < 0) {
|
if (vy_ < 0) {
|
||||||
const int min_y = play_area_.y;
|
const int MIN_Y = play_area_.y;
|
||||||
if (y_ < min_y) {
|
if (y_ < MIN_Y) {
|
||||||
if (bouncing_sound_enabled_)
|
if (bouncing_sound_enabled_)
|
||||||
playSound(bouncing_sound_);
|
playSound(bouncing_sound_);
|
||||||
y_ = min_y;
|
y_ = MIN_Y;
|
||||||
vy_ = -vy_;
|
vy_ = -vy_;
|
||||||
enableBounce();
|
enableBounce();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Colisión en la parte inferior de la zona de juego
|
// Colisión en la parte inferior de la zona de juego
|
||||||
const int max_y = play_area_.y + play_area_.h - h_;
|
const int MAX_Y = play_area_.y + play_area_.h - h_;
|
||||||
if (y_ > max_y) {
|
if (y_ > MAX_Y) {
|
||||||
if (bouncing_sound_enabled_)
|
if (bouncing_sound_enabled_)
|
||||||
playSound(bouncing_sound_);
|
playSound(bouncing_sound_);
|
||||||
y_ = max_y;
|
y_ = MAX_Y;
|
||||||
vy_ = -default_vy_;
|
vy_ = -default_vy_;
|
||||||
if (type_ != BalloonType::POWERBALL) {
|
if (type_ != BalloonType::POWERBALL) {
|
||||||
enableBounce();
|
enableBounce();
|
||||||
@@ -240,10 +240,10 @@ void Balloon::updateState() {
|
|||||||
x_ += vx_;
|
x_ += vx_;
|
||||||
|
|
||||||
// Comprueba no se salga por los laterales
|
// Comprueba no se salga por los laterales
|
||||||
const int min_x = play_area_.x;
|
const int MIN_X = play_area_.x;
|
||||||
const int max_x = play_area_.w - w_;
|
const int MAX_X = play_area_.w - w_;
|
||||||
|
|
||||||
if (x_ < min_x || x_ > max_x) {
|
if (x_ < MIN_X || x_ > MAX_X) {
|
||||||
// Corrige y cambia el sentido de la velocidad
|
// Corrige y cambia el sentido de la velocidad
|
||||||
x_ -= vx_;
|
x_ -= vx_;
|
||||||
vx_ = -vx_;
|
vx_ = -vx_;
|
||||||
@@ -340,9 +340,9 @@ void Balloon::disableBounce() {
|
|||||||
// Aplica el efecto
|
// Aplica el efecto
|
||||||
void Balloon::updateBounce() {
|
void Balloon::updateBounce() {
|
||||||
if (bouncing_.enabled) {
|
if (bouncing_.enabled) {
|
||||||
const int index = bouncing_.counter / bouncing_.speed;
|
const int INDEX = bouncing_.counter / bouncing_.speed;
|
||||||
bouncing_.zoomW = bouncing_.w[index];
|
bouncing_.zoomW = bouncing_.w[INDEX];
|
||||||
bouncing_.zoomH = bouncing_.h[index];
|
bouncing_.zoomH = bouncing_.h[INDEX];
|
||||||
|
|
||||||
zoomSprite();
|
zoomSprite();
|
||||||
|
|
||||||
@@ -371,8 +371,8 @@ void Balloon::playSound(const std::string &name) {
|
|||||||
if (!sound_enabled_)
|
if (!sound_enabled_)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
static auto audio = Audio::get();
|
static auto audio_ = Audio::get();
|
||||||
audio->playSound(name);
|
audio_->playSound(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Explota el globo
|
// Explota el globo
|
||||||
|
|||||||
@@ -5,22 +5,22 @@
|
|||||||
#include "utils.h" // Para ParamGame, Param, Zone, BLOCK
|
#include "utils.h" // Para ParamGame, Param, Zone, BLOCK
|
||||||
|
|
||||||
void BalloonFormations::initBalloonFormations() {
|
void BalloonFormations::initBalloonFormations() {
|
||||||
constexpr int y4 = -BLOCK;
|
constexpr int Y4 = -BLOCK;
|
||||||
const int x4_0 = param.game.play_area.rect.x;
|
const int X4_0 = param.game.play_area.rect.x;
|
||||||
const int x4_100 = param.game.play_area.rect.w - BALLOON_SIZE[3];
|
const int X4_100 = param.game.play_area.rect.w - BALLOON_SIZE[3];
|
||||||
|
|
||||||
constexpr int y3 = -BLOCK;
|
constexpr int Y3 = -BLOCK;
|
||||||
const int x3_0 = param.game.play_area.rect.x;
|
const int X3_0 = param.game.play_area.rect.x;
|
||||||
const int x3_100 = param.game.play_area.rect.w - BALLOON_SIZE[2];
|
const int X3_100 = param.game.play_area.rect.w - BALLOON_SIZE[2];
|
||||||
|
|
||||||
constexpr int y2 = -BLOCK;
|
constexpr int Y2 = -BLOCK;
|
||||||
const int x2_0 = param.game.play_area.rect.x;
|
const int X2_0 = param.game.play_area.rect.x;
|
||||||
const int x2_100 = param.game.play_area.rect.w - BALLOON_SIZE[1];
|
const int X2_100 = param.game.play_area.rect.w - BALLOON_SIZE[1];
|
||||||
|
|
||||||
constexpr int y1 = -BLOCK;
|
constexpr int Y1 = -BLOCK;
|
||||||
const int x1_0 = param.game.play_area.rect.x;
|
const int X1_0 = param.game.play_area.rect.x;
|
||||||
const int x1_50 = param.game.play_area.center_x - (BALLOON_SIZE[0] / 2);
|
const int X1_50 = param.game.play_area.center_x - (BALLOON_SIZE[0] / 2);
|
||||||
const int x1_100 = param.game.play_area.rect.w - BALLOON_SIZE[0];
|
const int X1_100 = param.game.play_area.rect.w - BALLOON_SIZE[0];
|
||||||
|
|
||||||
balloon_formation_.reserve(NUMBER_OF_BALLOON_FORMATIONS);
|
balloon_formation_.reserve(NUMBER_OF_BALLOON_FORMATIONS);
|
||||||
|
|
||||||
@@ -29,16 +29,16 @@ void BalloonFormations::initBalloonFormations() {
|
|||||||
// #00 - Dos enemigos BALLOON4 uno a cada extremo
|
// #00 - Dos enemigos BALLOON4 uno a cada extremo
|
||||||
{
|
{
|
||||||
std::vector<BalloonFormationParams> init_params = {
|
std::vector<BalloonFormationParams> init_params = {
|
||||||
BalloonFormationParams(x4_0, y4, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME),
|
BalloonFormationParams(X4_0, Y4, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME),
|
||||||
BalloonFormationParams(x4_100, y4, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME)};
|
BalloonFormationParams(X4_100, Y4, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME)};
|
||||||
balloon_formation_.emplace_back(2, init_params);
|
balloon_formation_.emplace_back(2, init_params);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #01 - Dos enemigos BALLOON4 uno a cada cuarto. Ambos van hacia el centro
|
// #01 - Dos enemigos BALLOON4 uno a cada cuarto. Ambos van hacia el centro
|
||||||
{
|
{
|
||||||
std::vector<BalloonFormationParams> init_params = {
|
std::vector<BalloonFormationParams> init_params = {
|
||||||
BalloonFormationParams(param.game.play_area.first_quarter_x - (BALLOON_SIZE[3] / 2), y4, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME),
|
BalloonFormationParams(param.game.play_area.first_quarter_x - (BALLOON_SIZE[3] / 2), Y4, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME),
|
||||||
BalloonFormationParams(param.game.play_area.third_quarter_x - (BALLOON_SIZE[3] / 2), y4, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME)};
|
BalloonFormationParams(param.game.play_area.third_quarter_x - (BALLOON_SIZE[3] / 2), Y4, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME)};
|
||||||
balloon_formation_.emplace_back(2, init_params);
|
balloon_formation_.emplace_back(2, init_params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ void BalloonFormations::initBalloonFormations() {
|
|||||||
{
|
{
|
||||||
std::vector<BalloonFormationParams> init_params;
|
std::vector<BalloonFormationParams> init_params;
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
init_params.emplace_back(x2_0 + (i * (BALLOON_SIZE[1] + 1)), y2, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE2, CREATION_TIME - (10 * i));
|
init_params.emplace_back(X2_0 + (i * (BALLOON_SIZE[1] + 1)), Y2, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE2, CREATION_TIME - (10 * i));
|
||||||
}
|
}
|
||||||
balloon_formation_.emplace_back(4, init_params);
|
balloon_formation_.emplace_back(4, init_params);
|
||||||
}
|
}
|
||||||
@@ -55,7 +55,7 @@ void BalloonFormations::initBalloonFormations() {
|
|||||||
{
|
{
|
||||||
std::vector<BalloonFormationParams> init_params;
|
std::vector<BalloonFormationParams> init_params;
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
init_params.emplace_back(x2_100 - (i * (BALLOON_SIZE[1] + 1)), y2, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE2, CREATION_TIME - (10 * i));
|
init_params.emplace_back(X2_100 - (i * (BALLOON_SIZE[1] + 1)), Y2, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE2, CREATION_TIME - (10 * i));
|
||||||
}
|
}
|
||||||
balloon_formation_.emplace_back(4, init_params);
|
balloon_formation_.emplace_back(4, init_params);
|
||||||
}
|
}
|
||||||
@@ -64,7 +64,7 @@ void BalloonFormations::initBalloonFormations() {
|
|||||||
{
|
{
|
||||||
std::vector<BalloonFormationParams> init_params;
|
std::vector<BalloonFormationParams> init_params;
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
init_params.emplace_back(x3_0 + (i * (BALLOON_SIZE[2] * 2)), y3, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i));
|
init_params.emplace_back(X3_0 + (i * (BALLOON_SIZE[2] * 2)), Y3, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i));
|
||||||
}
|
}
|
||||||
balloon_formation_.emplace_back(3, init_params);
|
balloon_formation_.emplace_back(3, init_params);
|
||||||
}
|
}
|
||||||
@@ -73,7 +73,7 @@ void BalloonFormations::initBalloonFormations() {
|
|||||||
{
|
{
|
||||||
std::vector<BalloonFormationParams> init_params;
|
std::vector<BalloonFormationParams> init_params;
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
init_params.emplace_back(x3_100 - (i * (BALLOON_SIZE[2] * 2)), y3, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i));
|
init_params.emplace_back(X3_100 - (i * (BALLOON_SIZE[2] * 2)), Y3, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i));
|
||||||
}
|
}
|
||||||
balloon_formation_.emplace_back(3, init_params);
|
balloon_formation_.emplace_back(3, init_params);
|
||||||
}
|
}
|
||||||
@@ -82,7 +82,7 @@ void BalloonFormations::initBalloonFormations() {
|
|||||||
{
|
{
|
||||||
std::vector<BalloonFormationParams> init_params;
|
std::vector<BalloonFormationParams> init_params;
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
init_params.emplace_back(x3_0 + (i * (BALLOON_SIZE[2] + 1)), y3, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i));
|
init_params.emplace_back(X3_0 + (i * (BALLOON_SIZE[2] + 1)), Y3, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i));
|
||||||
}
|
}
|
||||||
balloon_formation_.emplace_back(3, init_params);
|
balloon_formation_.emplace_back(3, init_params);
|
||||||
}
|
}
|
||||||
@@ -91,7 +91,7 @@ void BalloonFormations::initBalloonFormations() {
|
|||||||
{
|
{
|
||||||
std::vector<BalloonFormationParams> init_params;
|
std::vector<BalloonFormationParams> init_params;
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
init_params.emplace_back(x3_100 - (i * (BALLOON_SIZE[2] + 1)), y3, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i));
|
init_params.emplace_back(X3_100 - (i * (BALLOON_SIZE[2] + 1)), Y3, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i));
|
||||||
}
|
}
|
||||||
balloon_formation_.emplace_back(3, init_params);
|
balloon_formation_.emplace_back(3, init_params);
|
||||||
}
|
}
|
||||||
@@ -100,7 +100,7 @@ void BalloonFormations::initBalloonFormations() {
|
|||||||
{
|
{
|
||||||
std::vector<BalloonFormationParams> init_params;
|
std::vector<BalloonFormationParams> init_params;
|
||||||
for (int i = 0; i < 6; ++i) {
|
for (int i = 0; i < 6; ++i) {
|
||||||
init_params.emplace_back(x1_0 + (i * (BALLOON_SIZE[0] + 1)), y1, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME - (10 * i));
|
init_params.emplace_back(X1_0 + (i * (BALLOON_SIZE[0] + 1)), Y1, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME - (10 * i));
|
||||||
}
|
}
|
||||||
balloon_formation_.emplace_back(6, init_params);
|
balloon_formation_.emplace_back(6, init_params);
|
||||||
}
|
}
|
||||||
@@ -109,7 +109,7 @@ void BalloonFormations::initBalloonFormations() {
|
|||||||
{
|
{
|
||||||
std::vector<BalloonFormationParams> init_params;
|
std::vector<BalloonFormationParams> init_params;
|
||||||
for (int i = 0; i < 6; ++i) {
|
for (int i = 0; i < 6; ++i) {
|
||||||
init_params.emplace_back(x1_100 - (i * (BALLOON_SIZE[0] + 1)), y1, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME - (10 * i));
|
init_params.emplace_back(X1_100 - (i * (BALLOON_SIZE[0] + 1)), Y1, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME - (10 * i));
|
||||||
}
|
}
|
||||||
balloon_formation_.emplace_back(6, init_params);
|
balloon_formation_.emplace_back(6, init_params);
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,7 @@ void BalloonFormations::initBalloonFormations() {
|
|||||||
{
|
{
|
||||||
std::vector<BalloonFormationParams> init_params;
|
std::vector<BalloonFormationParams> init_params;
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
init_params.emplace_back(x4_0 + (i * (BALLOON_SIZE[3] + 1)), y4, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME - (15 * i));
|
init_params.emplace_back(X4_0 + (i * (BALLOON_SIZE[3] + 1)), Y4, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME - (15 * i));
|
||||||
}
|
}
|
||||||
balloon_formation_.emplace_back(3, init_params);
|
balloon_formation_.emplace_back(3, init_params);
|
||||||
}
|
}
|
||||||
@@ -127,7 +127,7 @@ void BalloonFormations::initBalloonFormations() {
|
|||||||
{
|
{
|
||||||
std::vector<BalloonFormationParams> init_params;
|
std::vector<BalloonFormationParams> init_params;
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
init_params.emplace_back(x4_100 - (i * (BALLOON_SIZE[3] + 1)), y4, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME - (15 * i));
|
init_params.emplace_back(X4_100 - (i * (BALLOON_SIZE[3] + 1)), Y4, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME - (15 * i));
|
||||||
}
|
}
|
||||||
balloon_formation_.emplace_back(3, init_params);
|
balloon_formation_.emplace_back(3, init_params);
|
||||||
}
|
}
|
||||||
@@ -136,7 +136,7 @@ void BalloonFormations::initBalloonFormations() {
|
|||||||
{
|
{
|
||||||
std::vector<BalloonFormationParams> init_params;
|
std::vector<BalloonFormationParams> init_params;
|
||||||
for (int i = 0; i < 6; ++i) {
|
for (int i = 0; i < 6; ++i) {
|
||||||
init_params.emplace_back(x2_0 + (i * (BALLOON_SIZE[1] + 1)), y2, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE2, CREATION_TIME - (10 * i));
|
init_params.emplace_back(X2_0 + (i * (BALLOON_SIZE[1] + 1)), Y2, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE2, CREATION_TIME - (10 * i));
|
||||||
}
|
}
|
||||||
balloon_formation_.emplace_back(6, init_params);
|
balloon_formation_.emplace_back(6, init_params);
|
||||||
}
|
}
|
||||||
@@ -145,7 +145,7 @@ void BalloonFormations::initBalloonFormations() {
|
|||||||
{
|
{
|
||||||
std::vector<BalloonFormationParams> init_params;
|
std::vector<BalloonFormationParams> init_params;
|
||||||
for (int i = 0; i < 6; ++i) {
|
for (int i = 0; i < 6; ++i) {
|
||||||
init_params.emplace_back(x2_100 - (i * (BALLOON_SIZE[1] + 1)), y2, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE2, CREATION_TIME - (10 * i));
|
init_params.emplace_back(X2_100 - (i * (BALLOON_SIZE[1] + 1)), Y2, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE2, CREATION_TIME - (10 * i));
|
||||||
}
|
}
|
||||||
balloon_formation_.emplace_back(6, init_params);
|
balloon_formation_.emplace_back(6, init_params);
|
||||||
}
|
}
|
||||||
@@ -154,7 +154,7 @@ void BalloonFormations::initBalloonFormations() {
|
|||||||
{
|
{
|
||||||
std::vector<BalloonFormationParams> init_params;
|
std::vector<BalloonFormationParams> init_params;
|
||||||
for (int i = 0; i < 5; ++i) {
|
for (int i = 0; i < 5; ++i) {
|
||||||
init_params.emplace_back(x3_0 + (i * (BALLOON_SIZE[2] * 2)), y3, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i));
|
init_params.emplace_back(X3_0 + (i * (BALLOON_SIZE[2] * 2)), Y3, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i));
|
||||||
}
|
}
|
||||||
balloon_formation_.emplace_back(5, init_params);
|
balloon_formation_.emplace_back(5, init_params);
|
||||||
}
|
}
|
||||||
@@ -163,7 +163,7 @@ void BalloonFormations::initBalloonFormations() {
|
|||||||
{
|
{
|
||||||
std::vector<BalloonFormationParams> init_params;
|
std::vector<BalloonFormationParams> init_params;
|
||||||
for (int i = 0; i < 5; ++i) {
|
for (int i = 0; i < 5; ++i) {
|
||||||
init_params.emplace_back(x3_100 - (i * (BALLOON_SIZE[2] * 2)), y3, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i));
|
init_params.emplace_back(X3_100 - (i * (BALLOON_SIZE[2] * 2)), Y3, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i));
|
||||||
}
|
}
|
||||||
balloon_formation_.emplace_back(5, init_params);
|
balloon_formation_.emplace_back(5, init_params);
|
||||||
}
|
}
|
||||||
@@ -172,7 +172,7 @@ void BalloonFormations::initBalloonFormations() {
|
|||||||
{
|
{
|
||||||
std::vector<BalloonFormationParams> init_params;
|
std::vector<BalloonFormationParams> init_params;
|
||||||
for (int i = 0; i < 5; ++i) {
|
for (int i = 0; i < 5; ++i) {
|
||||||
init_params.emplace_back(x3_0 + (i * (BALLOON_SIZE[2] + 1)), y3, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i));
|
init_params.emplace_back(X3_0 + (i * (BALLOON_SIZE[2] + 1)), Y3, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i));
|
||||||
}
|
}
|
||||||
balloon_formation_.emplace_back(5, init_params);
|
balloon_formation_.emplace_back(5, init_params);
|
||||||
}
|
}
|
||||||
@@ -181,7 +181,7 @@ void BalloonFormations::initBalloonFormations() {
|
|||||||
{
|
{
|
||||||
std::vector<BalloonFormationParams> init_params;
|
std::vector<BalloonFormationParams> init_params;
|
||||||
for (int i = 0; i < 5; ++i) {
|
for (int i = 0; i < 5; ++i) {
|
||||||
init_params.emplace_back(x3_100 - (i * (BALLOON_SIZE[2] + 1)), y3, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i));
|
init_params.emplace_back(X3_100 - (i * (BALLOON_SIZE[2] + 1)), Y3, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i));
|
||||||
}
|
}
|
||||||
balloon_formation_.emplace_back(5, init_params);
|
balloon_formation_.emplace_back(5, init_params);
|
||||||
}
|
}
|
||||||
@@ -190,7 +190,7 @@ void BalloonFormations::initBalloonFormations() {
|
|||||||
{
|
{
|
||||||
std::vector<BalloonFormationParams> init_params;
|
std::vector<BalloonFormationParams> init_params;
|
||||||
for (int i = 0; i < 12; ++i) {
|
for (int i = 0; i < 12; ++i) {
|
||||||
init_params.emplace_back(x1_0 + (i * (BALLOON_SIZE[0] + 1)), y1, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME - (10 * i));
|
init_params.emplace_back(X1_0 + (i * (BALLOON_SIZE[0] + 1)), Y1, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME - (10 * i));
|
||||||
}
|
}
|
||||||
balloon_formation_.emplace_back(12, init_params);
|
balloon_formation_.emplace_back(12, init_params);
|
||||||
}
|
}
|
||||||
@@ -199,7 +199,7 @@ void BalloonFormations::initBalloonFormations() {
|
|||||||
{
|
{
|
||||||
std::vector<BalloonFormationParams> init_params;
|
std::vector<BalloonFormationParams> init_params;
|
||||||
for (int i = 0; i < 12; ++i) {
|
for (int i = 0; i < 12; ++i) {
|
||||||
init_params.emplace_back(x1_100 - (i * (BALLOON_SIZE[0] + 1)), y1, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME - (10 * i));
|
init_params.emplace_back(X1_100 - (i * (BALLOON_SIZE[0] + 1)), Y1, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME - (10 * i));
|
||||||
}
|
}
|
||||||
balloon_formation_.emplace_back(12, init_params);
|
balloon_formation_.emplace_back(12, init_params);
|
||||||
}
|
}
|
||||||
@@ -207,12 +207,12 @@ void BalloonFormations::initBalloonFormations() {
|
|||||||
// #20 - Dos enemigos BALLOON4 seguidos desde la izquierda/derecha. Simétricos
|
// #20 - Dos enemigos BALLOON4 seguidos desde la izquierda/derecha. Simétricos
|
||||||
{
|
{
|
||||||
std::vector<BalloonFormationParams> init_params;
|
std::vector<BalloonFormationParams> init_params;
|
||||||
const int half = 4 / 2;
|
const int HALF = 4 / 2;
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
if (i < half) {
|
if (i < HALF) {
|
||||||
init_params.emplace_back(x4_0 + (i * (BALLOON_SIZE[3] + 1)), y4, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME + (0 * i));
|
init_params.emplace_back(X4_0 + (i * (BALLOON_SIZE[3] + 1)), Y4, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME + (0 * i));
|
||||||
} else {
|
} else {
|
||||||
init_params.emplace_back(x4_100 - ((i - half) * (BALLOON_SIZE[3] + 1)), y4, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME + (0 * i));
|
init_params.emplace_back(X4_100 - ((i - HALF) * (BALLOON_SIZE[3] + 1)), Y4, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME + (0 * i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
balloon_formation_.emplace_back(4, init_params);
|
balloon_formation_.emplace_back(4, init_params);
|
||||||
@@ -221,12 +221,12 @@ void BalloonFormations::initBalloonFormations() {
|
|||||||
// #20 - Dos enemigos BALLOON4 seguidos desde la izquierda/derecha. Simétricos
|
// #20 - Dos enemigos BALLOON4 seguidos desde la izquierda/derecha. Simétricos
|
||||||
{
|
{
|
||||||
std::vector<BalloonFormationParams> init_params;
|
std::vector<BalloonFormationParams> init_params;
|
||||||
const int half = 4 / 2;
|
const int HALF = 4 / 2;
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
if (i < half) {
|
if (i < HALF) {
|
||||||
init_params.emplace_back(x4_0 + (i * (BALLOON_SIZE[3] + 1)), y4, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME + (0 * i));
|
init_params.emplace_back(X4_0 + (i * (BALLOON_SIZE[3] + 1)), Y4, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME + (0 * i));
|
||||||
} else {
|
} else {
|
||||||
init_params.emplace_back(x4_100 - ((i - half) * (BALLOON_SIZE[3] + 1)), y4, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME + (0 * i));
|
init_params.emplace_back(X4_100 - ((i - HALF) * (BALLOON_SIZE[3] + 1)), Y4, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME + (0 * i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
balloon_formation_.emplace_back(4, init_params);
|
balloon_formation_.emplace_back(4, init_params);
|
||||||
@@ -235,12 +235,12 @@ void BalloonFormations::initBalloonFormations() {
|
|||||||
// #21 - Diez enemigos BALLOON2 uno detrás del otro. Izquierda/derecha. Simétricos
|
// #21 - Diez enemigos BALLOON2 uno detrás del otro. Izquierda/derecha. Simétricos
|
||||||
{
|
{
|
||||||
std::vector<BalloonFormationParams> init_params;
|
std::vector<BalloonFormationParams> init_params;
|
||||||
const int half = 10 / 2;
|
const int HALF = 10 / 2;
|
||||||
for (int i = 0; i < 10; ++i) {
|
for (int i = 0; i < 10; ++i) {
|
||||||
if (i < half) {
|
if (i < HALF) {
|
||||||
init_params.emplace_back(x2_0 + (i * (BALLOON_SIZE[1] + 1)), y2, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE2, CREATION_TIME - (3 * i));
|
init_params.emplace_back(X2_0 + (i * (BALLOON_SIZE[1] + 1)), Y2, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE2, CREATION_TIME - (3 * i));
|
||||||
} else {
|
} else {
|
||||||
init_params.emplace_back(x2_100 - ((i - half) * (BALLOON_SIZE[1] + 1)), y2, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE2, CREATION_TIME - (3 * (i - half)));
|
init_params.emplace_back(X2_100 - ((i - HALF) * (BALLOON_SIZE[1] + 1)), Y2, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE2, CREATION_TIME - (3 * (i - HALF)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
balloon_formation_.emplace_back(10, init_params);
|
balloon_formation_.emplace_back(10, init_params);
|
||||||
@@ -249,12 +249,12 @@ void BalloonFormations::initBalloonFormations() {
|
|||||||
// #22 - Diez enemigos BALLOON3. Hacia la derecha/izquierda. Separados. Simétricos
|
// #22 - Diez enemigos BALLOON3. Hacia la derecha/izquierda. Separados. Simétricos
|
||||||
{
|
{
|
||||||
std::vector<BalloonFormationParams> init_params;
|
std::vector<BalloonFormationParams> init_params;
|
||||||
const int half = 10 / 2;
|
const int HALF = 10 / 2;
|
||||||
for (int i = 0; i < 10; ++i) {
|
for (int i = 0; i < 10; ++i) {
|
||||||
if (i < half) {
|
if (i < HALF) {
|
||||||
init_params.emplace_back(x3_0 + (i * (BALLOON_SIZE[2] * 2)), y3, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i));
|
init_params.emplace_back(X3_0 + (i * (BALLOON_SIZE[2] * 2)), Y3, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i));
|
||||||
} else {
|
} else {
|
||||||
init_params.emplace_back(x3_100 - ((i - half) * (BALLOON_SIZE[2] * 2)), y3, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * (i - half)));
|
init_params.emplace_back(X3_100 - ((i - HALF) * (BALLOON_SIZE[2] * 2)), Y3, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * (i - HALF)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
balloon_formation_.emplace_back(10, init_params);
|
balloon_formation_.emplace_back(10, init_params);
|
||||||
@@ -263,12 +263,12 @@ void BalloonFormations::initBalloonFormations() {
|
|||||||
// #23 - Diez enemigos BALLOON3. Hacia la derecha. Juntos. Simétricos
|
// #23 - Diez enemigos BALLOON3. Hacia la derecha. Juntos. Simétricos
|
||||||
{
|
{
|
||||||
std::vector<BalloonFormationParams> init_params;
|
std::vector<BalloonFormationParams> init_params;
|
||||||
const int half = 10 / 2;
|
const int HALF = 10 / 2;
|
||||||
for (int i = 0; i < 10; ++i) {
|
for (int i = 0; i < 10; ++i) {
|
||||||
if (i < half) {
|
if (i < HALF) {
|
||||||
init_params.emplace_back(x3_0 + (i * (BALLOON_SIZE[2] + 1)), y3, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i));
|
init_params.emplace_back(X3_0 + (i * (BALLOON_SIZE[2] + 1)), Y3, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i));
|
||||||
} else {
|
} else {
|
||||||
init_params.emplace_back(x3_100 - ((i - half) * (BALLOON_SIZE[2] + 1)), y3, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * (i - half)));
|
init_params.emplace_back(X3_100 - ((i - HALF) * (BALLOON_SIZE[2] + 1)), Y3, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * (i - HALF)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
balloon_formation_.emplace_back(10, init_params);
|
balloon_formation_.emplace_back(10, init_params);
|
||||||
@@ -277,12 +277,12 @@ void BalloonFormations::initBalloonFormations() {
|
|||||||
// #24 - Treinta enemigos BALLOON1. Del centro hacia los extremos. Juntos. Simétricos
|
// #24 - Treinta enemigos BALLOON1. Del centro hacia los extremos. Juntos. Simétricos
|
||||||
{
|
{
|
||||||
std::vector<BalloonFormationParams> init_params;
|
std::vector<BalloonFormationParams> init_params;
|
||||||
const int half = 30 / 2;
|
const int HALF = 30 / 2;
|
||||||
for (int i = 0; i < 30; ++i) {
|
for (int i = 0; i < 30; ++i) {
|
||||||
if (i < half) {
|
if (i < HALF) {
|
||||||
init_params.emplace_back(x1_50, y1, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME + (5 * i));
|
init_params.emplace_back(X1_50, Y1, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME + (5 * i));
|
||||||
} else {
|
} else {
|
||||||
init_params.emplace_back(x1_50, y1, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME + (5 * (i - half)));
|
init_params.emplace_back(X1_50, Y1, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME + (5 * (i - HALF)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
balloon_formation_.emplace_back(30, init_params);
|
balloon_formation_.emplace_back(30, init_params);
|
||||||
@@ -291,12 +291,12 @@ void BalloonFormations::initBalloonFormations() {
|
|||||||
// #25 - Treinta enemigos BALLOON1. Del centro hacia adentro. Juntos. Simétricos
|
// #25 - Treinta enemigos BALLOON1. Del centro hacia adentro. Juntos. Simétricos
|
||||||
{
|
{
|
||||||
std::vector<BalloonFormationParams> init_params;
|
std::vector<BalloonFormationParams> init_params;
|
||||||
const int half = 30 / 2;
|
const int HALF = 30 / 2;
|
||||||
for (int i = 0; i < 30; ++i) {
|
for (int i = 0; i < 30; ++i) {
|
||||||
if (i < half) {
|
if (i < HALF) {
|
||||||
init_params.emplace_back(x1_50 + 20, y1, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME - (5 * i));
|
init_params.emplace_back(X1_50 + 20, Y1, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME - (5 * i));
|
||||||
} else {
|
} else {
|
||||||
init_params.emplace_back(x1_50 - 20, y1, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME - (5 * (i - half)));
|
init_params.emplace_back(X1_50 - 20, Y1, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME - (5 * (i - HALF)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
balloon_formation_.emplace_back(30, init_params);
|
balloon_formation_.emplace_back(30, init_params);
|
||||||
@@ -322,10 +322,10 @@ void BalloonFormations::initBalloonFormations() {
|
|||||||
|
|
||||||
// TEST
|
// TEST
|
||||||
std::vector<BalloonFormationParams> test_params = {
|
std::vector<BalloonFormationParams> test_params = {
|
||||||
{10, y1, 0, BalloonType::FLOATER, BalloonSize::SIZE1, 200},
|
{10, Y1, 0, BalloonType::FLOATER, BalloonSize::SIZE1, 200},
|
||||||
{50, y1, 0, BalloonType::FLOATER, BalloonSize::SIZE2, 200},
|
{50, Y1, 0, BalloonType::FLOATER, BalloonSize::SIZE2, 200},
|
||||||
{90, y1, 0, BalloonType::FLOATER, BalloonSize::SIZE3, 200},
|
{90, Y1, 0, BalloonType::FLOATER, BalloonSize::SIZE3, 200},
|
||||||
{140, y1, 0, BalloonType::FLOATER, BalloonSize::SIZE4, 200}};
|
{140, Y1, 0, BalloonType::FLOATER, BalloonSize::SIZE4, 200}};
|
||||||
|
|
||||||
balloon_formation_.at(99) = BalloonFormationUnit(4, test_params);
|
balloon_formation_.at(99) = BalloonFormationUnit(4, test_params);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,10 +96,10 @@ void BalloonManager::deployBalloonFormation(int stage) {
|
|||||||
|
|
||||||
last_balloon_deploy_ = formation;
|
last_balloon_deploy_ = formation;
|
||||||
|
|
||||||
const auto set = balloon_formations_->getSet(stage, formation);
|
const auto SET = balloon_formations_->getSet(stage, formation);
|
||||||
const auto num_enemies = set.number_of_balloons;
|
const auto NUM_ENEMIES = SET.number_of_balloons;
|
||||||
for (int i = 0; i < num_enemies; ++i) {
|
for (int i = 0; i < NUM_ENEMIES; ++i) {
|
||||||
auto p = set.init[i];
|
auto p = SET.init[i];
|
||||||
createBalloon(
|
createBalloon(
|
||||||
p.x,
|
p.x,
|
||||||
p.y,
|
p.y,
|
||||||
@@ -117,20 +117,20 @@ void BalloonManager::deployBalloonFormation(int stage) {
|
|||||||
|
|
||||||
// Crea una formación de enemigos específica
|
// Crea una formación de enemigos específica
|
||||||
void BalloonManager::deploySet(int set_number) {
|
void BalloonManager::deploySet(int set_number) {
|
||||||
const auto set = balloon_formations_->getSet(set_number);
|
const auto SET = balloon_formations_->getSet(set_number);
|
||||||
const auto num_enemies = set.number_of_balloons;
|
const auto NUM_ENEMIES = SET.number_of_balloons;
|
||||||
for (int i = 0; i < num_enemies; ++i) {
|
for (int i = 0; i < NUM_ENEMIES; ++i) {
|
||||||
auto p = set.init[i];
|
auto p = SET.init[i];
|
||||||
createBalloon(p.x, p.y, p.type, p.size, p.vel_x, balloon_speed_, p.creation_counter);
|
createBalloon(p.x, p.y, p.type, p.size, p.vel_x, balloon_speed_, p.creation_counter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Crea una formación de enemigos específica
|
// Crea una formación de enemigos específica
|
||||||
void BalloonManager::deploySet(int set_number, int y) {
|
void BalloonManager::deploySet(int set_number, int y) {
|
||||||
const auto set = balloon_formations_->getSet(set_number);
|
const auto SET = balloon_formations_->getSet(set_number);
|
||||||
const auto num_enemies = set.number_of_balloons;
|
const auto NUM_ENEMIES = SET.number_of_balloons;
|
||||||
for (int i = 0; i < num_enemies; ++i) {
|
for (int i = 0; i < NUM_ENEMIES; ++i) {
|
||||||
auto p = set.init[i];
|
auto p = SET.init[i];
|
||||||
createBalloon(p.x, y, p.type, p.size, p.vel_x, balloon_speed_, p.creation_counter);
|
createBalloon(p.x, y, p.type, p.size, p.vel_x, balloon_speed_, p.creation_counter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -340,14 +340,14 @@ void BalloonManager::createTwoBigBalloons() {
|
|||||||
|
|
||||||
// Crea una disposición de globos aleatoria
|
// Crea una disposición de globos aleatoria
|
||||||
void BalloonManager::createRandomBalloons() {
|
void BalloonManager::createRandomBalloons() {
|
||||||
const int num_balloons = 2 + rand() % 4;
|
const int NUM_BALLOONS = 2 + rand() % 4;
|
||||||
for (int i = 0; i < num_balloons; ++i) {
|
for (int i = 0; i < NUM_BALLOONS; ++i) {
|
||||||
const float x = param.game.game_area.rect.x + (rand() % static_cast<int>(param.game.game_area.rect.w)) - BALLOON_SIZE[3];
|
const float X = param.game.game_area.rect.x + (rand() % static_cast<int>(param.game.game_area.rect.w)) - BALLOON_SIZE[3];
|
||||||
const int y = param.game.game_area.rect.y + (rand() % 50);
|
const int Y = param.game.game_area.rect.y + (rand() % 50);
|
||||||
const BalloonSize size = static_cast<BalloonSize>(rand() % 4);
|
const BalloonSize SIZE = static_cast<BalloonSize>(rand() % 4);
|
||||||
const float vel_x = (rand() % 2 == 0) ? BALLOON_VELX_POSITIVE : BALLOON_VELX_NEGATIVE;
|
const float VEL_X = (rand() % 2 == 0) ? BALLOON_VELX_POSITIVE : BALLOON_VELX_NEGATIVE;
|
||||||
const int creation_counter = 0;
|
const int CREATION_COUNTER = 0;
|
||||||
createBalloon(x, y, BalloonType::BALLOON, size, vel_x, balloon_speed_, creation_counter);
|
createBalloon(X, Y, BalloonType::BALLOON, SIZE, VEL_X, balloon_speed_, CREATION_COUNTER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,9 +38,9 @@ void DefineButtons::doControllerButtonDown(const SDL_GamepadButtonEvent &event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto button = static_cast<SDL_GamepadButton>(event.button);
|
const auto BUTTON = static_cast<SDL_GamepadButton>(event.button);
|
||||||
if (checkButtonNotInUse(button)) {
|
if (checkButtonNotInUse(BUTTON)) {
|
||||||
buttons_.at(index_button_).button = button;
|
buttons_.at(index_button_).button = BUTTON;
|
||||||
incIndexButton();
|
incIndexButton();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,9 +126,9 @@ void Director::loadParams() {
|
|||||||
#ifdef ANBERNIC
|
#ifdef ANBERNIC
|
||||||
const std::string paramFilePath = asset->get("param_320x240.txt");
|
const std::string paramFilePath = asset->get("param_320x240.txt");
|
||||||
#else
|
#else
|
||||||
const std::string paramFilePath = overrides.param_file == "--320x240" ? Asset::get()->get("param_320x240.txt") : Asset::get()->get("param_320x256.txt");
|
const std::string PARAM_FILE_PATH = overrides.param_file == "--320x240" ? Asset::get()->get("param_320x240.txt") : Asset::get()->get("param_320x256.txt");
|
||||||
#endif
|
#endif
|
||||||
loadParamsFromFile(paramFilePath);
|
loadParamsFromFile(PARAM_FILE_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Carga el fichero de puntuaciones
|
// Carga el fichero de puntuaciones
|
||||||
@@ -205,8 +205,8 @@ void Director::bindInputs() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mapea las asignaciones a los botones desde el archivo de configuración, si se da el caso
|
// Mapea las asignaciones a los botones desde el archivo de configuración, si se da el caso
|
||||||
const size_t max_controllers = std::min(2, NUM_GAMEPADS);
|
const size_t MAX_CONTROLLERS = std::min(2, NUM_GAMEPADS);
|
||||||
for (size_t i = 0; i < max_controllers; ++i) {
|
for (size_t i = 0; i < MAX_CONTROLLERS; ++i) {
|
||||||
for (auto &controller : Options::controllers) {
|
for (auto &controller : Options::controllers) {
|
||||||
if (Input::get()->getControllerName(i) == controller.name) {
|
if (Input::get()->getControllerName(i) == controller.name) {
|
||||||
for (size_t j = 0; j < controller.inputs.size(); ++j) {
|
for (size_t j = 0; j < controller.inputs.size(); ++j) {
|
||||||
@@ -224,7 +224,7 @@ void Director::bindInputs() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Guarda las asignaciones de botones en las opciones de los dos primeros mandos
|
// Guarda las asignaciones de botones en las opciones de los dos primeros mandos
|
||||||
for (size_t i = 0; i < max_controllers; ++i) {
|
for (size_t i = 0; i < MAX_CONTROLLERS; ++i) {
|
||||||
// Variables asociadas al mando
|
// Variables asociadas al mando
|
||||||
Options::controllers.at(i).index = i;
|
Options::controllers.at(i).index = i;
|
||||||
Options::controllers.at(i).name = Input::get()->getControllerName(i);
|
Options::controllers.at(i).name = Input::get()->getControllerName(i);
|
||||||
@@ -246,186 +246,186 @@ void Director::setFileList() {
|
|||||||
#ifdef MACOS_BUNDLE
|
#ifdef MACOS_BUNDLE
|
||||||
const std::string prefix = "/../Resources";
|
const std::string prefix = "/../Resources";
|
||||||
#else
|
#else
|
||||||
const std::string prefix;
|
const std::string PREFIX;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Ficheros de configuración
|
// Ficheros de configuración
|
||||||
Asset::get()->add(system_folder_ + "/config.txt", AssetType::DATA, false, true);
|
Asset::get()->add(system_folder_ + "/config.txt", AssetType::DATA, false, true);
|
||||||
Asset::get()->add(system_folder_ + "/score.bin", AssetType::DATA, false, true);
|
Asset::get()->add(system_folder_ + "/score.bin", AssetType::DATA, false, true);
|
||||||
Asset::get()->add(prefix + "/data/config/param_320x240.txt", AssetType::DATA);
|
Asset::get()->add(PREFIX + "/data/config/param_320x240.txt", AssetType::DATA);
|
||||||
Asset::get()->add(prefix + "/data/config/param_320x256.txt", AssetType::DATA);
|
Asset::get()->add(PREFIX + "/data/config/param_320x256.txt", AssetType::DATA);
|
||||||
Asset::get()->add(prefix + "/data/config/demo1.bin", AssetType::DEMODATA);
|
Asset::get()->add(PREFIX + "/data/config/demo1.bin", AssetType::DEMODATA);
|
||||||
Asset::get()->add(prefix + "/data/config/demo2.bin", AssetType::DEMODATA);
|
Asset::get()->add(PREFIX + "/data/config/demo2.bin", AssetType::DEMODATA);
|
||||||
Asset::get()->add(prefix + "/data/config/gamecontrollerdb.txt", AssetType::DATA);
|
Asset::get()->add(PREFIX + "/data/config/gamecontrollerdb.txt", AssetType::DATA);
|
||||||
|
|
||||||
// Musicas
|
// Musicas
|
||||||
Asset::get()->add(prefix + "/data/music/intro.ogg", AssetType::MUSIC);
|
Asset::get()->add(PREFIX + "/data/music/intro.ogg", AssetType::MUSIC);
|
||||||
Asset::get()->add(prefix + "/data/music/playing.ogg", AssetType::MUSIC);
|
Asset::get()->add(PREFIX + "/data/music/playing.ogg", AssetType::MUSIC);
|
||||||
Asset::get()->add(prefix + "/data/music/title.ogg", AssetType::MUSIC);
|
Asset::get()->add(PREFIX + "/data/music/title.ogg", AssetType::MUSIC);
|
||||||
Asset::get()->add(prefix + "/data/music/credits.ogg", AssetType::MUSIC);
|
Asset::get()->add(PREFIX + "/data/music/credits.ogg", AssetType::MUSIC);
|
||||||
|
|
||||||
// Sonidos
|
// Sonidos
|
||||||
Asset::get()->add(prefix + "/data/sound/balloon1.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/balloon1.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/balloon2.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/balloon2.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/balloon3.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/balloon3.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/balloon4.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/balloon4.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/bubble1.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/bubble1.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/bubble2.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/bubble2.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/bubble3.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/bubble3.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/bubble4.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/bubble4.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/bullet.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/bullet.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/clock.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/clock.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/coffee_out.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/coffee_out.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/continue_clock.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/continue_clock.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/debian_drop.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/debian_drop.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/debian_pickup.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/debian_pickup.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/hi_score_achieved.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/hi_score_achieved.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/item_drop.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/item_drop.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/item_pickup.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/item_pickup.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/jump.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/jump.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/logo.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/logo.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/notify.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/notify.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/player_collision.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/player_collision.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/power_ball_explosion.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/power_ball_explosion.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/service_menu_adjust.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/service_menu_adjust.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/service_menu_move.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/service_menu_move.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/service_menu_select.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/service_menu_select.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/stage_change.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/stage_change.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/tabe_hit.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/tabe_hit.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/tabe.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/tabe.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/title.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/title.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/voice_aw_aw_aw.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/voice_aw_aw_aw.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/voice_coffee.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/voice_coffee.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/voice_get_ready.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/voice_get_ready.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/voice_no.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/voice_no.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/voice_power_up.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/voice_power_up.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/voice_thankyou.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/voice_thankyou.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/walk.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/walk.wav", AssetType::SOUND);
|
||||||
|
|
||||||
// Shaders
|
// Shaders
|
||||||
Asset::get()->add(prefix + "/data/shaders/crtpi_256.glsl", AssetType::DATA);
|
Asset::get()->add(PREFIX + "/data/shaders/crtpi_256.glsl", AssetType::DATA);
|
||||||
Asset::get()->add(prefix + "/data/shaders/crtpi_240.glsl", AssetType::DATA);
|
Asset::get()->add(PREFIX + "/data/shaders/crtpi_240.glsl", AssetType::DATA);
|
||||||
|
|
||||||
// Texturas - Balloons
|
// Texturas - Balloons
|
||||||
Asset::get()->add(prefix + "/data/gfx/balloon/balloon1.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/balloon/balloon1.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/balloon/balloon1.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/gfx/balloon/balloon1.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/gfx/balloon/balloon2.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/balloon/balloon2.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/balloon/balloon2.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/gfx/balloon/balloon2.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/gfx/balloon/balloon3.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/balloon/balloon3.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/balloon/balloon3.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/gfx/balloon/balloon3.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/gfx/balloon/balloon4.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/balloon/balloon4.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/balloon/balloon4.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/gfx/balloon/balloon4.ani", AssetType::ANIMATION);
|
||||||
|
|
||||||
// Texturas - Explosiones
|
// Texturas - Explosiones
|
||||||
Asset::get()->add(prefix + "/data/gfx/balloon/explosion1.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/balloon/explosion1.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/balloon/explosion1.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/gfx/balloon/explosion1.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/gfx/balloon/explosion2.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/balloon/explosion2.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/balloon/explosion2.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/gfx/balloon/explosion2.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/gfx/balloon/explosion3.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/balloon/explosion3.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/balloon/explosion3.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/gfx/balloon/explosion3.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/gfx/balloon/explosion4.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/balloon/explosion4.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/balloon/explosion4.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/gfx/balloon/explosion4.ani", AssetType::ANIMATION);
|
||||||
|
|
||||||
// Texturas - Power Ball
|
// Texturas - Power Ball
|
||||||
Asset::get()->add(prefix + "/data/gfx/balloon/powerball.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/balloon/powerball.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/balloon/powerball.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/gfx/balloon/powerball.ani", AssetType::ANIMATION);
|
||||||
|
|
||||||
// Texturas - Bala
|
// Texturas - Bala
|
||||||
Asset::get()->add(prefix + "/data/gfx/bullet/bullet.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/bullet/bullet.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/bullet/bullet.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/gfx/bullet/bullet.ani", AssetType::ANIMATION);
|
||||||
|
|
||||||
// Texturas - Tabe
|
// Texturas - Tabe
|
||||||
Asset::get()->add(prefix + "/data/gfx/tabe/tabe.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/tabe/tabe.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/tabe/tabe.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/gfx/tabe/tabe.ani", AssetType::ANIMATION);
|
||||||
|
|
||||||
// Texturas - Juego
|
// Texturas - Juego
|
||||||
Asset::get()->add(prefix + "/data/gfx/game/game_buildings.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/game/game_buildings.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/game/game_clouds1.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/game/game_clouds1.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/game/game_clouds2.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/game/game_clouds2.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/game/game_grass.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/game/game_grass.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/game/game_power_meter.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/game/game_power_meter.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/game/game_sky_colors.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/game/game_sky_colors.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/game/game_sun.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/game/game_sun.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/game/game_moon.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/game/game_moon.png", AssetType::BITMAP);
|
||||||
|
|
||||||
// Texturas - Intro
|
// Texturas - Intro
|
||||||
Asset::get()->add(prefix + "/data/gfx/intro/intro1.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/intro/intro1.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/intro/intro2.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/intro/intro2.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/intro/intro3.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/intro/intro3.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/intro/intro4.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/intro/intro4.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/intro/intro5.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/intro/intro5.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/intro/intro6.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/intro/intro6.png", AssetType::BITMAP);
|
||||||
|
|
||||||
// Texturas - Logo
|
// Texturas - Logo
|
||||||
Asset::get()->add(prefix + "/data/gfx/logo/logo_jailgames.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/logo/logo_jailgames.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/logo/logo_jailgames_mini.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/logo/logo_jailgames_mini.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/logo/logo_since_1998.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/logo/logo_since_1998.png", AssetType::BITMAP);
|
||||||
|
|
||||||
// Texturas - Items
|
// Texturas - Items
|
||||||
Asset::get()->add(prefix + "/data/gfx/item/item_points1_disk.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/item/item_points1_disk.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/item/item_points1_disk.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/gfx/item/item_points1_disk.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/gfx/item/item_points2_gavina.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/item/item_points2_gavina.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/item/item_points2_gavina.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/gfx/item/item_points2_gavina.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/gfx/item/item_points3_pacmar.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/item/item_points3_pacmar.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/item/item_points3_pacmar.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/gfx/item/item_points3_pacmar.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/gfx/item/item_clock.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/item/item_clock.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/item/item_clock.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/gfx/item/item_clock.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/gfx/item/item_coffee.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/item/item_coffee.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/item/item_coffee.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/gfx/item/item_coffee.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/gfx/item/item_debian.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/item/item_debian.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/item/item_debian.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/gfx/item/item_debian.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/gfx/item/item_coffee_machine.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/item/item_coffee_machine.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/item/item_coffee_machine.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/gfx/item/item_coffee_machine.ani", AssetType::ANIMATION);
|
||||||
|
|
||||||
// Texturas - Titulo
|
// Texturas - Titulo
|
||||||
Asset::get()->add(prefix + "/data/gfx/title/title_bg_tile.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/title/title_bg_tile.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/title/title_coffee.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/title/title_coffee.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/title/title_crisis.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/title/title_crisis.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/title/title_arcade_edition.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/title/title_arcade_edition.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/title/title_dust.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/title/title_dust.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/title/title_dust.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/gfx/title/title_dust.ani", AssetType::ANIMATION);
|
||||||
|
|
||||||
// Texturas - Jugador 1
|
// Texturas - Jugador 1
|
||||||
Asset::get()->add(prefix + "/data/gfx/player/player1.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/player/player1.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/player/player1_coffee1.pal", AssetType::PALETTE);
|
Asset::get()->add(PREFIX + "/data/gfx/player/player1_coffee1.pal", AssetType::PALETTE);
|
||||||
Asset::get()->add(prefix + "/data/gfx/player/player1_coffee2.pal", AssetType::PALETTE);
|
Asset::get()->add(PREFIX + "/data/gfx/player/player1_coffee2.pal", AssetType::PALETTE);
|
||||||
Asset::get()->add(prefix + "/data/gfx/player/player1_invencible.pal", AssetType::PALETTE);
|
Asset::get()->add(PREFIX + "/data/gfx/player/player1_invencible.pal", AssetType::PALETTE);
|
||||||
Asset::get()->add(prefix + "/data/gfx/player/player1_power.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/player/player1_power.png", AssetType::BITMAP);
|
||||||
|
|
||||||
// Texturas - Jugador 2
|
// Texturas - Jugador 2
|
||||||
Asset::get()->add(prefix + "/data/gfx/player/player2.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/player/player2.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/player/player2_coffee1.pal", AssetType::PALETTE);
|
Asset::get()->add(PREFIX + "/data/gfx/player/player2_coffee1.pal", AssetType::PALETTE);
|
||||||
Asset::get()->add(prefix + "/data/gfx/player/player2_coffee2.pal", AssetType::PALETTE);
|
Asset::get()->add(PREFIX + "/data/gfx/player/player2_coffee2.pal", AssetType::PALETTE);
|
||||||
Asset::get()->add(prefix + "/data/gfx/player/player2_invencible.pal", AssetType::PALETTE);
|
Asset::get()->add(PREFIX + "/data/gfx/player/player2_invencible.pal", AssetType::PALETTE);
|
||||||
Asset::get()->add(prefix + "/data/gfx/player/player2_power.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/gfx/player/player2_power.png", AssetType::BITMAP);
|
||||||
|
|
||||||
// Animaciones del jugador
|
// Animaciones del jugador
|
||||||
Asset::get()->add(prefix + "/data/gfx/player/player.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/gfx/player/player.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/gfx/player/player_power.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/gfx/player/player_power.ani", AssetType::ANIMATION);
|
||||||
|
|
||||||
// Fuentes de texto
|
// Fuentes de texto
|
||||||
Asset::get()->add(prefix + "/data/font/8bithud.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/font/8bithud.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/font/8bithud.txt", AssetType::FONT);
|
Asset::get()->add(PREFIX + "/data/font/8bithud.txt", AssetType::FONT);
|
||||||
Asset::get()->add(prefix + "/data/font/aseprite.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/font/aseprite.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/font/aseprite.txt", AssetType::FONT);
|
Asset::get()->add(PREFIX + "/data/font/aseprite.txt", AssetType::FONT);
|
||||||
Asset::get()->add(prefix + "/data/font/smb2.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/font/smb2.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/font/smb2_grad.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/font/smb2_grad.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/font/smb2.txt", AssetType::FONT);
|
Asset::get()->add(PREFIX + "/data/font/smb2.txt", AssetType::FONT);
|
||||||
Asset::get()->add(prefix + "/data/font/04b_25.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/font/04b_25.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/font/04b_25.txt", AssetType::FONT);
|
Asset::get()->add(PREFIX + "/data/font/04b_25.txt", AssetType::FONT);
|
||||||
Asset::get()->add(prefix + "/data/font/04b_25_2x.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/font/04b_25_2x.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/font/04b_25_2x.txt", AssetType::FONT);
|
Asset::get()->add(PREFIX + "/data/font/04b_25_2x.txt", AssetType::FONT);
|
||||||
Asset::get()->add(prefix + "/data/font/04b_25_metal.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/font/04b_25_metal.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/font/04b_25_grey.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/font/04b_25_grey.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/font/04b_25_flat.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/font/04b_25_flat.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/font/04b_25_reversed.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/font/04b_25_reversed.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/font/04b_25_flat_2x.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/font/04b_25_flat_2x.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/font/04b_25_reversed_2x.png", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/font/04b_25_reversed_2x.png", AssetType::BITMAP);
|
||||||
|
|
||||||
// Textos
|
// Textos
|
||||||
Asset::get()->add(prefix + "/data/lang/es_ES.json", AssetType::LANG);
|
Asset::get()->add(PREFIX + "/data/lang/es_ES.json", AssetType::LANG);
|
||||||
Asset::get()->add(prefix + "/data/lang/en_UK.json", AssetType::LANG);
|
Asset::get()->add(PREFIX + "/data/lang/en_UK.json", AssetType::LANG);
|
||||||
Asset::get()->add(prefix + "/data/lang/ba_BA.json", AssetType::LANG);
|
Asset::get()->add(PREFIX + "/data/lang/ba_BA.json", AssetType::LANG);
|
||||||
|
|
||||||
// Si falta algun fichero, sale del programa
|
// Si falta algun fichero, sale del programa
|
||||||
if (!Asset::get()->check()) {
|
if (!Asset::get()->check()) {
|
||||||
|
|||||||
@@ -156,8 +156,8 @@ void Fade::update() {
|
|||||||
SDL_SetRenderDrawColor(renderer_, r_, g_, b_, a_);
|
SDL_SetRenderDrawColor(renderer_, r_, g_, b_, a_);
|
||||||
|
|
||||||
// Dibuja el cuadrado correspondiente
|
// Dibuja el cuadrado correspondiente
|
||||||
for (const auto rect : square_) {
|
for (const auto RECT : square_) {
|
||||||
SDL_RenderFillRect(renderer_, &rect);
|
SDL_RenderFillRect(renderer_, &RECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deja el renderizador como estaba
|
// Deja el renderizador como estaba
|
||||||
@@ -165,10 +165,10 @@ void Fade::update() {
|
|||||||
SDL_SetRenderTarget(renderer_, temp);
|
SDL_SetRenderTarget(renderer_, temp);
|
||||||
|
|
||||||
// Modifica el tamaño de los rectangulos
|
// Modifica el tamaño de los rectangulos
|
||||||
const auto h = counter_ / 2;
|
const auto H = counter_ / 2;
|
||||||
for (size_t i = 0; i < square_.size(); ++i) {
|
for (size_t i = 0; i < square_.size(); ++i) {
|
||||||
// A partir del segundo rectangulo se pinta en función del anterior
|
// A partir del segundo rectangulo se pinta en función del anterior
|
||||||
square_.at(i).h = i == 0 ? h : std::max(static_cast<int>(square_.at(i - 1).h) - 2, 0);
|
square_.at(i).h = i == 0 ? H : std::max(static_cast<int>(square_.at(i - 1).h) - 2, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int completed = 0;
|
int completed = 0;
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ GameLogo::GameLogo(int x, int y)
|
|||||||
|
|
||||||
// Inicializa las variables
|
// Inicializa las variables
|
||||||
void GameLogo::init() {
|
void GameLogo::init() {
|
||||||
const auto xp = x_ - coffee_texture_->getWidth() / 2;
|
const auto XP = x_ - coffee_texture_->getWidth() / 2;
|
||||||
const auto desp = getInitialVerticalDesp();
|
const auto DESP = getInitialVerticalDesp();
|
||||||
|
|
||||||
// Configura texturas
|
// Configura texturas
|
||||||
SDL_SetTextureScaleMode(Resource::get()->getTexture("title_arcade_edition.png")->getSDLTexture(), SDL_SCALEMODE_NEAREST);
|
SDL_SetTextureScaleMode(Resource::get()->getTexture("title_arcade_edition.png")->getSDLTexture(), SDL_SCALEMODE_NEAREST);
|
||||||
@@ -44,12 +44,12 @@ void GameLogo::init() {
|
|||||||
// Variables
|
// Variables
|
||||||
coffee_crisis_status_ = Status::DISABLED;
|
coffee_crisis_status_ = Status::DISABLED;
|
||||||
arcade_edition_status_ = Status::DISABLED;
|
arcade_edition_status_ = Status::DISABLED;
|
||||||
shake_.init(1, 2, 8, xp);
|
shake_.init(1, 2, 8, XP);
|
||||||
zoom_ = 3.0f * ZOOM_FACTOR;
|
zoom_ = 3.0f * ZOOM_FACTOR;
|
||||||
|
|
||||||
// Inicializa el bitmap de 'Coffee'
|
// Inicializa el bitmap de 'Coffee'
|
||||||
coffee_sprite_->setPosX(xp);
|
coffee_sprite_->setPosX(XP);
|
||||||
coffee_sprite_->setPosY(y_ - coffee_texture_->getHeight() - desp);
|
coffee_sprite_->setPosY(y_ - coffee_texture_->getHeight() - DESP);
|
||||||
coffee_sprite_->setWidth(coffee_texture_->getWidth());
|
coffee_sprite_->setWidth(coffee_texture_->getWidth());
|
||||||
coffee_sprite_->setHeight(coffee_texture_->getHeight());
|
coffee_sprite_->setHeight(coffee_texture_->getHeight());
|
||||||
coffee_sprite_->setVelX(0.0f);
|
coffee_sprite_->setVelX(0.0f);
|
||||||
@@ -59,12 +59,12 @@ void GameLogo::init() {
|
|||||||
coffee_sprite_->setSpriteClip(0, 0, coffee_texture_->getWidth(), coffee_texture_->getHeight());
|
coffee_sprite_->setSpriteClip(0, 0, coffee_texture_->getWidth(), coffee_texture_->getHeight());
|
||||||
coffee_sprite_->setEnabled(true);
|
coffee_sprite_->setEnabled(true);
|
||||||
coffee_sprite_->setFinishedCounter(0);
|
coffee_sprite_->setFinishedCounter(0);
|
||||||
coffee_sprite_->setDestX(xp);
|
coffee_sprite_->setDestX(XP);
|
||||||
coffee_sprite_->setDestY(y_ - coffee_texture_->getHeight());
|
coffee_sprite_->setDestY(y_ - coffee_texture_->getHeight());
|
||||||
|
|
||||||
// Inicializa el bitmap de 'Crisis'
|
// Inicializa el bitmap de 'Crisis'
|
||||||
crisis_sprite_->setPosX(xp + 15);
|
crisis_sprite_->setPosX(XP + 15);
|
||||||
crisis_sprite_->setPosY(y_ + desp);
|
crisis_sprite_->setPosY(y_ + DESP);
|
||||||
crisis_sprite_->setWidth(crisis_texture_->getWidth());
|
crisis_sprite_->setWidth(crisis_texture_->getWidth());
|
||||||
crisis_sprite_->setHeight(crisis_texture_->getHeight());
|
crisis_sprite_->setHeight(crisis_texture_->getHeight());
|
||||||
crisis_sprite_->setVelX(0.0f);
|
crisis_sprite_->setVelX(0.0f);
|
||||||
@@ -74,7 +74,7 @@ void GameLogo::init() {
|
|||||||
crisis_sprite_->setSpriteClip(0, 0, crisis_texture_->getWidth(), crisis_texture_->getHeight());
|
crisis_sprite_->setSpriteClip(0, 0, crisis_texture_->getWidth(), crisis_texture_->getHeight());
|
||||||
crisis_sprite_->setEnabled(true);
|
crisis_sprite_->setEnabled(true);
|
||||||
crisis_sprite_->setFinishedCounter(0);
|
crisis_sprite_->setFinishedCounter(0);
|
||||||
crisis_sprite_->setDestX(xp + 15);
|
crisis_sprite_->setDestX(XP + 15);
|
||||||
crisis_sprite_->setDestY(y_);
|
crisis_sprite_->setDestY(y_);
|
||||||
|
|
||||||
// Inicializa el bitmap de 'DustRight'
|
// Inicializa el bitmap de 'DustRight'
|
||||||
@@ -138,9 +138,9 @@ void GameLogo::update() {
|
|||||||
shake_.counter--;
|
shake_.counter--;
|
||||||
} else {
|
} else {
|
||||||
shake_.counter = shake_.delay;
|
shake_.counter = shake_.delay;
|
||||||
const auto desp = shake_.remaining % 2 == 0 ? shake_.desp * (-1) : shake_.desp;
|
const auto DESP = shake_.remaining % 2 == 0 ? shake_.desp * (-1) : shake_.desp;
|
||||||
coffee_sprite_->setPosX(shake_.origin + desp);
|
coffee_sprite_->setPosX(shake_.origin + DESP);
|
||||||
crisis_sprite_->setPosX(shake_.origin + desp + 15);
|
crisis_sprite_->setPosX(shake_.origin + DESP + 15);
|
||||||
shake_.remaining--;
|
shake_.remaining--;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -190,8 +190,8 @@ void GameLogo::update() {
|
|||||||
shake_.counter--;
|
shake_.counter--;
|
||||||
} else {
|
} else {
|
||||||
shake_.counter = shake_.delay;
|
shake_.counter = shake_.delay;
|
||||||
const auto desp = shake_.remaining % 2 == 0 ? shake_.desp * (-1) : shake_.desp;
|
const auto DESP = shake_.remaining % 2 == 0 ? shake_.desp * (-1) : shake_.desp;
|
||||||
arcade_edition_sprite_->setX(shake_.origin + desp);
|
arcade_edition_sprite_->setX(shake_.origin + DESP);
|
||||||
shake_.remaining--;
|
shake_.remaining--;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -57,13 +57,13 @@ void Input::bindGameControllerButton(int controller_index, InputAction input_tar
|
|||||||
bool Input::checkInput(InputAction input, bool repeat, InputDevice device, int controller_index) {
|
bool Input::checkInput(InputAction input, bool repeat, InputDevice device, int controller_index) {
|
||||||
bool success_keyboard = false;
|
bool success_keyboard = false;
|
||||||
bool success_controller = false;
|
bool success_controller = false;
|
||||||
const int input_index = static_cast<int>(input);
|
const int INPUT_INDEX = static_cast<int>(input);
|
||||||
|
|
||||||
if (device == InputDevice::KEYBOARD || device == InputDevice::ANY) {
|
if (device == InputDevice::KEYBOARD || device == InputDevice::ANY) {
|
||||||
if (repeat) { // El usuario quiere saber si está pulsada (estado mantenido)
|
if (repeat) { // El usuario quiere saber si está pulsada (estado mantenido)
|
||||||
success_keyboard = key_bindings_[input_index].is_held;
|
success_keyboard = key_bindings_[INPUT_INDEX].is_held;
|
||||||
} else { // El usuario quiere saber si ACABA de ser pulsada (evento de un solo fotograma)
|
} else { // El usuario quiere saber si ACABA de ser pulsada (evento de un solo fotograma)
|
||||||
success_keyboard = key_bindings_[input_index].just_pressed;
|
success_keyboard = key_bindings_[INPUT_INDEX].just_pressed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,9 +73,9 @@ bool Input::checkInput(InputAction input, bool repeat, InputDevice device, int c
|
|||||||
|
|
||||||
if (!success_controller) {
|
if (!success_controller) {
|
||||||
if (repeat) { // El usuario quiere saber si está pulsada (estado mantenido)
|
if (repeat) { // El usuario quiere saber si está pulsada (estado mantenido)
|
||||||
success_controller = controller_bindings_.at(controller_index).at(input_index).is_held;
|
success_controller = controller_bindings_.at(controller_index).at(INPUT_INDEX).is_held;
|
||||||
} else { // El usuario quiere saber si ACABA de ser pulsada (evento de un solo fotograma)
|
} else { // El usuario quiere saber si ACABA de ser pulsada (evento de un solo fotograma)
|
||||||
success_controller = controller_bindings_.at(controller_index).at(input_index).just_pressed;
|
success_controller = controller_bindings_.at(controller_index).at(INPUT_INDEX).just_pressed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -87,11 +87,11 @@ bool Input::checkInput(InputAction input, bool repeat, InputDevice device, int c
|
|||||||
// Comprueba si hay almenos un input activo
|
// Comprueba si hay almenos un input activo
|
||||||
bool Input::checkAnyInput(InputDevice device, int controller_index) {
|
bool Input::checkAnyInput(InputDevice device, int controller_index) {
|
||||||
// Obtenemos el número total de acciones posibles para iterar sobre ellas.
|
// Obtenemos el número total de acciones posibles para iterar sobre ellas.
|
||||||
const int num_actions = static_cast<int>(InputAction::SIZE);
|
const int NUM_ACTIONS = static_cast<int>(InputAction::SIZE);
|
||||||
|
|
||||||
// --- Comprobación del Teclado ---
|
// --- Comprobación del Teclado ---
|
||||||
if (device == InputDevice::KEYBOARD || device == InputDevice::ANY) {
|
if (device == InputDevice::KEYBOARD || device == InputDevice::ANY) {
|
||||||
for (int i = 0; i < num_actions; ++i) {
|
for (int i = 0; i < NUM_ACTIONS; ++i) {
|
||||||
// Simplemente leemos el estado pre-calculado por Input::update().
|
// Simplemente leemos el estado pre-calculado por Input::update().
|
||||||
// Ya no se llama a SDL_GetKeyboardState ni se modifica el estado '.active'.
|
// Ya no se llama a SDL_GetKeyboardState ni se modifica el estado '.active'.
|
||||||
if (key_bindings_.at(i).just_pressed) {
|
if (key_bindings_.at(i).just_pressed) {
|
||||||
@@ -105,7 +105,7 @@ bool Input::checkAnyInput(InputDevice device, int controller_index) {
|
|||||||
if (gameControllerFound() && controller_index >= 0 && controller_index < num_gamepads_) {
|
if (gameControllerFound() && controller_index >= 0 && controller_index < num_gamepads_) {
|
||||||
if (device == InputDevice::CONTROLLER || device == InputDevice::ANY) {
|
if (device == InputDevice::CONTROLLER || device == InputDevice::ANY) {
|
||||||
// Bucle CORREGIDO: Iteramos sobre todas las acciones, no sobre el número de mandos.
|
// Bucle CORREGIDO: Iteramos sobre todas las acciones, no sobre el número de mandos.
|
||||||
for (int i = 0; i < num_actions; ++i) {
|
for (int i = 0; i < NUM_ACTIONS; ++i) {
|
||||||
// Leemos el estado pre-calculado para el mando y la acción específicos.
|
// Leemos el estado pre-calculado para el mando y la acción específicos.
|
||||||
if (controller_bindings_.at(controller_index).at(i).just_pressed) {
|
if (controller_bindings_.at(controller_index).at(i).just_pressed) {
|
||||||
return true; // Se encontró una acción recién pulsada en el mando.
|
return true; // Se encontró una acción recién pulsada en el mando.
|
||||||
@@ -277,15 +277,15 @@ std::string Input::inputToString(InputAction input) const {
|
|||||||
|
|
||||||
// Convierte un std::string a InputAction
|
// Convierte un std::string a InputAction
|
||||||
InputAction Input::stringToInput(const std::string &name) const {
|
InputAction Input::stringToInput(const std::string &name) const {
|
||||||
static const std::unordered_map<std::string, InputAction> inputMap = {
|
static const std::unordered_map<std::string, InputAction> INPUT_MAP = {
|
||||||
{"input_fire_left", InputAction::FIRE_LEFT},
|
{"input_fire_left", InputAction::FIRE_LEFT},
|
||||||
{"input_fire_center", InputAction::FIRE_CENTER},
|
{"input_fire_center", InputAction::FIRE_CENTER},
|
||||||
{"input_fire_right", InputAction::FIRE_RIGHT},
|
{"input_fire_right", InputAction::FIRE_RIGHT},
|
||||||
{"input_start", InputAction::START},
|
{"input_start", InputAction::START},
|
||||||
{"input_service", InputAction::SERVICE}};
|
{"input_service", InputAction::SERVICE}};
|
||||||
|
|
||||||
auto it = inputMap.find(name);
|
auto it = INPUT_MAP.find(name);
|
||||||
return it != inputMap.end() ? it->second : InputAction::NONE;
|
return it != INPUT_MAP.end() ? it->second : InputAction::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba el eje del mando
|
// Comprueba el eje del mando
|
||||||
|
|||||||
@@ -44,13 +44,13 @@ Item::Item(ItemType type, float x, float y, SDL_FRect &play_area, std::shared_pt
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Item::alignTo(int x) {
|
void Item::alignTo(int x) {
|
||||||
const float min_x = param.game.play_area.rect.x + 1;
|
const float MIN_X = param.game.play_area.rect.x + 1;
|
||||||
const float max_x = play_area_.w - width_ - 1;
|
const float MAX_X = play_area_.w - width_ - 1;
|
||||||
|
|
||||||
pos_x_ = x - (width_ / 2);
|
pos_x_ = x - (width_ / 2);
|
||||||
|
|
||||||
// Ajusta para que no quede fuera de la zona de juego
|
// Ajusta para que no quede fuera de la zona de juego
|
||||||
pos_x_ = std::clamp(pos_x_, min_x, max_x);
|
pos_x_ = std::clamp(pos_x_, MIN_X, MAX_X);
|
||||||
|
|
||||||
// Actualiza el sprite
|
// Actualiza el sprite
|
||||||
shiftSprite();
|
shiftSprite();
|
||||||
|
|||||||
@@ -66,15 +66,15 @@ void Notifier::update() {
|
|||||||
|
|
||||||
// Comprueba los estados
|
// Comprueba los estados
|
||||||
if (notifications_[i].state == NotificationStatus::RISING) {
|
if (notifications_[i].state == NotificationStatus::RISING) {
|
||||||
const float step = ((float)notifications_[i].counter / notifications_[i].travel_dist);
|
const float STEP = ((float)notifications_[i].counter / notifications_[i].travel_dist);
|
||||||
const int alpha = 255 * step;
|
const int ALPHA = 255 * STEP;
|
||||||
|
|
||||||
if (param.notification.pos_v == NotifyPosition::TOP) {
|
if (param.notification.pos_v == NotifyPosition::TOP) {
|
||||||
notifications_[i].rect.y++;
|
notifications_[i].rect.y++;
|
||||||
} else {
|
} else {
|
||||||
notifications_[i].rect.y--;
|
notifications_[i].rect.y--;
|
||||||
}
|
}
|
||||||
notifications_[i].texture->setAlpha(alpha);
|
notifications_[i].texture->setAlpha(ALPHA);
|
||||||
|
|
||||||
if (notifications_[i].rect.y == notifications_[i].y) {
|
if (notifications_[i].rect.y == notifications_[i].y) {
|
||||||
notifications_[i].state = NotificationStatus::STAY;
|
notifications_[i].state = NotificationStatus::STAY;
|
||||||
@@ -89,15 +89,15 @@ void Notifier::update() {
|
|||||||
notifications_[i].counter = 0;
|
notifications_[i].counter = 0;
|
||||||
}
|
}
|
||||||
} else if (notifications_[i].state == NotificationStatus::VANISHING) {
|
} else if (notifications_[i].state == NotificationStatus::VANISHING) {
|
||||||
const float step = (notifications_[i].counter / (float)notifications_[i].travel_dist);
|
const float STEP = (notifications_[i].counter / (float)notifications_[i].travel_dist);
|
||||||
const int alpha = 255 * (1 - step);
|
const int ALPHA = 255 * (1 - STEP);
|
||||||
|
|
||||||
if (param.notification.pos_v == NotifyPosition::TOP) {
|
if (param.notification.pos_v == NotifyPosition::TOP) {
|
||||||
notifications_[i].rect.y--;
|
notifications_[i].rect.y--;
|
||||||
} else {
|
} else {
|
||||||
notifications_[i].rect.y++;
|
notifications_[i].rect.y++;
|
||||||
}
|
}
|
||||||
notifications_[i].texture->setAlpha(alpha);
|
notifications_[i].texture->setAlpha(ALPHA);
|
||||||
|
|
||||||
if (notifications_[i].rect.y == notifications_[i].y - notifications_[i].travel_dist) {
|
if (notifications_[i].rect.y == notifications_[i].y - notifications_[i].travel_dist) {
|
||||||
notifications_[i].state = NotificationStatus::FINISHED;
|
notifications_[i].state = NotificationStatus::FINISHED;
|
||||||
@@ -176,7 +176,7 @@ void Notifier::show(std::vector<std::string> texts, int icon, const std::string
|
|||||||
|
|
||||||
// Offset
|
// Offset
|
||||||
const auto TRAVEL_DIST = HEIGHT + PADDING_OUT;
|
const auto TRAVEL_DIST = HEIGHT + PADDING_OUT;
|
||||||
auto OFFSET = notifications_.empty()
|
auto offset = notifications_.empty()
|
||||||
? DESP_V
|
? DESP_V
|
||||||
: notifications_.back().y + (param.notification.pos_v == NotifyPosition::TOP ? TRAVEL_DIST : -TRAVEL_DIST);
|
: notifications_.back().y + (param.notification.pos_v == NotifyPosition::TOP ? TRAVEL_DIST : -TRAVEL_DIST);
|
||||||
|
|
||||||
@@ -185,11 +185,11 @@ void Notifier::show(std::vector<std::string> texts, int icon, const std::string
|
|||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
n.code = code;
|
n.code = code;
|
||||||
n.y = OFFSET;
|
n.y = offset;
|
||||||
n.travel_dist = TRAVEL_DIST;
|
n.travel_dist = TRAVEL_DIST;
|
||||||
n.texts = texts;
|
n.texts = texts;
|
||||||
n.shape = SHAPE;
|
n.shape = SHAPE;
|
||||||
const float POS_Y = OFFSET + (param.notification.pos_v == NotifyPosition::TOP ? -TRAVEL_DIST : TRAVEL_DIST);
|
const float POS_Y = offset + (param.notification.pos_v == NotifyPosition::TOP ? -TRAVEL_DIST : TRAVEL_DIST);
|
||||||
n.rect = {desp_h, POS_Y, WIDTH, HEIGHT};
|
n.rect = {desp_h, POS_Y, WIDTH, HEIGHT};
|
||||||
|
|
||||||
// Crea la textura
|
// Crea la textura
|
||||||
@@ -234,10 +234,10 @@ void Notifier::show(std::vector<std::string> texts, int icon, const std::string
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Escribe el texto de la notificación
|
// Escribe el texto de la notificación
|
||||||
const Color color{255, 255, 255};
|
const Color COLOR{255, 255, 255};
|
||||||
int iterator = 0;
|
int iterator = 0;
|
||||||
for (const auto &text : texts) {
|
for (const auto &text : texts) {
|
||||||
text_->writeColored(PADDING_IN_H + ICON_SPACE, PADDING_IN_V + iterator * (text_->getCharacterSize() + 1), text, color);
|
text_->writeColored(PADDING_IN_H + ICON_SPACE, PADDING_IN_V + iterator * (text_->getCharacterSize() + 1), text, COLOR);
|
||||||
++iterator;
|
++iterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,16 +6,16 @@
|
|||||||
#include <utility> // Para move
|
#include <utility> // Para move
|
||||||
|
|
||||||
// Devuelve un vector con los puntos que conforman la ruta
|
// Devuelve un vector con los puntos que conforman la ruta
|
||||||
std::vector<SDL_FPoint> createPath(float start, float end, PathType type, float fixed_pos, int steps, const std::function<double(double)> &easingFunction) {
|
std::vector<SDL_FPoint> createPath(float start, float end, PathType type, float fixed_pos, int steps, const std::function<double(double)> &easing_function) {
|
||||||
std::vector<SDL_FPoint> v;
|
std::vector<SDL_FPoint> v;
|
||||||
v.reserve(steps);
|
v.reserve(steps);
|
||||||
|
|
||||||
for (int i = 0; i < steps; ++i) {
|
for (int i = 0; i < steps; ++i) {
|
||||||
double t = static_cast<double>(i) / (steps - 1);
|
double t = static_cast<double>(i) / (steps - 1);
|
||||||
double value = start + (end - start) * easingFunction(t);
|
double value = start + (end - start) * easing_function(t);
|
||||||
|
|
||||||
if ((start > 0 && end < 0) || (start < 0 && end > 0)) {
|
if ((start > 0 && end < 0) || (start < 0 && end > 0)) {
|
||||||
value = start + (end > 0 ? 1 : -1) * std::abs(end - start) * easingFunction(t);
|
value = start + (end > 0 ? 1 : -1) * std::abs(end - start) * easing_function(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@@ -56,16 +56,16 @@ void PathSprite::addPath(Path path, bool centered) {
|
|||||||
|
|
||||||
switch (path_centered) {
|
switch (path_centered) {
|
||||||
case PathCentered::ON_X: {
|
case PathCentered::ON_X: {
|
||||||
const int x = path.spots.back().x - pos_.w / 2;
|
const int X = path.spots.back().x - pos_.w / 2;
|
||||||
for (auto &spot : path.spots)
|
for (auto &spot : path.spots)
|
||||||
spot.x = x;
|
spot.x = X;
|
||||||
paths_.emplace_back(path);
|
paths_.emplace_back(path);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PathCentered::ON_Y: {
|
case PathCentered::ON_Y: {
|
||||||
const int y = path.spots.back().y - pos_.h / 2;
|
const int Y = path.spots.back().y - pos_.h / 2;
|
||||||
for (auto &spot : path.spots)
|
for (auto &spot : path.spots)
|
||||||
spot.y = y;
|
spot.y = Y;
|
||||||
paths_.emplace_back(path);
|
paths_.emplace_back(path);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -76,8 +76,8 @@ void PathSprite::addPath(Path path, bool centered) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Añade un recorrido
|
// Añade un recorrido
|
||||||
void PathSprite::addPath(int start, int end, PathType type, int fixed_pos, int steps, const std::function<double(double)> &easingFunction, int waiting_counter) {
|
void PathSprite::addPath(int start, int end, PathType type, int fixed_pos, int steps, const std::function<double(double)> &easing_function, int waiting_counter) {
|
||||||
paths_.emplace_back(createPath(start, end, type, fixed_pos, steps, easingFunction), waiting_counter);
|
paths_.emplace_back(createPath(start, end, type, fixed_pos, steps, easing_function), waiting_counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Añade un recorrido
|
// Añade un recorrido
|
||||||
@@ -95,8 +95,8 @@ void PathSprite::enable() {
|
|||||||
|
|
||||||
// Establece la posición
|
// Establece la posición
|
||||||
auto &path = paths_.at(current_path_);
|
auto &path = paths_.at(current_path_);
|
||||||
const auto &P = path.spots.at(path.counter);
|
const auto &p = path.spots.at(path.counter);
|
||||||
setPosition(P);
|
setPosition(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Coloca el sprite en los diferentes puntos del recorrido
|
// Coloca el sprite en los diferentes puntos del recorrido
|
||||||
|
|||||||
@@ -174,8 +174,8 @@ void Player::move() {
|
|||||||
if (player_sprite_->getPosY() > play_area_.h - HEIGHT_) {
|
if (player_sprite_->getPosY() > play_area_.h - HEIGHT_) {
|
||||||
if (player_sprite_->getVelY() < 2.0f) {
|
if (player_sprite_->getVelY() < 2.0f) {
|
||||||
// Si la velocidad de rebote es baja, lo detiene y cambia de estado
|
// Si la velocidad de rebote es baja, lo detiene y cambia de estado
|
||||||
const auto nextPlayerStatus = IsEligibleForHighScore() ? PlayerState::ENTERING_NAME : PlayerState::CONTINUE;
|
const auto NEXT_PLAYER_STATUS = IsEligibleForHighScore() ? PlayerState::ENTERING_NAME : PlayerState::CONTINUE;
|
||||||
demo_ ? setPlayingState(PlayerState::LYING_ON_THE_FLOOR_FOREVER) : setPlayingState(nextPlayerStatus);
|
demo_ ? setPlayingState(PlayerState::LYING_ON_THE_FLOOR_FOREVER) : setPlayingState(NEXT_PLAYER_STATUS);
|
||||||
pos_x_ = player_sprite_->getPosX();
|
pos_x_ = player_sprite_->getPosX();
|
||||||
pos_y_ = default_pos_y_;
|
pos_y_ = default_pos_y_;
|
||||||
player_sprite_->clear();
|
player_sprite_->clear();
|
||||||
@@ -791,14 +791,14 @@ void Player::playSound(const std::string &name) {
|
|||||||
if (demo_)
|
if (demo_)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
static auto audio = Audio::get();
|
static auto audio_ = Audio::get();
|
||||||
audio->playSound(name);
|
audio_->playSound(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Añade una puntuación a la tabla de records
|
// Añade una puntuación a la tabla de records
|
||||||
void Player::addScoreToScoreBoard() {
|
void Player::addScoreToScoreBoard() {
|
||||||
const auto entry = HiScoreEntry(trim(getLastEnterName()), getScore(), get1CC());
|
const auto ENTRY = HiScoreEntry(trim(getLastEnterName()), getScore(), get1CC());
|
||||||
auto manager = std::make_unique<ManageHiScoreTable>(Options::settings.hi_score_table);
|
auto manager = std::make_unique<ManageHiScoreTable>(Options::settings.hi_score_table);
|
||||||
Options::settings.last_hi_score_entry.at(getId() - 1) = manager->add(entry);
|
Options::settings.last_hi_score_entry.at(getId() - 1) = manager->add(ENTRY);
|
||||||
manager->saveToFile(Asset::get()->get("score.bin"));
|
manager->saveToFile(Asset::get()->get("score.bin"));
|
||||||
}
|
}
|
||||||
@@ -234,9 +234,9 @@ void Resource::loadAnimations() {
|
|||||||
void Resource::loadDemoData() {
|
void Resource::loadDemoData() {
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> DEMO FILES");
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> DEMO FILES");
|
||||||
|
|
||||||
constexpr std::array<const char *, 2> demo_files = {"demo1.bin", "demo2.bin"};
|
constexpr std::array<const char *, 2> DEMO_FILES = {"demo1.bin", "demo2.bin"};
|
||||||
|
|
||||||
for (const auto &file : demo_files) {
|
for (const auto &file : DEMO_FILES) {
|
||||||
updateLoadingProgress(file);
|
updateLoadingProgress(file);
|
||||||
demos_.emplace_back(loadDemoDataFromFile(Asset::get()->get(file)));
|
demos_.emplace_back(loadDemoDataFromFile(Asset::get()->get(file)));
|
||||||
}
|
}
|
||||||
@@ -286,7 +286,7 @@ void Resource::createTextures() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Texturas de tamaño doble
|
// Texturas de tamaño doble
|
||||||
std::vector<NameAndText> strings2X = {
|
std::vector<NameAndText> strings2_x = {
|
||||||
{"game_text_100000_points", "100.000"},
|
{"game_text_100000_points", "100.000"},
|
||||||
{"game_text_get_ready", Lang::getText("[GAME_TEXT] 7")},
|
{"game_text_get_ready", Lang::getText("[GAME_TEXT] 7")},
|
||||||
{"game_text_last_stage", Lang::getText("[GAME_TEXT] 3")},
|
{"game_text_last_stage", Lang::getText("[GAME_TEXT] 3")},
|
||||||
@@ -294,7 +294,7 @@ void Resource::createTextures() {
|
|||||||
{"game_text_game_over", "Game Over"}};
|
{"game_text_game_over", "Game Over"}};
|
||||||
|
|
||||||
auto text2 = getText("04b_25_2x");
|
auto text2 = getText("04b_25_2x");
|
||||||
for (const auto &s : strings2X) {
|
for (const auto &s : strings2_x) {
|
||||||
textures_.emplace_back(Resource::ResourceTexture(s.name, text2->writeToTexture(s.text, 1, -4)));
|
textures_.emplace_back(Resource::ResourceTexture(s.name, text2->writeToTexture(s.text, 1, -4)));
|
||||||
printWithDots("Texture : ", s.name, "[ DONE ]");
|
printWithDots("Texture : ", s.name, "[ DONE ]");
|
||||||
}
|
}
|
||||||
@@ -304,11 +304,11 @@ void Resource::createTextures() {
|
|||||||
void Resource::createText() {
|
void Resource::createText() {
|
||||||
struct ResourceInfo {
|
struct ResourceInfo {
|
||||||
std::string key;
|
std::string key;
|
||||||
std::string textureFile;
|
std::string texture_file;
|
||||||
std::string textFile;
|
std::string text_file;
|
||||||
|
|
||||||
ResourceInfo(const std::string &k, const std::string &tFile, const std::string &txtFile)
|
ResourceInfo(const std::string &k, const std::string &t_file, const std::string &txt_file)
|
||||||
: key(k), textureFile(tFile), textFile(txtFile) {}
|
: key(k), texture_file(t_file), text_file(txt_file) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> CREATING TEXT OBJECTS");
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> CREATING TEXT OBJECTS");
|
||||||
@@ -328,7 +328,7 @@ void Resource::createText() {
|
|||||||
{"smb2_grad", "smb2_grad.png", "smb2.txt"}};
|
{"smb2_grad", "smb2_grad.png", "smb2.txt"}};
|
||||||
|
|
||||||
for (const auto &resource : resources) {
|
for (const auto &resource : resources) {
|
||||||
texts_.emplace_back(Resource::ResourceText(resource.key, std::make_shared<Text>(getTexture(resource.textureFile), getTextFile(resource.textFile))));
|
texts_.emplace_back(Resource::ResourceText(resource.key, std::make_shared<Text>(getTexture(resource.texture_file), getTextFile(resource.text_file))));
|
||||||
printWithDots("Text : ", resource.key, "[ DONE ]");
|
printWithDots("Text : ", resource.key, "[ DONE ]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -213,8 +213,8 @@ void Scoreboard::fillPanelTextures() {
|
|||||||
|
|
||||||
// HI-SCORE
|
// HI-SCORE
|
||||||
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_3_.x, slot4_3_.y, Lang::getText("[SCOREBOARD] 4"), 1, text_color1_);
|
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_3_.x, slot4_3_.y, Lang::getText("[SCOREBOARD] 4"), 1, text_color1_);
|
||||||
const std::string name = hi_score_name_ == "" ? "" : hi_score_name_ + " - ";
|
const std::string NAME = hi_score_name_ == "" ? "" : hi_score_name_ + " - ";
|
||||||
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_4_.x, slot4_4_.y, name + updateScoreText(hi_score_), 1, text_color2_);
|
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_4_.x, slot4_4_.y, NAME + updateScoreText(hi_score_), 1, text_color2_);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,18 +242,18 @@ void Scoreboard::fillPanelTextures() {
|
|||||||
// Recorre todos los slots de letras del nombre
|
// Recorre todos los slots de letras del nombre
|
||||||
for (size_t j = 0; j < NAME_SIZE; ++j) {
|
for (size_t j = 0; j < NAME_SIZE; ++j) {
|
||||||
// Selecciona el color
|
// Selecciona el color
|
||||||
const Color color = j < selector_pos_[i] ? text_color2_ : text_color1_;
|
const Color COLOR = j < selector_pos_[i] ? text_color2_ : text_color1_;
|
||||||
|
|
||||||
if (j != selector_pos_[i] || time_counter_ % 3 == 0) {
|
if (j != selector_pos_[i] || time_counter_ % 3 == 0) {
|
||||||
// Dibuja la linea
|
// Dibuja la linea
|
||||||
if (j >= selector_pos_[i]) {
|
if (j >= selector_pos_[i]) {
|
||||||
SDL_SetRenderDrawColor(renderer_, color.r, color.g, color.b, 255);
|
SDL_SetRenderDrawColor(renderer_, COLOR.r, COLOR.g, COLOR.b, 255);
|
||||||
SDL_RenderLine(renderer_, rect.x, rect.y + rect.h, rect.x + rect.w, rect.y + rect.h);
|
SDL_RenderLine(renderer_, rect.x, rect.y + rect.h, rect.x + rect.w, rect.y + rect.h);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja la letra
|
// Dibuja la letra
|
||||||
if (j < record_name_[i].size()) {
|
if (j < record_name_[i].size()) {
|
||||||
text_scoreboard_->writeColored(rect.x, rect.y, record_name_[i].substr(j, 1), color);
|
text_scoreboard_->writeColored(rect.x, rect.y, record_name_[i].substr(j, 1), COLOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rect.x += 7;
|
rect.x += 7;
|
||||||
@@ -323,11 +323,11 @@ void Scoreboard::fillBackgroundTexture() {
|
|||||||
// Recalcula las anclas de los elementos
|
// Recalcula las anclas de los elementos
|
||||||
void Scoreboard::recalculateAnchors() {
|
void Scoreboard::recalculateAnchors() {
|
||||||
// Recalcula la posición y el tamaño de los paneles
|
// Recalcula la posición y el tamaño de los paneles
|
||||||
const float panel_width = (float)rect_.w / (float)SCOREBOARD_MAX_PANELS;
|
const float PANEL_WIDTH = (float)rect_.w / (float)SCOREBOARD_MAX_PANELS;
|
||||||
for (int i = 0; i < SCOREBOARD_MAX_PANELS; ++i) {
|
for (int i = 0; i < SCOREBOARD_MAX_PANELS; ++i) {
|
||||||
panel_[i].pos.x = roundf(panel_width * i);
|
panel_[i].pos.x = roundf(PANEL_WIDTH * i);
|
||||||
panel_[i].pos.y = 0;
|
panel_[i].pos.y = 0;
|
||||||
panel_[i].pos.w = roundf(panel_width * (i + 1)) - panel_[i].pos.x;
|
panel_[i].pos.w = roundf(PANEL_WIDTH * (i + 1)) - panel_[i].pos.x;
|
||||||
panel_[i].pos.h = rect_.h;
|
panel_[i].pos.h = rect_.h;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,7 +342,7 @@ void Scoreboard::recalculateAnchors() {
|
|||||||
const float ROW4 = 1 + (ROW_SIZE * 3) + (TEXT_HEIGHT / 2) - 3;
|
const float ROW4 = 1 + (ROW_SIZE * 3) + (TEXT_HEIGHT / 2) - 3;
|
||||||
|
|
||||||
// Columna
|
// Columna
|
||||||
const float COL = panel_width / 2;
|
const float COL = PANEL_WIDTH / 2;
|
||||||
|
|
||||||
// Slots de 4
|
// Slots de 4
|
||||||
slot4_1_ = {COL, ROW1};
|
slot4_1_ = {COL, ROW1};
|
||||||
@@ -351,8 +351,8 @@ void Scoreboard::recalculateAnchors() {
|
|||||||
slot4_4_ = {COL, ROW4};
|
slot4_4_ = {COL, ROW4};
|
||||||
|
|
||||||
// Primer cuadrado para poner el nombre de record
|
// Primer cuadrado para poner el nombre de record
|
||||||
const int enter_name_lenght = text_scoreboard_->lenght(std::string(NAME_SIZE, 'A'));
|
const int ENTER_NAME_LENGHT = text_scoreboard_->lenght(std::string(NAME_SIZE, 'A'));
|
||||||
enter_name_pos_.x = COL - (enter_name_lenght / 2);
|
enter_name_pos_.x = COL - (ENTER_NAME_LENGHT / 2);
|
||||||
enter_name_pos_.y = ROW4;
|
enter_name_pos_.y = ROW4;
|
||||||
|
|
||||||
// Recoloca los sprites
|
// Recoloca los sprites
|
||||||
|
|||||||
@@ -257,8 +257,8 @@ void Credits::fillCanvas() {
|
|||||||
|
|
||||||
// Dibuja el rectangulo rojo
|
// Dibuja el rectangulo rojo
|
||||||
// SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0xFF, 0, 0, 0xFF);
|
// SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0xFF, 0, 0, 0xFF);
|
||||||
const Color color = color_.LIGHTEN();
|
const Color COLOR = color_.LIGHTEN();
|
||||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), color.r, color.g, color.b, 0xFF);
|
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), COLOR.r, COLOR.g, COLOR.b, 0xFF);
|
||||||
SDL_RenderRect(Screen::get()->getRenderer(), &red_rect);
|
SDL_RenderRect(Screen::get()->getRenderer(), &red_rect);
|
||||||
|
|
||||||
// Si el mini_logo está en su destino, lo dibuja encima de lo anterior
|
// Si el mini_logo está en su destino, lo dibuja encima de lo anterior
|
||||||
@@ -305,19 +305,19 @@ void Credits::updateTextureDstRects() {
|
|||||||
|
|
||||||
// Tira globos al escenario
|
// Tira globos al escenario
|
||||||
void Credits::throwBalloons() {
|
void Credits::throwBalloons() {
|
||||||
constexpr int speed = 200;
|
constexpr int SPEED = 200;
|
||||||
const std::vector<int> sets = {0, 63, 25, 67, 17, 75, 13, 50};
|
const std::vector<int> SETS = {0, 63, 25, 67, 17, 75, 13, 50};
|
||||||
|
|
||||||
if (counter_ > ((sets.size() - 1) * speed) * 3) {
|
if (counter_ > ((SETS.size() - 1) * SPEED) * 3) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (counter_ % speed == 0) {
|
if (counter_ % SPEED == 0) {
|
||||||
const int index = (counter_ / speed) % sets.size();
|
const int INDEX = (counter_ / SPEED) % SETS.size();
|
||||||
balloon_manager_->deploySet(sets.at(index), -60);
|
balloon_manager_->deploySet(SETS.at(INDEX), -60);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (counter_ % (speed * 4) == 0 && counter_ > 0) {
|
if (counter_ % (SPEED * 4) == 0 && counter_ > 0) {
|
||||||
balloon_manager_->createPowerBall();
|
balloon_manager_->createPowerBall();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -365,7 +365,7 @@ void Credits::initPlayers() {
|
|||||||
|
|
||||||
// Actualiza los rectangulos negros
|
// Actualiza los rectangulos negros
|
||||||
void Credits::updateBlackRects() {
|
void Credits::updateBlackRects() {
|
||||||
static int current_step = steps_;
|
static int current_step_ = steps_;
|
||||||
if (top_black_rect_.h != param.game.game_area.center_y - 1 && bottom_black_rect_.y != param.game.game_area.center_y + 1) {
|
if (top_black_rect_.h != param.game.game_area.center_y - 1 && bottom_black_rect_.y != param.game.game_area.center_y + 1) {
|
||||||
// Si los rectangulos superior e inferior no han llegado al centro
|
// Si los rectangulos superior e inferior no han llegado al centro
|
||||||
if (counter_ % 4 == 0) {
|
if (counter_ % 4 == 0) {
|
||||||
@@ -376,8 +376,8 @@ void Credits::updateBlackRects() {
|
|||||||
++bottom_black_rect_.h;
|
++bottom_black_rect_.h;
|
||||||
bottom_black_rect_.y = std::max(bottom_black_rect_.y - 1, param.game.game_area.center_y + 1);
|
bottom_black_rect_.y = std::max(bottom_black_rect_.y - 1, param.game.game_area.center_y + 1);
|
||||||
|
|
||||||
--current_step;
|
--current_step_;
|
||||||
setVolume(static_cast<int>(initial_volume_ * current_step / steps_));
|
setVolume(static_cast<int>(initial_volume_ * current_step_ / steps_));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Si los rectangulos superior e inferior han llegado al centro
|
// Si los rectangulos superior e inferior han llegado al centro
|
||||||
@@ -391,8 +391,8 @@ void Credits::updateBlackRects() {
|
|||||||
right_black_rect_.w += SPEED;
|
right_black_rect_.w += SPEED;
|
||||||
right_black_rect_.x = std::max(right_black_rect_.x - SPEED, param.game.game_area.center_x);
|
right_black_rect_.x = std::max(right_black_rect_.x - SPEED, param.game.game_area.center_x);
|
||||||
|
|
||||||
--current_step;
|
--current_step_;
|
||||||
setVolume(static_cast<int>(initial_volume_ * current_step / steps_));
|
setVolume(static_cast<int>(initial_volume_ * current_step_ / steps_));
|
||||||
} else {
|
} else {
|
||||||
// Si los rectangulos izquierdo y derecho han llegado al centro
|
// Si los rectangulos izquierdo y derecho han llegado al centro
|
||||||
setVolume(0);
|
setVolume(0);
|
||||||
@@ -452,33 +452,33 @@ void Credits::cycleColors() {
|
|||||||
constexpr int UPPER_LIMIT = 140; // Límite superior
|
constexpr int UPPER_LIMIT = 140; // Límite superior
|
||||||
constexpr int LOWER_LIMIT = 30; // Límite inferior
|
constexpr int LOWER_LIMIT = 30; // Límite inferior
|
||||||
|
|
||||||
static float r = static_cast<float>(UPPER_LIMIT);
|
static float r_ = static_cast<float>(UPPER_LIMIT);
|
||||||
static float g = static_cast<float>(LOWER_LIMIT);
|
static float g_ = static_cast<float>(LOWER_LIMIT);
|
||||||
static float b = static_cast<float>(LOWER_LIMIT);
|
static float b_ = static_cast<float>(LOWER_LIMIT);
|
||||||
static float stepR = -0.5f; // Paso flotante para transiciones suaves
|
static float step_r_ = -0.5f; // Paso flotante para transiciones suaves
|
||||||
static float stepG = 0.3f;
|
static float step_g_ = 0.3f;
|
||||||
static float stepB = 0.1f;
|
static float step_b_ = 0.1f;
|
||||||
|
|
||||||
// Ajustar valores de R
|
// Ajustar valores de R
|
||||||
r += stepR;
|
r_ += step_r_;
|
||||||
if (r >= UPPER_LIMIT || r <= LOWER_LIMIT) {
|
if (r_ >= UPPER_LIMIT || r_ <= LOWER_LIMIT) {
|
||||||
stepR = -stepR; // Cambia de dirección al alcanzar los límites
|
step_r_ = -step_r_; // Cambia de dirección al alcanzar los límites
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ajustar valores de G
|
// Ajustar valores de G
|
||||||
g += stepG;
|
g_ += step_g_;
|
||||||
if (g >= UPPER_LIMIT || g <= LOWER_LIMIT) {
|
if (g_ >= UPPER_LIMIT || g_ <= LOWER_LIMIT) {
|
||||||
stepG = -stepG; // Cambia de dirección al alcanzar los límites
|
step_g_ = -step_g_; // Cambia de dirección al alcanzar los límites
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ajustar valores de B
|
// Ajustar valores de B
|
||||||
b += stepB;
|
b_ += step_b_;
|
||||||
if (b >= UPPER_LIMIT || b <= LOWER_LIMIT) {
|
if (b_ >= UPPER_LIMIT || b_ <= LOWER_LIMIT) {
|
||||||
stepB = -stepB; // Cambia de dirección al alcanzar los límites
|
step_b_ = -step_b_; // Cambia de dirección al alcanzar los límites
|
||||||
}
|
}
|
||||||
|
|
||||||
// Aplicar el color, redondeando a enteros antes de usar
|
// Aplicar el color, redondeando a enteros antes de usar
|
||||||
color_ = Color(static_cast<int>(r), static_cast<int>(g), static_cast<int>(b));
|
color_ = Color(static_cast<int>(r_), static_cast<int>(g_), static_cast<int>(b_));
|
||||||
tiled_bg_->setColor(color_);
|
tiled_bg_->setColor(color_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -253,8 +253,8 @@ void Game::updateStage() {
|
|||||||
createMessage(paths, Resource::get()->getTexture("game_text_last_stage"));
|
createMessage(paths, Resource::get()->getTexture("game_text_last_stage"));
|
||||||
} else {
|
} else {
|
||||||
auto text = Resource::get()->getText("04b_25_2x");
|
auto text = Resource::get()->getText("04b_25_2x");
|
||||||
const std::string caption = std::to_string(10 - Stage::number) + Lang::getText("[GAME_TEXT] 2");
|
const std::string CAPTION = std::to_string(10 - Stage::number) + Lang::getText("[GAME_TEXT] 2");
|
||||||
createMessage(paths, text->writeToTexture(caption, 1, -4));
|
createMessage(paths, text->writeToTexture(CAPTION, 1, -4));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -422,48 +422,48 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player) {
|
|||||||
switch (item->getType()) {
|
switch (item->getType()) {
|
||||||
case ItemType::DISK: {
|
case ItemType::DISK: {
|
||||||
player->addScore(1000);
|
player->addScore(1000);
|
||||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(0)->getWidth()) / 2;
|
const auto X = item->getPosX() + (item->getWidth() - game_text_textures_.at(0)->getWidth()) / 2;
|
||||||
createItemText(x, game_text_textures_.at(0));
|
createItemText(X, game_text_textures_.at(0));
|
||||||
playSound("item_pickup.wav");
|
playSound("item_pickup.wav");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ItemType::GAVINA: {
|
case ItemType::GAVINA: {
|
||||||
player->addScore(2500);
|
player->addScore(2500);
|
||||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(1)->getWidth()) / 2;
|
const auto X = item->getPosX() + (item->getWidth() - game_text_textures_.at(1)->getWidth()) / 2;
|
||||||
createItemText(x, game_text_textures_.at(1));
|
createItemText(X, game_text_textures_.at(1));
|
||||||
playSound("item_pickup.wav");
|
playSound("item_pickup.wav");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ItemType::PACMAR: {
|
case ItemType::PACMAR: {
|
||||||
player->addScore(5000);
|
player->addScore(5000);
|
||||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(2)->getWidth()) / 2;
|
const auto X = item->getPosX() + (item->getWidth() - game_text_textures_.at(2)->getWidth()) / 2;
|
||||||
createItemText(x, game_text_textures_.at(2));
|
createItemText(X, game_text_textures_.at(2));
|
||||||
playSound("item_pickup.wav");
|
playSound("item_pickup.wav");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ItemType::DEBIAN: {
|
case ItemType::DEBIAN: {
|
||||||
player->addScore(100000);
|
player->addScore(100000);
|
||||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(6)->getWidth()) / 2;
|
const auto X = item->getPosX() + (item->getWidth() - game_text_textures_.at(6)->getWidth()) / 2;
|
||||||
createItemText(x, game_text_textures_.at(6));
|
createItemText(X, game_text_textures_.at(6));
|
||||||
playSound("debian_pickup.wav");
|
playSound("debian_pickup.wav");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ItemType::CLOCK: {
|
case ItemType::CLOCK: {
|
||||||
enableTimeStopItem();
|
enableTimeStopItem();
|
||||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(5)->getWidth()) / 2;
|
const auto X = item->getPosX() + (item->getWidth() - game_text_textures_.at(5)->getWidth()) / 2;
|
||||||
createItemText(x, game_text_textures_.at(5));
|
createItemText(X, game_text_textures_.at(5));
|
||||||
playSound("item_pickup.wav");
|
playSound("item_pickup.wav");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ItemType::COFFEE: {
|
case ItemType::COFFEE: {
|
||||||
if (player->getCoffees() == 2) {
|
if (player->getCoffees() == 2) {
|
||||||
player->addScore(5000);
|
player->addScore(5000);
|
||||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(2)->getWidth()) / 2;
|
const auto X = item->getPosX() + (item->getWidth() - game_text_textures_.at(2)->getWidth()) / 2;
|
||||||
createItemText(x, game_text_textures_.at(2));
|
createItemText(X, game_text_textures_.at(2));
|
||||||
} else {
|
} else {
|
||||||
player->giveExtraHit();
|
player->giveExtraHit();
|
||||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(4)->getWidth()) / 2;
|
const auto X = item->getPosX() + (item->getWidth() - game_text_textures_.at(4)->getWidth()) / 2;
|
||||||
createItemText(x, game_text_textures_.at(4));
|
createItemText(X, game_text_textures_.at(4));
|
||||||
}
|
}
|
||||||
playSound("voice_coffee.wav");
|
playSound("voice_coffee.wav");
|
||||||
break;
|
break;
|
||||||
@@ -471,8 +471,8 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player) {
|
|||||||
case ItemType::COFFEE_MACHINE: {
|
case ItemType::COFFEE_MACHINE: {
|
||||||
player->setPowerUp();
|
player->setPowerUp();
|
||||||
coffee_machine_enabled_ = false;
|
coffee_machine_enabled_ = false;
|
||||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(3)->getWidth()) / 2;
|
const auto X = item->getPosX() + (item->getWidth() - game_text_textures_.at(3)->getWidth()) / 2;
|
||||||
createItemText(x, game_text_textures_.at(3));
|
createItemText(X, game_text_textures_.at(3));
|
||||||
playSound("voice_power_up.wav");
|
playSound("voice_power_up.wav");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -516,12 +516,12 @@ void Game::checkBulletCollision() {
|
|||||||
auto player = getPlayer(bullet->getOwner());
|
auto player = getPlayer(bullet->getOwner());
|
||||||
|
|
||||||
// Suelta el item si se da el caso
|
// Suelta el item si se da el caso
|
||||||
const auto dropped_item = dropItem();
|
const auto DROPPED_ITEM = dropItem();
|
||||||
if (dropped_item != ItemType::NONE && !demo_.recording) {
|
if (DROPPED_ITEM != ItemType::NONE && !demo_.recording) {
|
||||||
if (dropped_item != ItemType::COFFEE_MACHINE) {
|
if (DROPPED_ITEM != ItemType::COFFEE_MACHINE) {
|
||||||
createItem(dropped_item, balloon->getPosX(), balloon->getPosY());
|
createItem(DROPPED_ITEM, balloon->getPosX(), balloon->getPosY());
|
||||||
} else {
|
} else {
|
||||||
createItem(dropped_item, player->getPosX(), param.game.game_area.rect.y - Item::COFFEE_MACHINE_HEIGHT);
|
createItem(DROPPED_ITEM, player->getPosX(), param.game.game_area.rect.y - Item::COFFEE_MACHINE_HEIGHT);
|
||||||
coffee_machine_enabled_ = true;
|
coffee_machine_enabled_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -595,32 +595,32 @@ void Game::renderItems() {
|
|||||||
|
|
||||||
// Devuelve un item al azar y luego segun sus probabilidades
|
// Devuelve un item al azar y luego segun sus probabilidades
|
||||||
ItemType Game::dropItem() {
|
ItemType Game::dropItem() {
|
||||||
const auto lucky_number = rand() % 100;
|
const auto LUCKY_NUMBER = rand() % 100;
|
||||||
const auto item = rand() % 6;
|
const auto ITEM = rand() % 6;
|
||||||
|
|
||||||
switch (item) {
|
switch (ITEM) {
|
||||||
case 0:
|
case 0:
|
||||||
if (lucky_number < helper_.item_disk_odds) {
|
if (LUCKY_NUMBER < helper_.item_disk_odds) {
|
||||||
return ItemType::DISK;
|
return ItemType::DISK;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if (lucky_number < helper_.item_gavina_odds) {
|
if (LUCKY_NUMBER < helper_.item_gavina_odds) {
|
||||||
return ItemType::GAVINA;
|
return ItemType::GAVINA;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (lucky_number < helper_.item_pacmar_odds) {
|
if (LUCKY_NUMBER < helper_.item_pacmar_odds) {
|
||||||
return ItemType::GAVINA;
|
return ItemType::GAVINA;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if (lucky_number < helper_.item_clock_odds) {
|
if (LUCKY_NUMBER < helper_.item_clock_odds) {
|
||||||
return ItemType::CLOCK;
|
return ItemType::CLOCK;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if (lucky_number < helper_.item_coffee_odds) {
|
if (LUCKY_NUMBER < helper_.item_coffee_odds) {
|
||||||
helper_.item_coffee_odds = ITEM_COFFEE_ODDS_;
|
helper_.item_coffee_odds = ITEM_COFFEE_ODDS_;
|
||||||
return ItemType::COFFEE;
|
return ItemType::COFFEE;
|
||||||
} else {
|
} else {
|
||||||
@@ -630,7 +630,7 @@ ItemType Game::dropItem() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
if (lucky_number < helper_.item_coffee_machine_odds) {
|
if (LUCKY_NUMBER < helper_.item_coffee_machine_odds) {
|
||||||
helper_.item_coffee_machine_odds = ITEM_COFFEE_MACHINE_ODDS_;
|
helper_.item_coffee_machine_odds = ITEM_COFFEE_MACHINE_ODDS_;
|
||||||
if (!coffee_machine_enabled_ && helper_.need_coffee_machine) {
|
if (!coffee_machine_enabled_ && helper_.need_coffee_machine) {
|
||||||
return ItemType::COFFEE_MACHINE;
|
return ItemType::COFFEE_MACHINE;
|
||||||
@@ -666,22 +666,22 @@ void Game::freeItems() {
|
|||||||
void Game::createItemText(int x, std::shared_ptr<Texture> texture) {
|
void Game::createItemText(int x, std::shared_ptr<Texture> texture) {
|
||||||
path_sprites_.emplace_back(std::make_unique<PathSprite>(texture));
|
path_sprites_.emplace_back(std::make_unique<PathSprite>(texture));
|
||||||
|
|
||||||
const auto w = texture->getWidth();
|
const auto W = texture->getWidth();
|
||||||
const auto h = texture->getHeight();
|
const auto H = texture->getHeight();
|
||||||
|
|
||||||
const int y0 = param.game.play_area.rect.h - h;
|
const int Y0 = param.game.play_area.rect.h - H;
|
||||||
const int y1 = 160 - (h / 2);
|
const int Y1 = 160 - (H / 2);
|
||||||
const int y2 = -h;
|
const int Y2 = -H;
|
||||||
|
|
||||||
// Ajusta para que no se dibuje fuera de pantalla
|
// Ajusta para que no se dibuje fuera de pantalla
|
||||||
x = std::clamp(x, 2, static_cast<int>(param.game.play_area.rect.w) - w - 2);
|
x = std::clamp(x, 2, static_cast<int>(param.game.play_area.rect.w) - W - 2);
|
||||||
|
|
||||||
// Inicializa
|
// Inicializa
|
||||||
path_sprites_.back()->setWidth(w);
|
path_sprites_.back()->setWidth(W);
|
||||||
path_sprites_.back()->setHeight(h);
|
path_sprites_.back()->setHeight(H);
|
||||||
path_sprites_.back()->setSpriteClip({0, 0, static_cast<float>(w), static_cast<float>(h)});
|
path_sprites_.back()->setSpriteClip({0, 0, static_cast<float>(W), static_cast<float>(H)});
|
||||||
path_sprites_.back()->addPath(y0, y1, PathType::VERTICAL, x, 100, easeOutQuint, 0);
|
path_sprites_.back()->addPath(Y0, Y1, PathType::VERTICAL, x, 100, easeOutQuint, 0);
|
||||||
path_sprites_.back()->addPath(y1, y2, PathType::VERTICAL, x, 80, easeInQuint, 0);
|
path_sprites_.back()->addPath(Y1, Y2, PathType::VERTICAL, x, 80, easeInQuint, 0);
|
||||||
path_sprites_.back()->enable();
|
path_sprites_.back()->enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -866,19 +866,19 @@ void Game::updateBackground() {
|
|||||||
// Calcula la velocidad en función de los globos explotados y el total de globos a explotar para acabar el juego
|
// Calcula la velocidad en función de los globos explotados y el total de globos a explotar para acabar el juego
|
||||||
constexpr float CLOUDS_INITIAL_SPEED = 0.05f;
|
constexpr float CLOUDS_INITIAL_SPEED = 0.05f;
|
||||||
constexpr float CLOUDS_FINAL_SPEED = 2.00f - CLOUDS_INITIAL_SPEED;
|
constexpr float CLOUDS_FINAL_SPEED = 2.00f - CLOUDS_INITIAL_SPEED;
|
||||||
const float cloudsSpeed = (-CLOUDS_INITIAL_SPEED) + (-CLOUDS_FINAL_SPEED * (static_cast<float>(Stage::total_power) / total_power_to_complete_game_));
|
const float CLOUDS_SPEED = (-CLOUDS_INITIAL_SPEED) + (-CLOUDS_FINAL_SPEED * (static_cast<float>(Stage::total_power) / total_power_to_complete_game_));
|
||||||
background_->setCloudsSpeed(cloudsSpeed);
|
background_->setCloudsSpeed(CLOUDS_SPEED);
|
||||||
|
|
||||||
// Calcula la transición de los diferentes fondos
|
// Calcula la transición de los diferentes fondos
|
||||||
constexpr float num = 1525.0f; // total_power_to_complete div 4
|
constexpr float NUM = 1525.0f; // total_power_to_complete div 4
|
||||||
const float gradient_number = std::min(Stage::total_power / num, 3.0f);
|
const float GRADIENT_NUMBER = std::min(Stage::total_power / NUM, 3.0f);
|
||||||
const float percent = gradient_number - static_cast<int>(gradient_number);
|
const float PERCENT = GRADIENT_NUMBER - static_cast<int>(GRADIENT_NUMBER);
|
||||||
background_->setGradientNumber(static_cast<int>(gradient_number));
|
background_->setGradientNumber(static_cast<int>(GRADIENT_NUMBER));
|
||||||
background_->setTransition(percent);
|
background_->setTransition(PERCENT);
|
||||||
|
|
||||||
// Calcula la posición del sol
|
// Calcula la posición del sol
|
||||||
constexpr float sun_final_power = num * 2;
|
constexpr float SUN_FINAL_POWER = NUM * 2;
|
||||||
background_->setSunProgression(Stage::total_power / sun_final_power);
|
background_->setSunProgression(Stage::total_power / SUN_FINAL_POWER);
|
||||||
background_->setMoonProgression(Stage::total_power / static_cast<float>(total_power_to_complete_game_));
|
background_->setMoonProgression(Stage::total_power / static_cast<float>(total_power_to_complete_game_));
|
||||||
|
|
||||||
// Actualiza el objeto
|
// Actualiza el objeto
|
||||||
@@ -955,51 +955,51 @@ void Game::initPaths() {
|
|||||||
// Recorrido para el texto de "Get Ready!" (0,1)
|
// Recorrido para el texto de "Get Ready!" (0,1)
|
||||||
{
|
{
|
||||||
const auto &texture = Resource::get()->getTexture("game_text_get_ready");
|
const auto &texture = Resource::get()->getTexture("game_text_get_ready");
|
||||||
const auto w = texture->getWidth();
|
const auto W = texture->getWidth();
|
||||||
const int x0 = -w;
|
const int X0 = -W;
|
||||||
const int x1 = param.game.play_area.center_x - w / 2;
|
const int X1 = param.game.play_area.center_x - W / 2;
|
||||||
const int x2 = param.game.play_area.rect.w;
|
const int X2 = param.game.play_area.rect.w;
|
||||||
const int y = param.game.play_area.center_y;
|
const int Y = param.game.play_area.center_y;
|
||||||
paths_.emplace_back(Path(createPath(x0, x1, PathType::HORIZONTAL, y, 80, easeOutQuint), 20));
|
paths_.emplace_back(Path(createPath(X0, X1, PathType::HORIZONTAL, Y, 80, easeOutQuint), 20));
|
||||||
paths_.emplace_back(Path(createPath(x1, x2, PathType::HORIZONTAL, y, 80, easeInQuint), 0));
|
paths_.emplace_back(Path(createPath(X1, X2, PathType::HORIZONTAL, Y, 80, easeInQuint), 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recorrido para el texto de "Last Stage!" o de "X stages left" o "Game Over" (2,3)
|
// Recorrido para el texto de "Last Stage!" o de "X stages left" o "Game Over" (2,3)
|
||||||
{
|
{
|
||||||
const auto &texture = Resource::get()->getTexture("game_text_last_stage");
|
const auto &texture = Resource::get()->getTexture("game_text_last_stage");
|
||||||
const auto h = texture->getHeight();
|
const auto H = texture->getHeight();
|
||||||
const int y0 = param.game.play_area.rect.h - h;
|
const int Y0 = param.game.play_area.rect.h - H;
|
||||||
const int y1 = param.game.play_area.center_y - h / 2;
|
const int Y1 = param.game.play_area.center_y - H / 2;
|
||||||
const int y2 = -h;
|
const int Y2 = -H;
|
||||||
const int x = param.game.play_area.center_x;
|
const int X = param.game.play_area.center_x;
|
||||||
paths_.emplace_back(Path(createPath(y0, y1, PathType::VERTICAL, x, 80, easeOutQuint), 20));
|
paths_.emplace_back(Path(createPath(Y0, Y1, PathType::VERTICAL, X, 80, easeOutQuint), 20));
|
||||||
paths_.emplace_back(Path(createPath(y1, y2, PathType::VERTICAL, x, 80, easeInQuint), 0));
|
paths_.emplace_back(Path(createPath(Y1, Y2, PathType::VERTICAL, X, 80, easeInQuint), 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recorrido para el texto de "Congratulations!!" (3,4)
|
// Recorrido para el texto de "Congratulations!!" (3,4)
|
||||||
{
|
{
|
||||||
const auto &texture = Resource::get()->getTexture("game_text_congratulations");
|
const auto &texture = Resource::get()->getTexture("game_text_congratulations");
|
||||||
const auto w = texture->getWidth();
|
const auto W = texture->getWidth();
|
||||||
const auto h = texture->getHeight();
|
const auto H = texture->getHeight();
|
||||||
const int x0 = -w;
|
const int X0 = -W;
|
||||||
const int x1 = param.game.play_area.center_x - w / 2;
|
const int X1 = param.game.play_area.center_x - W / 2;
|
||||||
const int x2 = param.game.play_area.rect.w;
|
const int X2 = param.game.play_area.rect.w;
|
||||||
const int y = param.game.play_area.center_y - h / 2 - 20;
|
const int Y = param.game.play_area.center_y - H / 2 - 20;
|
||||||
paths_.emplace_back(Path(createPath(x0, x1, PathType::HORIZONTAL, y, 80, easeOutQuint), 400));
|
paths_.emplace_back(Path(createPath(X0, X1, PathType::HORIZONTAL, Y, 80, easeOutQuint), 400));
|
||||||
paths_.emplace_back(Path(createPath(x1, x2, PathType::HORIZONTAL, y, 80, easeInQuint), 0));
|
paths_.emplace_back(Path(createPath(X1, X2, PathType::HORIZONTAL, Y, 80, easeInQuint), 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recorrido para el texto de "1.000.000 points!" (5,6)
|
// Recorrido para el texto de "1.000.000 points!" (5,6)
|
||||||
{
|
{
|
||||||
const auto &texture = Resource::get()->getTexture("game_text_1000000_points");
|
const auto &texture = Resource::get()->getTexture("game_text_1000000_points");
|
||||||
const auto w = texture->getWidth();
|
const auto W = texture->getWidth();
|
||||||
const auto h = texture->getHeight();
|
const auto H = texture->getHeight();
|
||||||
const int x0 = param.game.play_area.rect.w;
|
const int X0 = param.game.play_area.rect.w;
|
||||||
const int x1 = param.game.play_area.center_x - w / 2;
|
const int X1 = param.game.play_area.center_x - W / 2;
|
||||||
const int x2 = -w;
|
const int X2 = -W;
|
||||||
const int y = param.game.play_area.center_y + h / 2 - 20;
|
const int Y = param.game.play_area.center_y + H / 2 - 20;
|
||||||
paths_.emplace_back(Path(createPath(x0, x1, PathType::HORIZONTAL, y, 80, easeOutQuint), 400));
|
paths_.emplace_back(Path(createPath(X0, X1, PathType::HORIZONTAL, Y, 80, easeOutQuint), 400));
|
||||||
paths_.emplace_back(Path(createPath(x1, x2, PathType::HORIZONTAL, y, 80, easeInQuint), 0));
|
paths_.emplace_back(Path(createPath(X1, X2, PathType::HORIZONTAL, Y, 80, easeInQuint), 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1097,17 +1097,17 @@ void Game::pause(bool value) {
|
|||||||
|
|
||||||
// Añade una puntuación a la tabla de records
|
// Añade una puntuación a la tabla de records
|
||||||
void Game::addScoreToScoreBoard(const std::shared_ptr<Player> &player) {
|
void Game::addScoreToScoreBoard(const std::shared_ptr<Player> &player) {
|
||||||
const auto entry = HiScoreEntry(trim(player->getLastEnterName()), player->getScore(), player->get1CC());
|
const auto ENTRY = HiScoreEntry(trim(player->getLastEnterName()), player->getScore(), player->get1CC());
|
||||||
auto manager = std::make_unique<ManageHiScoreTable>(Options::settings.hi_score_table);
|
auto manager = std::make_unique<ManageHiScoreTable>(Options::settings.hi_score_table);
|
||||||
Options::settings.last_hi_score_entry.at(player->getId() - 1) = manager->add(entry);
|
Options::settings.last_hi_score_entry.at(player->getId() - 1) = manager->add(ENTRY);
|
||||||
manager->saveToFile(Asset::get()->get("score.bin"));
|
manager->saveToFile(Asset::get()->get("score.bin"));
|
||||||
hi_score_.name = Options::settings.hi_score_table.front().name;
|
hi_score_.name = Options::settings.hi_score_table.front().name;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Saca del estado de GAME OVER al jugador si el otro está activo
|
// Saca del estado de GAME OVER al jugador si el otro está activo
|
||||||
void Game::checkAndUpdatePlayerStatus(int activePlayerIndex, int inactivePlayerIndex) {
|
void Game::checkAndUpdatePlayerStatus(int active_player_index, int inactive_player_index) {
|
||||||
if (players_[activePlayerIndex]->isGameOver() && !players_[inactivePlayerIndex]->isGameOver() && !players_[inactivePlayerIndex]->isWaiting()) {
|
if (players_[active_player_index]->isGameOver() && !players_[inactive_player_index]->isGameOver() && !players_[inactive_player_index]->isWaiting()) {
|
||||||
players_[activePlayerIndex]->setPlayingState(PlayerState::WAITING);
|
players_[active_player_index]->setPlayingState(PlayerState::WAITING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1210,21 +1210,21 @@ void Game::DEMO_handleInput() {
|
|||||||
|
|
||||||
// Procesa las entradas para un jugador específico durante el modo demo.
|
// Procesa las entradas para un jugador específico durante el modo demo.
|
||||||
void Game::DEMO_handlePlayerInput(const std::shared_ptr<Player> &player, int index) {
|
void Game::DEMO_handlePlayerInput(const std::shared_ptr<Player> &player, int index) {
|
||||||
const auto &demoData = demo_.data[index][demo_.counter];
|
const auto &demo_data = demo_.data[index][demo_.counter];
|
||||||
|
|
||||||
if (demoData.left == 1) {
|
if (demo_data.left == 1) {
|
||||||
player->setInput(InputAction::LEFT);
|
player->setInput(InputAction::LEFT);
|
||||||
} else if (demoData.right == 1) {
|
} else if (demo_data.right == 1) {
|
||||||
player->setInput(InputAction::RIGHT);
|
player->setInput(InputAction::RIGHT);
|
||||||
} else if (demoData.no_input == 1) {
|
} else if (demo_data.no_input == 1) {
|
||||||
player->setInput(InputAction::NONE);
|
player->setInput(InputAction::NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (demoData.fire == 1) {
|
if (demo_data.fire == 1) {
|
||||||
handleFireInput(player, BulletType::UP);
|
handleFireInput(player, BulletType::UP);
|
||||||
} else if (demoData.fire_left == 1) {
|
} else if (demo_data.fire_left == 1) {
|
||||||
handleFireInput(player, BulletType::LEFT);
|
handleFireInput(player, BulletType::LEFT);
|
||||||
} else if (demoData.fire_right == 1) {
|
} else if (demo_data.fire_right == 1) {
|
||||||
handleFireInput(player, BulletType::RIGHT);
|
handleFireInput(player, BulletType::RIGHT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1275,31 +1275,31 @@ void Game::handleFireInput(const std::shared_ptr<Player> &player, BulletType bul
|
|||||||
|
|
||||||
// Gestiona las entradas de todos los jugadores en el modo normal (fuera del modo demo).
|
// Gestiona las entradas de todos los jugadores en el modo normal (fuera del modo demo).
|
||||||
void Game::handlePlayersInput() {
|
void Game::handlePlayersInput() {
|
||||||
for (const auto &PLAYER : players_) {
|
for (const auto &player : players_) {
|
||||||
if (PLAYER->isPlaying()) {
|
if (player->isPlaying()) {
|
||||||
// Maneja el input de los jugadores en modo normal.
|
// Maneja el input de los jugadores en modo normal.
|
||||||
handleNormalPlayerInput(PLAYER);
|
handleNormalPlayerInput(player);
|
||||||
} else if (PLAYER->isContinue() || PLAYER->isWaiting()) {
|
} else if (player->isContinue() || player->isWaiting()) {
|
||||||
// Gestiona la continuación del jugador.
|
// Gestiona la continuación del jugador.
|
||||||
handlePlayerContinue(PLAYER);
|
handlePlayerContinue(player);
|
||||||
} else if (PLAYER->isEnteringName() || PLAYER->isEnteringNameGameCompleted() || PLAYER->isShowingName()) {
|
} else if (player->isEnteringName() || player->isEnteringNameGameCompleted() || player->isShowingName()) {
|
||||||
// Gestiona la introducción del nombre del jugador.
|
// Gestiona la introducción del nombre del jugador.
|
||||||
handleNameInput(PLAYER);
|
handleNameInput(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Maneja las entradas de movimiento y disparo para un jugador en modo normal.
|
// Maneja las entradas de movimiento y disparo para un jugador en modo normal.
|
||||||
void Game::handleNormalPlayerInput(const std::shared_ptr<Player> &player) {
|
void Game::handleNormalPlayerInput(const std::shared_ptr<Player> &player) {
|
||||||
const auto &CONTROLLER = Options::controllers.at(player->getController());
|
const auto &controller = Options::controllers.at(player->getController());
|
||||||
const bool AUTOFIRE = player->isPowerUp() || Options::settings.autofire;
|
const bool AUTOFIRE = player->isPowerUp() || Options::settings.autofire;
|
||||||
|
|
||||||
if (input_->checkInput(InputAction::LEFT, INPUT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index)) {
|
if (input_->checkInput(InputAction::LEFT, INPUT_ALLOW_REPEAT, controller.type, controller.index)) {
|
||||||
player->setInput(InputAction::LEFT);
|
player->setInput(InputAction::LEFT);
|
||||||
#ifdef RECORDING
|
#ifdef RECORDING
|
||||||
demo_.keys.left = 1;
|
demo_.keys.left = 1;
|
||||||
#endif
|
#endif
|
||||||
} else if (input_->checkInput(InputAction::RIGHT, INPUT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index)) {
|
} else if (input_->checkInput(InputAction::RIGHT, INPUT_ALLOW_REPEAT, controller.type, controller.index)) {
|
||||||
player->setInput(InputAction::RIGHT);
|
player->setInput(InputAction::RIGHT);
|
||||||
#ifdef RECORDING
|
#ifdef RECORDING
|
||||||
demo_.keys.right = 1;
|
demo_.keys.right = 1;
|
||||||
@@ -1315,18 +1315,18 @@ void Game::handleNormalPlayerInput(const std::shared_ptr<Player> &player) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Procesa las entradas de disparo del jugador, permitiendo disparos automáticos si está habilitado.
|
// Procesa las entradas de disparo del jugador, permitiendo disparos automáticos si está habilitado.
|
||||||
void Game::handleFireInputs(const std::shared_ptr<Player> &player, bool autofire, int controllerIndex) {
|
void Game::handleFireInputs(const std::shared_ptr<Player> &player, bool autofire, int controller_index) {
|
||||||
if (input_->checkInput(InputAction::FIRE_CENTER, autofire, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index)) {
|
if (input_->checkInput(InputAction::FIRE_CENTER, autofire, Options::controllers[controller_index].type, Options::controllers[controller_index].index)) {
|
||||||
handleFireInput(player, BulletType::UP);
|
handleFireInput(player, BulletType::UP);
|
||||||
#ifdef RECORDING
|
#ifdef RECORDING
|
||||||
demo_.keys.fire = 1;
|
demo_.keys.fire = 1;
|
||||||
#endif
|
#endif
|
||||||
} else if (input_->checkInput(InputAction::FIRE_LEFT, autofire, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index)) {
|
} else if (input_->checkInput(InputAction::FIRE_LEFT, autofire, Options::controllers[controller_index].type, Options::controllers[controller_index].index)) {
|
||||||
handleFireInput(player, BulletType::LEFT);
|
handleFireInput(player, BulletType::LEFT);
|
||||||
#ifdef RECORDING
|
#ifdef RECORDING
|
||||||
demo_.keys.fire_left = 1;
|
demo_.keys.fire_left = 1;
|
||||||
#endif
|
#endif
|
||||||
} else if (input_->checkInput(InputAction::FIRE_RIGHT, autofire, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index)) {
|
} else if (input_->checkInput(InputAction::FIRE_RIGHT, autofire, Options::controllers[controller_index].type, Options::controllers[controller_index].index)) {
|
||||||
handleFireInput(player, BulletType::RIGHT);
|
handleFireInput(player, BulletType::RIGHT);
|
||||||
#ifdef RECORDING
|
#ifdef RECORDING
|
||||||
demo_.keys.fire_right = 1;
|
demo_.keys.fire_right = 1;
|
||||||
@@ -1336,15 +1336,15 @@ void Game::handleFireInputs(const std::shared_ptr<Player> &player, bool autofire
|
|||||||
|
|
||||||
// Maneja la continuación del jugador cuando no está jugando, permitiendo que continúe si se pulsa el botón de inicio.
|
// Maneja la continuación del jugador cuando no está jugando, permitiendo que continúe si se pulsa el botón de inicio.
|
||||||
void Game::handlePlayerContinue(const std::shared_ptr<Player> &player) {
|
void Game::handlePlayerContinue(const std::shared_ptr<Player> &player) {
|
||||||
const auto controllerIndex = player->getController();
|
const auto CONTROLLER_INDEX = player->getController();
|
||||||
if (input_->checkInput(InputAction::START, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index)) {
|
if (input_->checkInput(InputAction::START, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[CONTROLLER_INDEX].type, Options::controllers[CONTROLLER_INDEX].index)) {
|
||||||
player->setPlayingState(PlayerState::RESPAWNING);
|
player->setPlayingState(PlayerState::RESPAWNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disminuye el contador de continuación si se presiona cualquier botón de disparo.
|
// Disminuye el contador de continuación si se presiona cualquier botón de disparo.
|
||||||
if (input_->checkInput(InputAction::FIRE_LEFT, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index) ||
|
if (input_->checkInput(InputAction::FIRE_LEFT, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[CONTROLLER_INDEX].type, Options::controllers[CONTROLLER_INDEX].index) ||
|
||||||
input_->checkInput(InputAction::FIRE_CENTER, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index) ||
|
input_->checkInput(InputAction::FIRE_CENTER, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[CONTROLLER_INDEX].type, Options::controllers[CONTROLLER_INDEX].index) ||
|
||||||
input_->checkInput(InputAction::FIRE_RIGHT, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index)) {
|
input_->checkInput(InputAction::FIRE_RIGHT, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[CONTROLLER_INDEX].type, Options::controllers[CONTROLLER_INDEX].index)) {
|
||||||
if (player->getContinueCounter() < param.scoreboard.skip_countdown_value) {
|
if (player->getContinueCounter() < param.scoreboard.skip_countdown_value) {
|
||||||
player->decContinueCounter();
|
player->decContinueCounter();
|
||||||
}
|
}
|
||||||
@@ -1353,8 +1353,8 @@ void Game::handlePlayerContinue(const std::shared_ptr<Player> &player) {
|
|||||||
|
|
||||||
// Procesa las entradas para la introducción del nombre del jugador.
|
// Procesa las entradas para la introducción del nombre del jugador.
|
||||||
void Game::handleNameInput(const std::shared_ptr<Player> &player) {
|
void Game::handleNameInput(const std::shared_ptr<Player> &player) {
|
||||||
const auto controllerIndex = player->getController();
|
const auto CONTROLLER_INDEX = player->getController();
|
||||||
if (input_->checkInput(InputAction::FIRE_LEFT, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index)) {
|
if (input_->checkInput(InputAction::FIRE_LEFT, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[CONTROLLER_INDEX].type, Options::controllers[CONTROLLER_INDEX].index)) {
|
||||||
if (player->isShowingName()) {
|
if (player->isShowingName()) {
|
||||||
player->setPlayingState(PlayerState::CONTINUE);
|
player->setPlayingState(PlayerState::CONTINUE);
|
||||||
} else if (player->getEnterNamePositionOverflow()) {
|
} else if (player->getEnterNamePositionOverflow()) {
|
||||||
@@ -1364,18 +1364,18 @@ void Game::handleNameInput(const std::shared_ptr<Player> &player) {
|
|||||||
} else {
|
} else {
|
||||||
player->setInput(InputAction::RIGHT);
|
player->setInput(InputAction::RIGHT);
|
||||||
}
|
}
|
||||||
} else if (input_->checkInput(InputAction::FIRE_CENTER, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index) ||
|
} else if (input_->checkInput(InputAction::FIRE_CENTER, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[CONTROLLER_INDEX].type, Options::controllers[CONTROLLER_INDEX].index) ||
|
||||||
input_->checkInput(InputAction::FIRE_RIGHT, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index)) {
|
input_->checkInput(InputAction::FIRE_RIGHT, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[CONTROLLER_INDEX].type, Options::controllers[CONTROLLER_INDEX].index)) {
|
||||||
if (player->isShowingName()) {
|
if (player->isShowingName()) {
|
||||||
player->setPlayingState(PlayerState::CONTINUE);
|
player->setPlayingState(PlayerState::CONTINUE);
|
||||||
} else {
|
} else {
|
||||||
player->setInput(InputAction::LEFT);
|
player->setInput(InputAction::LEFT);
|
||||||
}
|
}
|
||||||
} else if (input_->checkInput(InputAction::UP, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index)) {
|
} else if (input_->checkInput(InputAction::UP, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[CONTROLLER_INDEX].type, Options::controllers[CONTROLLER_INDEX].index)) {
|
||||||
player->setInput(InputAction::UP);
|
player->setInput(InputAction::UP);
|
||||||
} else if (input_->checkInput(InputAction::DOWN, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index)) {
|
} else if (input_->checkInput(InputAction::DOWN, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[CONTROLLER_INDEX].type, Options::controllers[CONTROLLER_INDEX].index)) {
|
||||||
player->setInput(InputAction::DOWN);
|
player->setInput(InputAction::DOWN);
|
||||||
} else if (input_->checkInput(InputAction::START, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index)) {
|
} else if (input_->checkInput(InputAction::START, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[CONTROLLER_INDEX].type, Options::controllers[CONTROLLER_INDEX].index)) {
|
||||||
if (player->isShowingName()) {
|
if (player->isShowingName()) {
|
||||||
player->setPlayingState(PlayerState::CONTINUE);
|
player->setPlayingState(PlayerState::CONTINUE);
|
||||||
} else {
|
} else {
|
||||||
@@ -1666,12 +1666,12 @@ void Game::cleanVectors() {
|
|||||||
// Gestiona el nivel de amenaza
|
// Gestiona el nivel de amenaza
|
||||||
void Game::updateMenace() {
|
void Game::updateMenace() {
|
||||||
if (state_ == GameState::PLAYING) {
|
if (state_ == GameState::PLAYING) {
|
||||||
const auto stage = Stage::get(Stage::number);
|
const auto STAGE = Stage::get(Stage::number);
|
||||||
const float percent = Stage::power / stage.power_to_complete;
|
const float PERCENT = Stage::power / STAGE.power_to_complete;
|
||||||
const int difference = stage.max_menace - stage.min_menace;
|
const int DIFFERENCE = STAGE.max_menace - STAGE.min_menace;
|
||||||
|
|
||||||
// Aumenta el nivel de amenaza en función de la puntuación
|
// Aumenta el nivel de amenaza en función de la puntuación
|
||||||
menace_threshold_ = stage.min_menace + (difference * percent);
|
menace_threshold_ = STAGE.min_menace + (DIFFERENCE * PERCENT);
|
||||||
|
|
||||||
// Si el nivel de amenza es inferior al umbral
|
// Si el nivel de amenza es inferior al umbral
|
||||||
if (menace_current_ < menace_threshold_) {
|
if (menace_current_ < menace_threshold_) {
|
||||||
@@ -1694,11 +1694,11 @@ void Game::checkAndUpdateBalloonSpeed() {
|
|||||||
if (difficulty_ != Options::DifficultyCode::NORMAL)
|
if (difficulty_ != Options::DifficultyCode::NORMAL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const float percent = static_cast<float>(Stage::power) / Stage::get(Stage::number).power_to_complete;
|
const float PERCENT = static_cast<float>(Stage::power) / Stage::get(Stage::number).power_to_complete;
|
||||||
const float thresholds[] = {0.2f, 0.4f, 0.6f, 0.8f};
|
const float THRESHOLDS[] = {0.2f, 0.4f, 0.6f, 0.8f};
|
||||||
|
|
||||||
for (size_t i = 0; i < std::size(thresholds); ++i) {
|
for (size_t i = 0; i < std::size(THRESHOLDS); ++i) {
|
||||||
if (balloon_manager_->getBalloonSpeed() == BALLOON_SPEED[i] && percent > thresholds[i]) {
|
if (balloon_manager_->getBalloonSpeed() == BALLOON_SPEED[i] && PERCENT > THRESHOLDS[i]) {
|
||||||
balloon_manager_->setBalloonSpeed(BALLOON_SPEED[i + 1]);
|
balloon_manager_->setBalloonSpeed(BALLOON_SPEED[i + 1]);
|
||||||
break; // Salir del bucle una vez actualizada la velocidad y aplicada
|
break; // Salir del bucle una vez actualizada la velocidad y aplicada
|
||||||
}
|
}
|
||||||
@@ -1715,8 +1715,8 @@ void Game::playSound(const std::string &name) {
|
|||||||
if (demo_.enabled)
|
if (demo_.enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
static auto audio = Audio::get();
|
static auto audio_ = Audio::get();
|
||||||
audio->playSound(name);
|
audio_->playSound(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Organiza los jugadores para que los vivos se pinten sobre los muertos
|
// Organiza los jugadores para que los vivos se pinten sobre los muertos
|
||||||
@@ -1727,9 +1727,9 @@ void Game::movePlayersToFront() {
|
|||||||
for (auto &player : players_to_reorder) {
|
for (auto &player : players_to_reorder) {
|
||||||
auto it = std::find(players_.begin(), players_.end(), player);
|
auto it = std::find(players_.begin(), players_.end(), player);
|
||||||
if (it != players_.end() && it != players_.begin()) {
|
if (it != players_.end() && it != players_.begin()) {
|
||||||
std::shared_ptr<Player> dyingPlayer = *it;
|
std::shared_ptr<Player> dying_player = *it;
|
||||||
players_.erase(it);
|
players_.erase(it);
|
||||||
players_.insert(players_.begin(), dyingPlayer);
|
players_.insert(players_.begin(), dying_player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
players_to_reorder.clear();
|
players_to_reorder.clear();
|
||||||
@@ -1740,21 +1740,21 @@ void Game::checkServiceMenu() {
|
|||||||
if (demo_.enabled)
|
if (demo_.enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
static bool was_paused_before_service_menu = false;
|
static bool was_paused_before_service_menu_ = false;
|
||||||
static bool service_menu_was_active = false;
|
static bool service_menu_was_active_ = false;
|
||||||
|
|
||||||
bool service_menu_is_active = ServiceMenu::get()->isEnabled();
|
bool service_menu_is_active = ServiceMenu::get()->isEnabled();
|
||||||
|
|
||||||
if (service_menu_is_active && !service_menu_was_active) {
|
if (service_menu_is_active && !service_menu_was_active_) {
|
||||||
// El menú acaba de abrirse
|
// El menú acaba de abrirse
|
||||||
was_paused_before_service_menu = paused_;
|
was_paused_before_service_menu_ = paused_;
|
||||||
pause(true);
|
pause(true);
|
||||||
} else if (!service_menu_is_active && service_menu_was_active) {
|
} else if (!service_menu_is_active && service_menu_was_active_) {
|
||||||
// El menú acaba de cerrarse
|
// El menú acaba de cerrarse
|
||||||
pause(was_paused_before_service_menu);
|
pause(was_paused_before_service_menu_);
|
||||||
}
|
}
|
||||||
|
|
||||||
service_menu_was_active = service_menu_is_active;
|
service_menu_was_active_ = service_menu_is_active;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@@ -1770,9 +1770,9 @@ void Game::checkDebugEvents(const SDL_Event &event) {
|
|||||||
}
|
}
|
||||||
case SDLK_2: // Activa o desactiva la aparición de globos
|
case SDLK_2: // Activa o desactiva la aparición de globos
|
||||||
{
|
{
|
||||||
static bool deploy_balloons = true;
|
static bool deploy_balloons_ = true;
|
||||||
deploy_balloons = !deploy_balloons;
|
deploy_balloons_ = !deploy_balloons_;
|
||||||
balloon_manager_->enableBalloonDeployment(deploy_balloons);
|
balloon_manager_->enableBalloonDeployment(deploy_balloons_);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDLK_3: // Activa el modo para pasar el juego automaticamente
|
case SDLK_3: // Activa el modo para pasar el juego automaticamente
|
||||||
|
|||||||
@@ -169,19 +169,19 @@ void HiScoreTable::updateFade() {
|
|||||||
|
|
||||||
// Convierte un entero a un string con separadores de miles
|
// Convierte un entero a un string con separadores de miles
|
||||||
std::string HiScoreTable::format(int number) {
|
std::string HiScoreTable::format(int number) {
|
||||||
const std::string separator = ".";
|
const std::string SEPARATOR = ".";
|
||||||
const std::string score = std::to_string(number);
|
const std::string SCORE = std::to_string(number);
|
||||||
|
|
||||||
auto index = (int)score.size() - 1;
|
auto index = (int)SCORE.size() - 1;
|
||||||
std::string result;
|
std::string result;
|
||||||
auto i = 0;
|
auto i = 0;
|
||||||
while (index >= 0) {
|
while (index >= 0) {
|
||||||
result = score.at(index) + result;
|
result = SCORE.at(index) + result;
|
||||||
index--;
|
index--;
|
||||||
i++;
|
i++;
|
||||||
if (i == 3) {
|
if (i == 3) {
|
||||||
i = 0;
|
i = 0;
|
||||||
result = separator + result;
|
result = SEPARATOR + result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,44 +200,44 @@ void HiScoreTable::createSprites() {
|
|||||||
|
|
||||||
constexpr int ENTRY_LENGHT = 22;
|
constexpr int ENTRY_LENGHT = 22;
|
||||||
constexpr int MAX_NAMES = 10;
|
constexpr int MAX_NAMES = 10;
|
||||||
const int space_between_header = entry_text->getCharacterSize() * 4;
|
const int SPACE_BETWEEN_HEADER = entry_text->getCharacterSize() * 4;
|
||||||
const int space_between_lines = entry_text->getCharacterSize() * 2;
|
const int SPACE_BETWEEN_LINES = entry_text->getCharacterSize() * 2;
|
||||||
const int size = space_between_header + space_between_lines * (MAX_NAMES - 1) + entry_text->getCharacterSize();
|
const int SIZE = SPACE_BETWEEN_HEADER + SPACE_BETWEEN_LINES * (MAX_NAMES - 1) + entry_text->getCharacterSize();
|
||||||
const int first_line = (param.game.height - size) / 2;
|
const int FIRST_LINE = (param.game.height - SIZE) / 2;
|
||||||
|
|
||||||
// Crea el sprite para el texto de cabecera
|
// Crea el sprite para el texto de cabecera
|
||||||
header_ = std::make_unique<Sprite>(header_text->writeDXToTexture(TEXT_COLOR, Lang::getText("[HIGHSCORE_TABLE] CAPTION"), -2, background_fade_color_.INVERSE().LIGHTEN(25)));
|
header_ = std::make_unique<Sprite>(header_text->writeDXToTexture(TEXT_COLOR, Lang::getText("[HIGHSCORE_TABLE] CAPTION"), -2, background_fade_color_.INVERSE().LIGHTEN(25)));
|
||||||
header_->setPosition(param.game.game_area.center_x - (header_->getWidth() / 2), first_line);
|
header_->setPosition(param.game.game_area.center_x - (header_->getWidth() / 2), FIRST_LINE);
|
||||||
|
|
||||||
// Crea los sprites para las entradas en la tabla de puntuaciones
|
// Crea los sprites para las entradas en la tabla de puntuaciones
|
||||||
const int animation = rand() % 4;
|
const int ANIMATION = rand() % 4;
|
||||||
const std::string sample_line(ENTRY_LENGHT + 3, ' ');
|
const std::string SAMPLE_LINE(ENTRY_LENGHT + 3, ' ');
|
||||||
auto sample_entry = std::make_unique<Sprite>(entry_text->writeDXToTexture(TEXT_SHADOW, sample_line, 1, NO_TEXT_COLOR, 1, SHADOW_TEXT_COLOR));
|
auto sample_entry = std::make_unique<Sprite>(entry_text->writeDXToTexture(TEXT_SHADOW, SAMPLE_LINE, 1, NO_TEXT_COLOR, 1, SHADOW_TEXT_COLOR));
|
||||||
const auto entry_width = sample_entry->getWidth();
|
const auto ENTRY_WIDTH = sample_entry->getWidth();
|
||||||
for (int i = 0; i < MAX_NAMES; ++i) {
|
for (int i = 0; i < MAX_NAMES; ++i) {
|
||||||
const auto table_position = format(i + 1) + ". ";
|
const auto TABLE_POSITION = format(i + 1) + ". ";
|
||||||
const auto score = format(Options::settings.hi_score_table.at(i).score);
|
const auto SCORE = format(Options::settings.hi_score_table.at(i).score);
|
||||||
const auto num_dots = ENTRY_LENGHT - Options::settings.hi_score_table.at(i).name.size() - score.size();
|
const auto NUM_DOTS = ENTRY_LENGHT - Options::settings.hi_score_table.at(i).name.size() - SCORE.size();
|
||||||
const auto one_cc = Options::settings.hi_score_table.at(i).one_credit_complete ? " }" : "";
|
const auto ONE_CC = Options::settings.hi_score_table.at(i).one_credit_complete ? " }" : "";
|
||||||
std::string dots;
|
std::string dots;
|
||||||
for (int j = 0; j < (int)num_dots; ++j) {
|
for (int j = 0; j < (int)NUM_DOTS; ++j) {
|
||||||
dots = dots + ".";
|
dots = dots + ".";
|
||||||
}
|
}
|
||||||
const auto line = table_position + Options::settings.hi_score_table.at(i).name + dots + score + one_cc;
|
const auto LINE = TABLE_POSITION + Options::settings.hi_score_table.at(i).name + dots + SCORE + ONE_CC;
|
||||||
|
|
||||||
entry_names_.emplace_back(std::make_shared<PathSprite>(entry_text->writeDXToTexture(TEXT_SHADOW, line, 1, NO_TEXT_COLOR, 1, SHADOW_TEXT_COLOR)));
|
entry_names_.emplace_back(std::make_shared<PathSprite>(entry_text->writeDXToTexture(TEXT_SHADOW, LINE, 1, NO_TEXT_COLOR, 1, SHADOW_TEXT_COLOR)));
|
||||||
const int default_pos_x = (backbuffer_width - entry_width) / 2;
|
const int DEFAULT_POS_X = (backbuffer_width - ENTRY_WIDTH) / 2;
|
||||||
const int pos_x = (i < 9) ? default_pos_x : default_pos_x - entry_text->getCharacterSize();
|
const int POS_X = (i < 9) ? DEFAULT_POS_X : DEFAULT_POS_X - entry_text->getCharacterSize();
|
||||||
const int pos_y = (i * space_between_lines) + first_line + space_between_header;
|
const int POS_Y = (i * SPACE_BETWEEN_LINES) + FIRST_LINE + SPACE_BETWEEN_HEADER;
|
||||||
constexpr int steps = 80;
|
constexpr int STEPS = 80;
|
||||||
switch (animation) {
|
switch (ANIMATION) {
|
||||||
case 0: // Ambos lados alternativamente
|
case 0: // Ambos lados alternativamente
|
||||||
{
|
{
|
||||||
if (i % 2 == 0) {
|
if (i % 2 == 0) {
|
||||||
entry_names_.back()->addPath(-entry_names_.back()->getWidth(), pos_x, PathType::HORIZONTAL, pos_y, steps, easeOutQuint);
|
entry_names_.back()->addPath(-entry_names_.back()->getWidth(), POS_X, PathType::HORIZONTAL, POS_Y, STEPS, easeOutQuint);
|
||||||
entry_names_.back()->setPosition(-entry_names_.back()->getWidth(), 0);
|
entry_names_.back()->setPosition(-entry_names_.back()->getWidth(), 0);
|
||||||
} else {
|
} else {
|
||||||
entry_names_.back()->addPath(backbuffer_width, pos_x, PathType::HORIZONTAL, pos_y, steps, easeOutQuint);
|
entry_names_.back()->addPath(backbuffer_width, POS_X, PathType::HORIZONTAL, POS_Y, STEPS, easeOutQuint);
|
||||||
entry_names_.back()->setPosition(backbuffer_width, 0);
|
entry_names_.back()->setPosition(backbuffer_width, 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -245,21 +245,21 @@ void HiScoreTable::createSprites() {
|
|||||||
|
|
||||||
case 1: // Entran por la izquierda
|
case 1: // Entran por la izquierda
|
||||||
{
|
{
|
||||||
entry_names_.back()->addPath(-entry_names_.back()->getWidth(), pos_x, PathType::HORIZONTAL, pos_y, steps, easeOutQuint);
|
entry_names_.back()->addPath(-entry_names_.back()->getWidth(), POS_X, PathType::HORIZONTAL, POS_Y, STEPS, easeOutQuint);
|
||||||
entry_names_.back()->setPosition(-entry_names_.back()->getWidth(), 0);
|
entry_names_.back()->setPosition(-entry_names_.back()->getWidth(), 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 2: // Entran por la derecha
|
case 2: // Entran por la derecha
|
||||||
{
|
{
|
||||||
entry_names_.back()->addPath(backbuffer_width, pos_x, PathType::HORIZONTAL, pos_y, steps, easeOutQuint);
|
entry_names_.back()->addPath(backbuffer_width, POS_X, PathType::HORIZONTAL, POS_Y, STEPS, easeOutQuint);
|
||||||
entry_names_.back()->setPosition(backbuffer_width, 0);
|
entry_names_.back()->setPosition(backbuffer_width, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 3: // Entran desde la parte inferior
|
case 3: // Entran desde la parte inferior
|
||||||
{
|
{
|
||||||
entry_names_.back()->addPath(backbuffer_height, pos_y, PathType::VERTICAL, pos_x, steps, easeOutQuint);
|
entry_names_.back()->addPath(backbuffer_height, POS_Y, PathType::VERTICAL, POS_X, STEPS, easeOutQuint);
|
||||||
entry_names_.back()->setPosition(0, backbuffer_height);
|
entry_names_.back()->setPosition(0, backbuffer_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,12 +271,12 @@ void HiScoreTable::createSprites() {
|
|||||||
|
|
||||||
// Actualiza las posiciones de los sprites de texto
|
// Actualiza las posiciones de los sprites de texto
|
||||||
void HiScoreTable::updateSprites() {
|
void HiScoreTable::updateSprites() {
|
||||||
constexpr int init_counter = 190;
|
constexpr int INIT_COUNTER = 190;
|
||||||
const int counter_between_entries = 16;
|
const int COUNTER_BETWEEN_ENTRIES = 16;
|
||||||
if (counter_ >= init_counter) {
|
if (counter_ >= INIT_COUNTER) {
|
||||||
const int counter2 = counter_ - init_counter;
|
const int COUNTER2 = counter_ - INIT_COUNTER;
|
||||||
if (counter2 % counter_between_entries == 0) {
|
if (COUNTER2 % COUNTER_BETWEEN_ENTRIES == 0) {
|
||||||
int index = counter2 / counter_between_entries;
|
int index = COUNTER2 / COUNTER_BETWEEN_ENTRIES;
|
||||||
if (index < static_cast<int>(entry_names_.size())) {
|
if (index < static_cast<int>(entry_names_.size())) {
|
||||||
entry_names_.at(index)->enable();
|
entry_names_.at(index)->enable();
|
||||||
}
|
}
|
||||||
@@ -303,8 +303,8 @@ void HiScoreTable::initBackground() {
|
|||||||
background_->setPos(param.game.game_area.rect);
|
background_->setPos(param.game.game_area.rect);
|
||||||
background_->setCloudsSpeed(-0.1f);
|
background_->setCloudsSpeed(-0.1f);
|
||||||
|
|
||||||
const int lucky = rand() % 3;
|
const int LUCKY = rand() % 3;
|
||||||
switch (lucky) {
|
switch (LUCKY) {
|
||||||
case 0: // Fondo verde
|
case 0: // Fondo verde
|
||||||
{
|
{
|
||||||
background_->setGradientNumber(2);
|
background_->setGradientNumber(2);
|
||||||
@@ -341,9 +341,9 @@ void HiScoreTable::initBackground() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene un color del vector de colores de entradas
|
// Obtiene un color del vector de colores de entradas
|
||||||
Color HiScoreTable::getEntryColor(int counter_) {
|
Color HiScoreTable::getEntryColor(int counter) {
|
||||||
int cycle_length = entry_colors_.size() * 2 - 2;
|
int cycle_length = entry_colors_.size() * 2 - 2;
|
||||||
size_t n = counter_ % cycle_length;
|
size_t n = counter % cycle_length;
|
||||||
|
|
||||||
size_t index;
|
size_t index;
|
||||||
if (n < entry_colors_.size()) {
|
if (n < entry_colors_.size()) {
|
||||||
@@ -366,10 +366,10 @@ void HiScoreTable::iniEntryColors() {
|
|||||||
|
|
||||||
// Hace brillar los nombres de la tabla de records
|
// Hace brillar los nombres de la tabla de records
|
||||||
void HiScoreTable::glowEntryNames() {
|
void HiScoreTable::glowEntryNames() {
|
||||||
const Color entry_color = getEntryColor(counter_ / 5);
|
const Color ENTRY_COLOR = getEntryColor(counter_ / 5);
|
||||||
for (const auto &entry_index : Options::settings.last_hi_score_entry) {
|
for (const auto &entry_index : Options::settings.last_hi_score_entry) {
|
||||||
if (entry_index != -1) {
|
if (entry_index != -1) {
|
||||||
entry_names_.at(entry_index)->getTexture()->setColor(entry_color);
|
entry_names_.at(entry_index)->getTexture()->setColor(ENTRY_COLOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ void Instructions::updateSprites() {
|
|||||||
|
|
||||||
// Rellena la textura de texto
|
// Rellena la textura de texto
|
||||||
void Instructions::fillTexture() {
|
void Instructions::fillTexture() {
|
||||||
const int desp_x = param.game.item_size + 8;
|
const int DESP_X = param.game.item_size + 8;
|
||||||
|
|
||||||
// Modifica el renderizador para pintar en la textura
|
// Modifica el renderizador para pintar en la textura
|
||||||
auto temp = SDL_GetRenderTarget(renderer_);
|
auto temp = SDL_GetRenderTarget(renderer_);
|
||||||
@@ -121,19 +121,19 @@ void Instructions::fillTexture() {
|
|||||||
SDL_RenderClear(renderer_);
|
SDL_RenderClear(renderer_);
|
||||||
|
|
||||||
// Constantes
|
// Constantes
|
||||||
constexpr int num_lines = 4;
|
constexpr int NUM_LINES = 4;
|
||||||
constexpr int num_item_lines = 4;
|
constexpr int NUM_ITEM_LINES = 4;
|
||||||
constexpr int num_post_headers = 2;
|
constexpr int NUM_POST_HEADERS = 2;
|
||||||
constexpr int num_pre_headers = 1;
|
constexpr int NUM_PRE_HEADERS = 1;
|
||||||
|
|
||||||
constexpr int space_post_header = 20;
|
constexpr int SPACE_POST_HEADER = 20;
|
||||||
constexpr int space_pre_header = 28;
|
constexpr int SPACE_PRE_HEADER = 28;
|
||||||
const int space_between_lines = text_->getCharacterSize() * 1.5f;
|
const int SPACE_BETWEEN_LINES = text_->getCharacterSize() * 1.5f;
|
||||||
const int space_between_item_lines = param.game.item_size + item_space_;
|
const int SPACE_BETWEEN_ITEM_LINES = param.game.item_size + item_space_;
|
||||||
const int space_new_paragraph = space_between_lines * 0.5f;
|
const int SPACE_NEW_PARAGRAPH = SPACE_BETWEEN_LINES * 0.5f;
|
||||||
|
|
||||||
const int size = (num_lines * space_between_lines) + (num_item_lines * space_between_item_lines) + (num_post_headers * space_post_header) + (num_pre_headers * space_pre_header) + (space_new_paragraph);
|
const int SIZE = (NUM_LINES * SPACE_BETWEEN_LINES) + (NUM_ITEM_LINES * SPACE_BETWEEN_ITEM_LINES) + (NUM_POST_HEADERS * SPACE_POST_HEADER) + (NUM_PRE_HEADERS * SPACE_PRE_HEADER) + (SPACE_NEW_PARAGRAPH);
|
||||||
const int first_line = (param.game.height - size) / 2;
|
const int FIRST_LINE = (param.game.height - SIZE) / 2;
|
||||||
|
|
||||||
// Calcula cual es el texto más largo de las descripciones de los items
|
// Calcula cual es el texto más largo de las descripciones de los items
|
||||||
int lenght = 0;
|
int lenght = 0;
|
||||||
@@ -144,39 +144,39 @@ void Instructions::fillTexture() {
|
|||||||
Lang::getText("[INSTRUCTIONS] 10"),
|
Lang::getText("[INSTRUCTIONS] 10"),
|
||||||
Lang::getText("[INSTRUCTIONS] 11")};
|
Lang::getText("[INSTRUCTIONS] 11")};
|
||||||
for (const auto &desc : ITEM_DESCRIPTIONS) {
|
for (const auto &desc : ITEM_DESCRIPTIONS) {
|
||||||
const int l = text_->lenght(desc);
|
const int L = text_->lenght(desc);
|
||||||
lenght = l > lenght ? l : lenght;
|
lenght = L > lenght ? L : lenght;
|
||||||
}
|
}
|
||||||
const int ANCHOR_ITEM = (param.game.width - (lenght + desp_x)) / 2;
|
const int ANCHOR_ITEM = (param.game.width - (lenght + DESP_X)) / 2;
|
||||||
|
|
||||||
constexpr Color ORANGE_COLOR = Color(0XFF, 0X7A, 0X00);
|
constexpr Color ORANGE_COLOR = Color(0XFF, 0X7A, 0X00);
|
||||||
|
|
||||||
// Escribe el texto de las instrucciones
|
// Escribe el texto de las instrucciones
|
||||||
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, first_line, Lang::getText("[INSTRUCTIONS] 01"), 1, ORANGE_COLOR, 1, SHADOW_TEXT_COLOR);
|
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, FIRST_LINE, Lang::getText("[INSTRUCTIONS] 01"), 1, ORANGE_COLOR, 1, SHADOW_TEXT_COLOR);
|
||||||
|
|
||||||
const int anchor1 = first_line + space_post_header;
|
const int ANCHOR1 = FIRST_LINE + SPACE_POST_HEADER;
|
||||||
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor1 + space_between_lines * 0, Lang::getText("[INSTRUCTIONS] 02"), 1, NO_TEXT_COLOR, 1, SHADOW_TEXT_COLOR);
|
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, ANCHOR1 + SPACE_BETWEEN_LINES * 0, Lang::getText("[INSTRUCTIONS] 02"), 1, NO_TEXT_COLOR, 1, SHADOW_TEXT_COLOR);
|
||||||
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor1 + space_between_lines * 1, Lang::getText("[INSTRUCTIONS] 03"), 1, NO_TEXT_COLOR, 1, SHADOW_TEXT_COLOR);
|
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, ANCHOR1 + SPACE_BETWEEN_LINES * 1, Lang::getText("[INSTRUCTIONS] 03"), 1, NO_TEXT_COLOR, 1, SHADOW_TEXT_COLOR);
|
||||||
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor1 + space_new_paragraph + space_between_lines * 2, Lang::getText("[INSTRUCTIONS] 04"), 1, NO_TEXT_COLOR, 1, SHADOW_TEXT_COLOR);
|
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, ANCHOR1 + SPACE_NEW_PARAGRAPH + SPACE_BETWEEN_LINES * 2, Lang::getText("[INSTRUCTIONS] 04"), 1, NO_TEXT_COLOR, 1, SHADOW_TEXT_COLOR);
|
||||||
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor1 + space_new_paragraph + space_between_lines * 3, Lang::getText("[INSTRUCTIONS] 05"), 1, NO_TEXT_COLOR, 1, SHADOW_TEXT_COLOR);
|
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, ANCHOR1 + SPACE_NEW_PARAGRAPH + SPACE_BETWEEN_LINES * 3, Lang::getText("[INSTRUCTIONS] 05"), 1, NO_TEXT_COLOR, 1, SHADOW_TEXT_COLOR);
|
||||||
|
|
||||||
// Escribe el texto de los objetos y sus puntos
|
// Escribe el texto de los objetos y sus puntos
|
||||||
const int anchor2 = anchor1 + space_pre_header + space_new_paragraph + space_between_lines * 3;
|
const int ANCHOR2 = ANCHOR1 + SPACE_PRE_HEADER + SPACE_NEW_PARAGRAPH + SPACE_BETWEEN_LINES * 3;
|
||||||
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor2, Lang::getText("[INSTRUCTIONS] 06"), 1, ORANGE_COLOR, 1, SHADOW_TEXT_COLOR);
|
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, ANCHOR2, Lang::getText("[INSTRUCTIONS] 06"), 1, ORANGE_COLOR, 1, SHADOW_TEXT_COLOR);
|
||||||
|
|
||||||
const int anchor3 = anchor2 + space_post_header;
|
const int ANCHOR3 = ANCHOR2 + SPACE_POST_HEADER;
|
||||||
text_->writeShadowed(ANCHOR_ITEM + desp_x, anchor3 + space_between_item_lines * 0, Lang::getText("[INSTRUCTIONS] 07"), SHADOW_TEXT_COLOR);
|
text_->writeShadowed(ANCHOR_ITEM + DESP_X, ANCHOR3 + SPACE_BETWEEN_ITEM_LINES * 0, Lang::getText("[INSTRUCTIONS] 07"), SHADOW_TEXT_COLOR);
|
||||||
text_->writeShadowed(ANCHOR_ITEM + desp_x, anchor3 + space_between_item_lines * 1, Lang::getText("[INSTRUCTIONS] 08"), SHADOW_TEXT_COLOR);
|
text_->writeShadowed(ANCHOR_ITEM + DESP_X, ANCHOR3 + SPACE_BETWEEN_ITEM_LINES * 1, Lang::getText("[INSTRUCTIONS] 08"), SHADOW_TEXT_COLOR);
|
||||||
text_->writeShadowed(ANCHOR_ITEM + desp_x, anchor3 + space_between_item_lines * 2, Lang::getText("[INSTRUCTIONS] 09"), SHADOW_TEXT_COLOR);
|
text_->writeShadowed(ANCHOR_ITEM + DESP_X, ANCHOR3 + SPACE_BETWEEN_ITEM_LINES * 2, Lang::getText("[INSTRUCTIONS] 09"), SHADOW_TEXT_COLOR);
|
||||||
text_->writeShadowed(ANCHOR_ITEM + desp_x, anchor3 + space_between_item_lines * 3, Lang::getText("[INSTRUCTIONS] 10"), SHADOW_TEXT_COLOR);
|
text_->writeShadowed(ANCHOR_ITEM + DESP_X, ANCHOR3 + SPACE_BETWEEN_ITEM_LINES * 3, Lang::getText("[INSTRUCTIONS] 10"), SHADOW_TEXT_COLOR);
|
||||||
text_->writeShadowed(ANCHOR_ITEM + desp_x, anchor3 + space_between_item_lines * 4, Lang::getText("[INSTRUCTIONS] 11"), SHADOW_TEXT_COLOR);
|
text_->writeShadowed(ANCHOR_ITEM + DESP_X, ANCHOR3 + SPACE_BETWEEN_ITEM_LINES * 4, Lang::getText("[INSTRUCTIONS] 11"), SHADOW_TEXT_COLOR);
|
||||||
|
|
||||||
// Deja el renderizador como estaba
|
// Deja el renderizador como estaba
|
||||||
SDL_SetRenderTarget(renderer_, temp);
|
SDL_SetRenderTarget(renderer_, temp);
|
||||||
|
|
||||||
// Da valor a la variable
|
// Da valor a la variable
|
||||||
sprite_pos_.x = ANCHOR_ITEM;
|
sprite_pos_.x = ANCHOR_ITEM;
|
||||||
sprite_pos_.y = anchor3 - ((param.game.item_size - text_->getCharacterSize()) / 2);
|
sprite_pos_.y = ANCHOR3 - ((param.game.item_size - text_->getCharacterSize()) / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rellena el backbuffer
|
// Rellena el backbuffer
|
||||||
@@ -289,14 +289,14 @@ std::vector<Line> Instructions::initializeLines(int height) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Método para mover las líneas con suavizado
|
// Método para mover las líneas con suavizado
|
||||||
bool Instructions::moveLines(std::vector<Line> &lines, int width, float duration, Uint32 startDelay) {
|
bool Instructions::moveLines(std::vector<Line> &lines, int width, float duration, Uint32 start_delay) {
|
||||||
Uint32 current_time = SDL_GetTicks();
|
Uint32 current_time = SDL_GetTicks();
|
||||||
bool all_lines_off_screen = true;
|
bool all_lines_off_screen = true;
|
||||||
|
|
||||||
for (auto &line : lines) {
|
for (auto &line : lines) {
|
||||||
// Establecer startTime en el primer cuadro de animación
|
// Establecer startTime en el primer cuadro de animación
|
||||||
if (line.startTime == 0) {
|
if (line.startTime == 0) {
|
||||||
line.startTime = current_time + line.y * startDelay;
|
line.startTime = current_time + line.y * start_delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
float elapsed_time = (current_time - line.startTime) / 1000.0f; // Convertir a segundos
|
float elapsed_time = (current_time - line.startTime) / 1000.0f; // Convertir a segundos
|
||||||
@@ -319,10 +319,10 @@ bool Instructions::moveLines(std::vector<Line> &lines, int width, float duration
|
|||||||
|
|
||||||
// Método para renderizar las líneas
|
// Método para renderizar las líneas
|
||||||
void Instructions::renderLines(SDL_Renderer *renderer, SDL_Texture *texture, const std::vector<Line> &lines) {
|
void Instructions::renderLines(SDL_Renderer *renderer, SDL_Texture *texture, const std::vector<Line> &lines) {
|
||||||
for (const auto &LINE : lines) {
|
for (const auto &line : lines) {
|
||||||
SDL_FRect srcRect = {0, static_cast<float>(LINE.y), 320, 1};
|
SDL_FRect src_rect = {0, static_cast<float>(line.y), 320, 1};
|
||||||
SDL_FRect dstRect = {static_cast<float>(LINE.x), static_cast<float>(LINE.y), 320, 1};
|
SDL_FRect dst_rect = {static_cast<float>(line.x), static_cast<float>(line.y), 320, 1};
|
||||||
SDL_RenderTexture(renderer, texture, &srcRect, &dstRect);
|
SDL_RenderTexture(renderer, texture, &src_rect, &dst_rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,64 +52,64 @@ void Intro::checkEvents() {
|
|||||||
while (SDL_PollEvent(&event)) {
|
while (SDL_PollEvent(&event)) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (event.type == SDL_EVENT_KEY_DOWN && event.key.repeat == 1) {
|
if (event.type == SDL_EVENT_KEY_DOWN && event.key.repeat == 1) {
|
||||||
static Color color = param.intro.bg_color;
|
static Color color_ = param.intro.bg_color;
|
||||||
switch (event.key.key) {
|
switch (event.key.key) {
|
||||||
case SDLK_A:
|
case SDLK_A:
|
||||||
if (color.r < 255)
|
if (color_.r < 255)
|
||||||
++color.r;
|
++color_.r;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_Z:
|
case SDLK_Z:
|
||||||
if (color.r > 0)
|
if (color_.r > 0)
|
||||||
--color.r;
|
--color_.r;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_S:
|
case SDLK_S:
|
||||||
if (color.g < 255)
|
if (color_.g < 255)
|
||||||
++color.g;
|
++color_.g;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_X:
|
case SDLK_X:
|
||||||
if (color.g > 0)
|
if (color_.g > 0)
|
||||||
--color.g;
|
--color_.g;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_D:
|
case SDLK_D:
|
||||||
if (color.b < 255)
|
if (color_.b < 255)
|
||||||
++color.b;
|
++color_.b;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_C:
|
case SDLK_C:
|
||||||
if (color.b > 0)
|
if (color_.b > 0)
|
||||||
--color.b;
|
--color_.b;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_F:
|
case SDLK_F:
|
||||||
if (color.r < 255)
|
if (color_.r < 255)
|
||||||
++color.r;
|
++color_.r;
|
||||||
if (color.g < 255)
|
if (color_.g < 255)
|
||||||
++color.g;
|
++color_.g;
|
||||||
if (color.b < 255)
|
if (color_.b < 255)
|
||||||
++color.b;
|
++color_.b;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_V:
|
case SDLK_V:
|
||||||
if (color.r > 0)
|
if (color_.r > 0)
|
||||||
--color.r;
|
--color_.r;
|
||||||
if (color.g > 0)
|
if (color_.g > 0)
|
||||||
--color.g;
|
--color_.g;
|
||||||
if (color.b > 0)
|
if (color_.b > 0)
|
||||||
--color.b;
|
--color_.b;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
tiled_bg_->setColor(color);
|
tiled_bg_->setColor(color_);
|
||||||
std::cout << "#"
|
std::cout << "#"
|
||||||
<< std::hex << std::setw(2) << std::setfill('0') << (int)color.r
|
<< std::hex << std::setw(2) << std::setfill('0') << (int)color_.r
|
||||||
<< std::setw(2) << std::setfill('0') << (int)color.g
|
<< std::setw(2) << std::setfill('0') << (int)color_.g
|
||||||
<< std::setw(2) << std::setfill('0') << (int)color.b
|
<< std::setw(2) << std::setfill('0') << (int)color_.b
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -572,7 +572,7 @@ void Intro::updatePostState() {
|
|||||||
|
|
||||||
void Intro::renderTextRect() {
|
void Intro::renderTextRect() {
|
||||||
static const float HEIGHT = Resource::get()->getText("04b_25_metal")->getCharacterSize();
|
static const float HEIGHT = Resource::get()->getText("04b_25_metal")->getCharacterSize();
|
||||||
static SDL_FRect rect = {0.0f, param.game.height - param.intro.text_distance_from_bottom - HEIGHT, param.game.width, HEIGHT * 3};
|
static SDL_FRect rect_ = {0.0f, param.game.height - param.intro.text_distance_from_bottom - HEIGHT, param.game.width, HEIGHT * 3};
|
||||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), param.intro.shadow_color.r, param.intro.shadow_color.g, param.intro.shadow_color.b, param.intro.shadow_color.a);
|
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), param.intro.shadow_color.r, param.intro.shadow_color.g, param.intro.shadow_color.b, param.intro.shadow_color.a);
|
||||||
SDL_RenderFillRect(Screen::get()->getRenderer(), &rect);
|
SDL_RenderFillRect(Screen::get()->getRenderer(), &rect_);
|
||||||
}
|
}
|
||||||
@@ -110,18 +110,18 @@ void Logo::updateJAILGAMES() {
|
|||||||
|
|
||||||
// Gestiona el color de las texturas
|
// Gestiona el color de las texturas
|
||||||
void Logo::updateTextureColors() {
|
void Logo::updateTextureColors() {
|
||||||
constexpr int inc = 4;
|
constexpr int INC = 4;
|
||||||
|
|
||||||
// Manejo de 'sinceTexture'
|
// Manejo de 'sinceTexture'
|
||||||
for (int i = 0; i <= 7; ++i) {
|
for (int i = 0; i <= 7; ++i) {
|
||||||
if (counter_ == SHOW_SINCE_SPRITE_COUNTER_MARK + inc * i) {
|
if (counter_ == SHOW_SINCE_SPRITE_COUNTER_MARK + INC * i) {
|
||||||
since_texture_->setColor(color_[i].r, color_[i].g, color_[i].b);
|
since_texture_->setColor(color_[i].r, color_[i].g, color_[i].b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Manejo de 'jailTexture' y 'sinceTexture' en el fade
|
// Manejo de 'jailTexture' y 'sinceTexture' en el fade
|
||||||
for (int i = 0; i <= 6; ++i) {
|
for (int i = 0; i <= 6; ++i) {
|
||||||
if (counter_ == INIT_FADE_COUNTER_MARK + inc * i) {
|
if (counter_ == INIT_FADE_COUNTER_MARK + INC * i) {
|
||||||
jail_texture_->setColor(color_[6 - i].r, color_[6 - i].g, color_[6 - i].b);
|
jail_texture_->setColor(color_[6 - i].r, color_[6 - i].g, color_[6 - i].b);
|
||||||
since_texture_->setColor(color_[6 - i].r, color_[6 - i].g, color_[6 - i].b);
|
since_texture_->setColor(color_[6 - i].r, color_[6 - i].g, color_[6 - i].b);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,65 +109,65 @@ void Title::checkEvents() {
|
|||||||
while (SDL_PollEvent(&event)) {
|
while (SDL_PollEvent(&event)) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (event.type == SDL_EVENT_KEY_DOWN && event.key.repeat == 1) {
|
if (event.type == SDL_EVENT_KEY_DOWN && event.key.repeat == 1) {
|
||||||
static Color color = param.title.bg_color;
|
static Color color_ = param.title.bg_color;
|
||||||
switch (event.key.key) {
|
switch (event.key.key) {
|
||||||
case SDLK_A:
|
case SDLK_A:
|
||||||
if (color.r < 255)
|
if (color_.r < 255)
|
||||||
++color.r;
|
++color_.r;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_Z:
|
case SDLK_Z:
|
||||||
if (color.r > 0)
|
if (color_.r > 0)
|
||||||
--color.r;
|
--color_.r;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_S:
|
case SDLK_S:
|
||||||
if (color.g < 255)
|
if (color_.g < 255)
|
||||||
++color.g;
|
++color_.g;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_X:
|
case SDLK_X:
|
||||||
if (color.g > 0)
|
if (color_.g > 0)
|
||||||
--color.g;
|
--color_.g;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_D:
|
case SDLK_D:
|
||||||
if (color.b < 255)
|
if (color_.b < 255)
|
||||||
++color.b;
|
++color_.b;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_C:
|
case SDLK_C:
|
||||||
if (color.b > 0)
|
if (color_.b > 0)
|
||||||
--color.b;
|
--color_.b;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_F:
|
case SDLK_F:
|
||||||
if (color.r < 255)
|
if (color_.r < 255)
|
||||||
++color.r;
|
++color_.r;
|
||||||
if (color.g < 255)
|
if (color_.g < 255)
|
||||||
++color.g;
|
++color_.g;
|
||||||
if (color.b < 255)
|
if (color_.b < 255)
|
||||||
++color.b;
|
++color_.b;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_V:
|
case SDLK_V:
|
||||||
if (color.r > 0)
|
if (color_.r > 0)
|
||||||
--color.r;
|
--color_.r;
|
||||||
if (color.g > 0)
|
if (color_.g > 0)
|
||||||
--color.g;
|
--color_.g;
|
||||||
if (color.b > 0)
|
if (color_.b > 0)
|
||||||
--color.b;
|
--color_.b;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
counter_ = 0;
|
counter_ = 0;
|
||||||
tiled_bg_->setColor(color);
|
tiled_bg_->setColor(color_);
|
||||||
std::cout << "#"
|
std::cout << "#"
|
||||||
<< std::hex << std::setw(2) << std::setfill('0') << (int)color.r
|
<< std::hex << std::setw(2) << std::setfill('0') << (int)color_.r
|
||||||
<< std::setw(2) << std::setfill('0') << (int)color.g
|
<< std::setw(2) << std::setfill('0') << (int)color_.g
|
||||||
<< std::setw(2) << std::setfill('0') << (int)color.b
|
<< std::setw(2) << std::setfill('0') << (int)color_.b
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -218,11 +218,11 @@ void Title::checkInput() {
|
|||||||
|
|
||||||
if (!ServiceMenu::get()->isEnabled()) {
|
if (!ServiceMenu::get()->isEnabled()) {
|
||||||
// Comprueba todos los métodos de control
|
// Comprueba todos los métodos de control
|
||||||
for (const auto &CONTROLLER : Options::controllers) {
|
for (const auto &controller : Options::controllers) {
|
||||||
// Boton START
|
// Boton START
|
||||||
if (Input::get()->checkInput(InputAction::START, INPUT_DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index)) {
|
if (Input::get()->checkInput(InputAction::START, INPUT_DO_NOT_ALLOW_REPEAT, controller.type, controller.index)) {
|
||||||
if ((state_ != TitleState::LOGO_ANIMATING || ALLOW_TITLE_ANIMATION_SKIP)) {
|
if ((state_ != TitleState::LOGO_ANIMATING || ALLOW_TITLE_ANIMATION_SKIP)) {
|
||||||
if (CONTROLLER.player_id == 1) {
|
if (controller.player_id == 1) {
|
||||||
if (!player1_start_pressed_) {
|
if (!player1_start_pressed_) {
|
||||||
player1_start_pressed_ = true;
|
player1_start_pressed_ = true;
|
||||||
getPlayer(1)->setPlayingState(PlayerState::TITLE_ANIMATION);
|
getPlayer(1)->setPlayingState(PlayerState::TITLE_ANIMATION);
|
||||||
@@ -231,7 +231,7 @@ void Title::checkInput() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CONTROLLER.player_id == 2) {
|
if (controller.player_id == 2) {
|
||||||
if (!player2_start_pressed_) {
|
if (!player2_start_pressed_) {
|
||||||
player2_start_pressed_ = true;
|
player2_start_pressed_ = true;
|
||||||
getPlayer(2)->setPlayingState(PlayerState::TITLE_ANIMATION);
|
getPlayer(2)->setPlayingState(PlayerState::TITLE_ANIMATION);
|
||||||
@@ -292,9 +292,9 @@ void Title::showControllers() {
|
|||||||
|
|
||||||
// Genera el texto correspondiente
|
// Genera el texto correspondiente
|
||||||
for (size_t i = 0; i < NUM_CONTROLLERS; ++i) {
|
for (size_t i = 0; i < NUM_CONTROLLERS; ++i) {
|
||||||
const size_t index = player_controller_index.at(i);
|
const size_t INDEX = player_controller_index.at(i);
|
||||||
if (Options::controllers.at(index).plugged) {
|
if (Options::controllers.at(INDEX).plugged) {
|
||||||
text.at(i) = Lang::getText("[DEFINE_BUTTONS] PLAYER") + std::to_string(i + 1) + ": " + Options::controllers.at(index).name;
|
text.at(i) = Lang::getText("[DEFINE_BUTTONS] PLAYER") + std::to_string(i + 1) + ": " + Options::controllers.at(INDEX).name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ std::shared_ptr<Texture> Text::writeToTexture(const std::string &text, int zoom,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Escribe el texto con extras en una textura
|
// Escribe el texto con extras en una textura
|
||||||
std::shared_ptr<Texture> Text::writeDXToTexture(Uint8 flags, const std::string &text, int kerning, Color textColor, Uint8 shadow_distance, Color shadow_color, int lenght) {
|
std::shared_ptr<Texture> Text::writeDXToTexture(Uint8 flags, const std::string &text, int kerning, Color text_color, Uint8 shadow_distance, Color shadow_color, int lenght) {
|
||||||
auto renderer = Screen::get()->getRenderer();
|
auto renderer = Screen::get()->getRenderer();
|
||||||
auto texture = std::make_shared<Texture>(renderer);
|
auto texture = std::make_shared<Texture>(renderer);
|
||||||
auto width = Text::lenght(text, kerning) + shadow_distance;
|
auto width = Text::lenght(text, kerning) + shadow_distance;
|
||||||
@@ -170,7 +170,7 @@ std::shared_ptr<Texture> Text::writeDXToTexture(Uint8 flags, const std::string &
|
|||||||
texture->setAsRenderTarget(renderer);
|
texture->setAsRenderTarget(renderer);
|
||||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0);
|
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0);
|
||||||
SDL_RenderClear(renderer);
|
SDL_RenderClear(renderer);
|
||||||
writeDX(flags, 0, 0, text, kerning, textColor, shadow_distance, shadow_color, lenght);
|
writeDX(flags, 0, 0, text, kerning, text_color, shadow_distance, shadow_color, lenght);
|
||||||
SDL_SetRenderTarget(renderer, temp);
|
SDL_SetRenderTarget(renderer, temp);
|
||||||
|
|
||||||
return texture;
|
return texture;
|
||||||
@@ -198,21 +198,21 @@ void Text::writeCentered(int x, int y, const std::string &text, int kerning, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Escribe texto con extras
|
// Escribe texto con extras
|
||||||
void Text::writeDX(Uint8 flags, int x, int y, const std::string &text, int kerning, Color textColor, Uint8 shadow_distance, Color shadow_color, int lenght) {
|
void Text::writeDX(Uint8 flags, int x, int y, const std::string &text, int kerning, Color text_color, Uint8 shadow_distance, Color shadow_color, int lenght) {
|
||||||
const auto centered = ((flags & TEXT_CENTER) == TEXT_CENTER);
|
const auto CENTERED = ((flags & TEXT_CENTER) == TEXT_CENTER);
|
||||||
const auto shadowed = ((flags & TEXT_SHADOW) == TEXT_SHADOW);
|
const auto SHADOWED = ((flags & TEXT_SHADOW) == TEXT_SHADOW);
|
||||||
const auto colored = ((flags & TEXT_COLOR) == TEXT_COLOR);
|
const auto COLORED = ((flags & TEXT_COLOR) == TEXT_COLOR);
|
||||||
const auto stroked = ((flags & TEXT_STROKE) == TEXT_STROKE);
|
const auto STROKED = ((flags & TEXT_STROKE) == TEXT_STROKE);
|
||||||
|
|
||||||
if (centered) {
|
if (CENTERED) {
|
||||||
x -= (Text::lenght(text, kerning) / 2);
|
x -= (Text::lenght(text, kerning) / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shadowed) {
|
if (SHADOWED) {
|
||||||
writeColored(x + shadow_distance, y + shadow_distance, text, shadow_color, kerning, lenght);
|
writeColored(x + shadow_distance, y + shadow_distance, text, shadow_color, kerning, lenght);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stroked) {
|
if (STROKED) {
|
||||||
for (int dist = 1; dist <= shadow_distance; ++dist) {
|
for (int dist = 1; dist <= shadow_distance; ++dist) {
|
||||||
for (int dy = -dist; dy <= dist; ++dy) {
|
for (int dy = -dist; dy <= dist; ++dy) {
|
||||||
for (int dx = -dist; dx <= dist; ++dx) {
|
for (int dx = -dist; dx <= dist; ++dx) {
|
||||||
@@ -222,8 +222,8 @@ void Text::writeDX(Uint8 flags, int x, int y, const std::string &text, int kerni
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (colored) {
|
if (COLORED) {
|
||||||
writeColored(x, y, text, textColor, kerning, lenght);
|
writeColored(x, y, text, text_color, kerning, lenght);
|
||||||
} else {
|
} else {
|
||||||
write(x, y, text, kerning, lenght);
|
write(x, y, text, kerning, lenght);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,15 +22,15 @@ Texture::Texture(SDL_Renderer *renderer, const std::string &path)
|
|||||||
// Carga el fichero en la textura
|
// Carga el fichero en la textura
|
||||||
if (!path_.empty()) {
|
if (!path_.empty()) {
|
||||||
// Obtiene la extensión
|
// Obtiene la extensión
|
||||||
const std::string extension = path_.substr(path_.find_last_of(".") + 1);
|
const std::string EXTENSION = path_.substr(path_.find_last_of(".") + 1);
|
||||||
|
|
||||||
// .png
|
// .png
|
||||||
if (extension == "png") {
|
if (EXTENSION == "png") {
|
||||||
loadFromFile(path_);
|
loadFromFile(path_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// .gif
|
// .gif
|
||||||
else if (extension == "gif") {
|
else if (EXTENSION == "gif") {
|
||||||
// Crea la surface desde un fichero
|
// Crea la surface desde un fichero
|
||||||
surface_ = loadSurface(path_);
|
surface_ = loadSurface(path_);
|
||||||
|
|
||||||
@@ -149,28 +149,28 @@ void Texture::setAlpha(Uint8 alpha) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Renderiza la textura en un punto específico
|
// Renderiza la textura en un punto específico
|
||||||
void Texture::render(int x, int y, SDL_FRect *clip, float zoomW, float zoomH, double angle, SDL_FPoint *center, SDL_FlipMode flip) {
|
void Texture::render(int x, int y, SDL_FRect *clip, float zoom_w, float zoom_h, double angle, SDL_FPoint *center, SDL_FlipMode flip) {
|
||||||
// Establece el destino de renderizado en la pantalla
|
// Establece el destino de renderizado en la pantalla
|
||||||
SDL_FRect renderQuad = {static_cast<float>(x), static_cast<float>(y), static_cast<float>(width_), static_cast<float>(height_)};
|
SDL_FRect render_quad = {static_cast<float>(x), static_cast<float>(y), static_cast<float>(width_), static_cast<float>(height_)};
|
||||||
|
|
||||||
// Obtiene las dimesiones del clip de renderizado
|
// Obtiene las dimesiones del clip de renderizado
|
||||||
if (clip != nullptr) {
|
if (clip != nullptr) {
|
||||||
renderQuad.w = clip->w;
|
render_quad.w = clip->w;
|
||||||
renderQuad.h = clip->h;
|
render_quad.h = clip->h;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calcula el zoom y las coordenadas
|
// Calcula el zoom y las coordenadas
|
||||||
if (zoomH != 1.0f || zoomW != 1.0f) {
|
if (zoom_h != 1.0f || zoom_w != 1.0f) {
|
||||||
renderQuad.x = renderQuad.x + (renderQuad.w / 2);
|
render_quad.x = render_quad.x + (render_quad.w / 2);
|
||||||
renderQuad.y = renderQuad.y + (renderQuad.h / 2);
|
render_quad.y = render_quad.y + (render_quad.h / 2);
|
||||||
renderQuad.w = renderQuad.w * zoomW;
|
render_quad.w = render_quad.w * zoom_w;
|
||||||
renderQuad.h = renderQuad.h * zoomH;
|
render_quad.h = render_quad.h * zoom_h;
|
||||||
renderQuad.x = renderQuad.x - (renderQuad.w / 2);
|
render_quad.x = render_quad.x - (render_quad.w / 2);
|
||||||
renderQuad.y = renderQuad.y - (renderQuad.h / 2);
|
render_quad.y = render_quad.y - (render_quad.h / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Renderiza a pantalla
|
// Renderiza a pantalla
|
||||||
SDL_RenderTextureRotated(renderer_, texture_, clip, &renderQuad, angle, center, flip);
|
SDL_RenderTextureRotated(renderer_, texture_, clip, &render_quad, angle, center, flip);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece la textura como objetivo de renderizado
|
// Establece la textura como objetivo de renderizado
|
||||||
@@ -231,16 +231,16 @@ std::shared_ptr<Surface> Texture::loadSurface(const std::string &file_path) {
|
|||||||
// Crear un objeto Gif y llamar a la función loadGif
|
// Crear un objeto Gif y llamar a la función loadGif
|
||||||
GIF::Gif gif;
|
GIF::Gif gif;
|
||||||
Uint16 w = 0, h = 0;
|
Uint16 w = 0, h = 0;
|
||||||
std::vector<Uint8> rawPixels = gif.loadGif(buffer.data(), w, h);
|
std::vector<Uint8> raw_pixels = gif.loadGif(buffer.data(), w, h);
|
||||||
if (rawPixels.empty()) {
|
if (raw_pixels.empty()) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error: No se pudo cargar el GIF %s", file_path.c_str());
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error: No se pudo cargar el GIF %s", file_path.c_str());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si el constructor de Surface espera un std::shared_ptr<Uint8[]>:
|
// Si el constructor de Surface espera un std::shared_ptr<Uint8[]>:
|
||||||
size_t pixelCount = rawPixels.size();
|
size_t pixel_count = raw_pixels.size();
|
||||||
auto pixels = std::shared_ptr<Uint8[]>(new Uint8[pixelCount], std::default_delete<Uint8[]>());
|
auto pixels = std::shared_ptr<Uint8[]>(new Uint8[pixel_count], std::default_delete<Uint8[]>());
|
||||||
std::memcpy(pixels.get(), rawPixels.data(), pixelCount);
|
std::memcpy(pixels.get(), raw_pixels.data(), pixel_count);
|
||||||
|
|
||||||
auto surface = std::make_shared<Surface>(w, h, pixels);
|
auto surface = std::make_shared<Surface>(w, h, pixels);
|
||||||
|
|
||||||
|
|||||||
@@ -60,11 +60,11 @@ void TiledBG::fillTexture() {
|
|||||||
SDL_SetRenderTarget(renderer_, canvas_);
|
SDL_SetRenderTarget(renderer_, canvas_);
|
||||||
|
|
||||||
// Rellena la textura con el tile
|
// Rellena la textura con el tile
|
||||||
const auto i_max = pos_.w * 2 / TILE_WIDTH_;
|
const auto I_MAX = pos_.w * 2 / TILE_WIDTH_;
|
||||||
const auto j_max = pos_.h * 2 / TILE_HEIGHT_;
|
const auto J_MAX = pos_.h * 2 / TILE_HEIGHT_;
|
||||||
tile->setSpriteClip(0, 0, TILE_WIDTH_, TILE_HEIGHT_);
|
tile->setSpriteClip(0, 0, TILE_WIDTH_, TILE_HEIGHT_);
|
||||||
for (int i = 0; i < i_max; ++i) {
|
for (int i = 0; i < I_MAX; ++i) {
|
||||||
for (int j = 0; j < j_max; ++j) {
|
for (int j = 0; j < J_MAX; ++j) {
|
||||||
tile->setX(i * TILE_WIDTH_);
|
tile->setX(i * TILE_WIDTH_);
|
||||||
tile->setY(j * TILE_HEIGHT_);
|
tile->setY(j * TILE_HEIGHT_);
|
||||||
tile->render();
|
tile->render();
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ MenuRenderer::MenuRenderer(const ServiceMenu *menu_state, std::shared_ptr<Text>
|
|||||||
void MenuRenderer::render(const ServiceMenu *menu_state) {
|
void MenuRenderer::render(const ServiceMenu *menu_state) {
|
||||||
// Dibuja la sombra
|
// Dibuja la sombra
|
||||||
if (param.service_menu.drop_shadow) {
|
if (param.service_menu.drop_shadow) {
|
||||||
SDL_FRect shadowRect = {rect_.x + 5, rect_.y + 5, rect_.w, rect_.h};
|
SDL_FRect shadow_rect = {rect_.x + 5, rect_.y + 5, rect_.w, rect_.h};
|
||||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 0, 0, 64);
|
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 0, 0, 64);
|
||||||
SDL_RenderFillRect(Screen::get()->getRenderer(), &shadowRect);
|
SDL_RenderFillRect(Screen::get()->getRenderer(), &shadow_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja el fondo
|
// Dibuja el fondo
|
||||||
@@ -43,8 +43,8 @@ void MenuRenderer::render(const ServiceMenu *menu_state) {
|
|||||||
y = options_y_;
|
y = options_y_;
|
||||||
const auto &option_pairs = menu_state->getOptionPairs();
|
const auto &option_pairs = menu_state->getOptionPairs();
|
||||||
for (size_t i = 0; i < option_pairs.size(); ++i) {
|
for (size_t i = 0; i < option_pairs.size(); ++i) {
|
||||||
const bool is_selected = (i == menu_state->getSelectedIndex());
|
const bool IS_SELECTED = (i == menu_state->getSelectedIndex());
|
||||||
const Color ¤t_color = is_selected ? param.service_menu.selected_color : param.service_menu.text_color;
|
const Color ¤t_color = IS_SELECTED ? param.service_menu.selected_color : param.service_menu.text_color;
|
||||||
|
|
||||||
if (menu_state->getCurrentGroupAlignment() == ServiceMenu::GroupAlignment::LEFT) {
|
if (menu_state->getCurrentGroupAlignment() == ServiceMenu::GroupAlignment::LEFT) {
|
||||||
element_text_->writeColored(rect_.x + ServiceMenu::OPTIONS_HORIZONTAL_PADDING_, y, option_pairs.at(i).first, current_color, -2);
|
element_text_->writeColored(rect_.x + ServiceMenu::OPTIONS_HORIZONTAL_PADDING_, y, option_pairs.at(i).first, current_color, -2);
|
||||||
@@ -177,17 +177,17 @@ int MenuRenderer::getMenuWidthForGroup(ServiceMenu::SettingsGroup group) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MenuRenderer::updateColorCounter() {
|
void MenuRenderer::updateColorCounter() {
|
||||||
static Uint64 lastUpdate = SDL_GetTicks();
|
static Uint64 last_update_ = SDL_GetTicks();
|
||||||
Uint64 currentTicks = SDL_GetTicks();
|
Uint64 current_ticks = SDL_GetTicks();
|
||||||
if (currentTicks - lastUpdate >= 50) {
|
if (current_ticks - last_update_ >= 50) {
|
||||||
color_counter_++;
|
color_counter_++;
|
||||||
lastUpdate = currentTicks;
|
last_update_ = current_ticks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Color MenuRenderer::getAnimatedSelectedColor() {
|
Color MenuRenderer::getAnimatedSelectedColor() {
|
||||||
static auto colorCycle = generateMirroredCycle(param.service_menu.selected_color, ColorCycleStyle::HUE_WAVE);
|
static auto color_cycle_ = generateMirroredCycle(param.service_menu.selected_color, ColorCycleStyle::HUE_WAVE);
|
||||||
return colorCycle.at(color_counter_ % colorCycle.size());
|
return color_cycle_.at(color_counter_ % color_cycle_.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_FRect MenuRenderer::setRect(SDL_FRect rect) {
|
SDL_FRect MenuRenderer::setRect(SDL_FRect rect) {
|
||||||
|
|||||||
Reference in New Issue
Block a user