Compare commits
3 Commits
3d26a3022c
...
1d3b016b85
| Author | SHA1 | Date | |
|---|---|---|---|
| 1d3b016b85 | |||
| 72d2525e61 | |||
| 6bc5cf1e93 |
@@ -8,6 +8,8 @@ game.play_area.rect.w 320 # Ancho de la zona jugable
|
|||||||
game.play_area.rect.h 200 # Alto de la zona jugable
|
game.play_area.rect.h 200 # Alto de la zona jugable
|
||||||
game.name_entry_idle_time 10 # Segundos para introducir el nombre al finalizar la partida si no se pulsa nada
|
game.name_entry_idle_time 10 # Segundos para introducir el nombre al finalizar la partida si no se pulsa nada
|
||||||
game.name_entry_total_time 60 # Segundos totales para introducir el nombre al finalizar la partida
|
game.name_entry_total_time 60 # Segundos totales para introducir el nombre al finalizar la partida
|
||||||
|
game.hit_stop true # Indica si debe haber un paro cuando el jugador es golpeado por un globo
|
||||||
|
game.hit_stop_ms 300 # Cantidad de milisegundos que dura el hit_stop
|
||||||
|
|
||||||
## --- FADE ---
|
## --- FADE ---
|
||||||
fade.color 1F2B30 # Color hexadecimal para el efecto de fundido
|
fade.color 1F2B30 # Color hexadecimal para el efecto de fundido
|
||||||
@@ -52,10 +54,12 @@ balloon.settings[2].grav 0.10f # Gravedad aplicada al globo 3
|
|||||||
balloon.settings[3].vel 5.45f # Velocidad inicial del globo 4
|
balloon.settings[3].vel 5.45f # Velocidad inicial del globo 4
|
||||||
balloon.settings[3].grav 0.10f # Gravedad aplicada al globo 4
|
balloon.settings[3].grav 0.10f # Gravedad aplicada al globo 4
|
||||||
|
|
||||||
balloon.color[0] blue # Color de creación del globo normal
|
balloon.color[0] blue # Color de creación del globo normal
|
||||||
balloon.color[1] orange # Color del globo normal
|
balloon.color[1] orange # Color del globo normal
|
||||||
balloon.color[2] red # Color de creación del globo que rebota
|
balloon.color[2] red # Color de creación del globo que rebota
|
||||||
balloon.color[3] green # Color del globo que rebota
|
balloon.color[3] green # Color del globo que rebota
|
||||||
|
|
||||||
|
balloon.bouncing_sound false # Indica si los globos hacer sonido al rebotar
|
||||||
|
|
||||||
## --- NOTIFICATION ---
|
## --- NOTIFICATION ---
|
||||||
notification.pos_v TOP # Posición vertical de la notificación (TOP/BOTTOM)
|
notification.pos_v TOP # Posición vertical de la notificación (TOP/BOTTOM)
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ game.play_area.rect.w 320 # Ancho de la zona jugable
|
|||||||
game.play_area.rect.h 216 # Alto de la zona jugable
|
game.play_area.rect.h 216 # Alto de la zona jugable
|
||||||
game.name_entry_idle_time 10 # Segundos para introducir el nombre al finalizar la partida si no se pulsa nada
|
game.name_entry_idle_time 10 # Segundos para introducir el nombre al finalizar la partida si no se pulsa nada
|
||||||
game.name_entry_total_time 60 # Segundos totales para introducir el nombre al finalizar la partida
|
game.name_entry_total_time 60 # Segundos totales para introducir el nombre al finalizar la partida
|
||||||
|
game.hit_stop true # Indica si debe haber un paro cuando el jugador es golpeado por un globo
|
||||||
|
game.hit_stop_ms 300 # Cantidad de milisegundos que dura el hit_stop
|
||||||
|
|
||||||
## --- FADE ---
|
## --- FADE ---
|
||||||
fade.color 1F2B30 # Color hexadecimal para el efecto de fundido
|
fade.color 1F2B30 # Color hexadecimal para el efecto de fundido
|
||||||
@@ -52,10 +54,12 @@ balloon.settings[2].grav 0.10f # Gravedad aplicada al globo 3
|
|||||||
balloon.settings[3].vel 5.45f # Velocidad inicial del globo 4
|
balloon.settings[3].vel 5.45f # Velocidad inicial del globo 4
|
||||||
balloon.settings[3].grav 0.10f # Gravedad aplicada al globo 4
|
balloon.settings[3].grav 0.10f # Gravedad aplicada al globo 4
|
||||||
|
|
||||||
balloon.color[0] blue # Color de creación del globo normal
|
balloon.color[0] blue # Color de creación del globo normal
|
||||||
balloon.color[1] orange # Color del globo normal
|
balloon.color[1] orange # Color del globo normal
|
||||||
balloon.color[2] red # Color de creación del globo que rebota
|
balloon.color[2] red # Color de creación del globo que rebota
|
||||||
balloon.color[3] green # Color del globo que rebota
|
balloon.color[3] green # Color del globo que rebota
|
||||||
|
|
||||||
|
balloon.bouncing_sound false # Indica si los globos hacer sonido al rebotar
|
||||||
|
|
||||||
## --- NOTIFICATION ---
|
## --- NOTIFICATION ---
|
||||||
notification.pos_v TOP # Posición vertical de la notificación (TOP/BOTTOM)
|
notification.pos_v TOP # Posición vertical de la notificación (TOP/BOTTOM)
|
||||||
|
|||||||
Binary file not shown.
@@ -38,7 +38,8 @@ Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel
|
|||||||
power_ = BALLOON_POWER[index];
|
power_ = BALLOON_POWER[index];
|
||||||
menace_ = BALLOON_MENACE[index];
|
menace_ = BALLOON_MENACE[index];
|
||||||
score_ = BALLOON_SCORE[index];
|
score_ = BALLOON_SCORE[index];
|
||||||
sound_ = BALLOON_SOUND[index];
|
bouncing_sound_ = BALLOON_BOUNCING_SOUND[index];
|
||||||
|
popping_sound_ = BALLOON_POPPING_SOUND[index];
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -53,7 +54,8 @@ Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel
|
|||||||
power_ = BALLOON_POWER[index];
|
power_ = BALLOON_POWER[index];
|
||||||
menace_ = BALLOON_MENACE[index];
|
menace_ = BALLOON_MENACE[index];
|
||||||
score_ = BALLOON_SCORE[index];
|
score_ = BALLOON_SCORE[index];
|
||||||
sound_ = BALLOON_SOUND[index];
|
bouncing_sound_ = BALLOON_BOUNCING_SOUND[index];
|
||||||
|
popping_sound_ = BALLOON_POPPING_SOUND[index];
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -62,7 +64,7 @@ Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel
|
|||||||
{
|
{
|
||||||
constexpr int index = 3;
|
constexpr int index = 3;
|
||||||
h_ = w_ = BALLOON_SIZE[4];
|
h_ = w_ = BALLOON_SIZE[4];
|
||||||
sound_ = BALLOON_SOUND[3];
|
bouncing_sound_ = BALLOON_BOUNCING_SOUND[3];
|
||||||
power_ = score_ = menace_ = 0;
|
power_ = score_ = menace_ = 0;
|
||||||
|
|
||||||
vy_ = 0;
|
vy_ = 0;
|
||||||
@@ -162,7 +164,8 @@ void Balloon::move()
|
|||||||
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)
|
||||||
{
|
{
|
||||||
playSound();
|
if (bouncing_sound_enabled_)
|
||||||
|
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
|
||||||
@@ -185,7 +188,8 @@ void Balloon::move()
|
|||||||
const int min_y = play_area_.y;
|
const int min_y = play_area_.y;
|
||||||
if (y_ < min_y)
|
if (y_ < min_y)
|
||||||
{
|
{
|
||||||
playSound();
|
if (bouncing_sound_enabled_)
|
||||||
|
playSound(bouncing_sound_);
|
||||||
y_ = min_y;
|
y_ = min_y;
|
||||||
vy_ = -vy_;
|
vy_ = -vy_;
|
||||||
enableBounce();
|
enableBounce();
|
||||||
@@ -196,7 +200,8 @@ void Balloon::move()
|
|||||||
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)
|
||||||
{
|
{
|
||||||
playSound();
|
if (bouncing_sound_enabled_)
|
||||||
|
playSound(bouncing_sound_);
|
||||||
y_ = max_y;
|
y_ = max_y;
|
||||||
vy_ = -default_vy_;
|
vy_ = -default_vy_;
|
||||||
if (type_ != BalloonType::POWERBALL)
|
if (type_ != BalloonType::POWERBALL)
|
||||||
@@ -409,11 +414,24 @@ void Balloon::useNormalColor()
|
|||||||
setAnimation();
|
setAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reproduce el sonido al rebotar
|
// Reproduce sonido
|
||||||
void Balloon::playSound()
|
void Balloon::playSound(const std::string &name)
|
||||||
{
|
{
|
||||||
if (sound_enabled_)
|
if (!sound_enabled_)
|
||||||
|
return;
|
||||||
|
|
||||||
|
static auto audio = Audio::get();
|
||||||
|
audio->playSound(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Explota el globo
|
||||||
|
void Balloon::pop(bool should_sound)
|
||||||
|
{
|
||||||
|
if (should_sound)
|
||||||
{
|
{
|
||||||
Audio::get()->playSound(sound_);
|
if (poping_sound_enabled_)
|
||||||
|
playSound(popping_sound_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enabled_ = false;
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,8 @@ constexpr int BALLOON_SCORE[] = {50, 100, 200, 400};
|
|||||||
constexpr int BALLOON_POWER[] = {1, 3, 7, 15};
|
constexpr int BALLOON_POWER[] = {1, 3, 7, 15};
|
||||||
constexpr int BALLOON_MENACE[] = {1, 2, 4, 8};
|
constexpr int BALLOON_MENACE[] = {1, 2, 4, 8};
|
||||||
constexpr int BALLOON_SIZE[] = {10, 16, 26, 48, 49};
|
constexpr int BALLOON_SIZE[] = {10, 16, 26, 48, 49};
|
||||||
const std::string BALLOON_SOUND[] = {"bubble1.wav", "bubble2.wav", "bubble3.wav", "bubble4.wav"};
|
const std::string BALLOON_BOUNCING_SOUND[] = {"bubble1.wav", "bubble2.wav", "bubble3.wav", "bubble4.wav"};
|
||||||
|
const std::string BALLOON_POPPING_SOUND[] = {"balloon1.wav", "balloon2.wav", "balloon3.wav", "balloon4.wav"};
|
||||||
|
|
||||||
enum class BalloonSize : Uint8
|
enum class BalloonSize : Uint8
|
||||||
{
|
{
|
||||||
@@ -65,12 +66,13 @@ public:
|
|||||||
~Balloon() = default;
|
~Balloon() = default;
|
||||||
|
|
||||||
// --- Métodos principales ---
|
// --- Métodos principales ---
|
||||||
void alignTo(int x); // Centra el globo en la posición X
|
void alignTo(int x); // Centra el globo en la posición X
|
||||||
void render(); // Pinta el globo en la pantalla
|
void render(); // Pinta el globo en la pantalla
|
||||||
void move(); // Actualiza la posición y estados del globo
|
void move(); // Actualiza la posición y estados del globo
|
||||||
void update(); // Actualiza el globo (posición, animación, contadores)
|
void update(); // Actualiza el globo (posición, animación, contadores)
|
||||||
void stop(); // Detiene el globo
|
void stop(); // Detiene el globo
|
||||||
void start(); // Pone el globo en movimiento
|
void start(); // Pone el globo en movimiento
|
||||||
|
void pop(bool should_sound = false); // Explota el globo
|
||||||
|
|
||||||
// --- Métodos de color ---
|
// --- Métodos de color ---
|
||||||
void useReverseColor(); // Pone el color alternativo en el globo
|
void useReverseColor(); // Pone el color alternativo en el globo
|
||||||
@@ -99,8 +101,9 @@ public:
|
|||||||
void setVelY(float vel_y) { vy_ = vel_y; }
|
void setVelY(float vel_y) { vy_ = vel_y; }
|
||||||
void setSpeed(float speed) { speed_ = speed; }
|
void setSpeed(float speed) { speed_ = speed; }
|
||||||
void setInvulnerable(bool value) { invulnerable_ = value; }
|
void setInvulnerable(bool value) { invulnerable_ = value; }
|
||||||
|
void setBouncingSound(bool value) { bouncing_sound_enabled_ = value; }
|
||||||
|
void setPoppingSound(bool value) { poping_sound_enabled_ = value; }
|
||||||
void setSound(bool value) { sound_enabled_ = value; }
|
void setSound(bool value) { sound_enabled_ = value; }
|
||||||
void disable() { enabled_ = false; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// --- Estructura para el efecto de rebote ---
|
// --- Estructura para el efecto de rebote ---
|
||||||
@@ -132,43 +135,46 @@ private:
|
|||||||
std::unique_ptr<AnimatedSprite> sprite_; // Sprite del objeto globo
|
std::unique_ptr<AnimatedSprite> sprite_; // Sprite del objeto globo
|
||||||
|
|
||||||
// --- Variables de estado y físicas ---
|
// --- Variables de estado y físicas ---
|
||||||
float x_; // Posición X
|
float x_; // Posición X
|
||||||
float y_; // Posición Y
|
float y_; // Posición Y
|
||||||
float w_; // Ancho
|
float w_; // Ancho
|
||||||
float h_; // Alto
|
float h_; // Alto
|
||||||
float vx_; // Velocidad X
|
float vx_; // Velocidad X
|
||||||
float vy_; // Velocidad Y
|
float vy_; // Velocidad Y
|
||||||
float gravity_; // Aceleración en Y
|
float gravity_; // Aceleración en Y
|
||||||
float default_vy_; // Velocidad inicial al rebotar
|
float default_vy_; // Velocidad inicial al rebotar
|
||||||
float max_vy_; // Máxima velocidad en Y
|
float max_vy_; // Máxima velocidad en Y
|
||||||
bool being_created_; // Si el globo se está creando
|
bool being_created_; // Si el globo se está creando
|
||||||
bool enabled_ = true; // Si el globo está activo
|
bool enabled_ = true; // Si el globo está activo
|
||||||
bool invulnerable_; // Si el globo es invulnerable
|
bool invulnerable_; // Si el globo es invulnerable
|
||||||
bool stopped_; // Si el globo está parado
|
bool stopped_; // Si el globo está parado
|
||||||
bool use_reversed_colors_ = false; // Si se usa el color alternativo
|
bool use_reversed_colors_ = false; // Si se usa el color alternativo
|
||||||
Circle collider_; // Círculo de colisión
|
Circle collider_; // Círculo de colisión
|
||||||
Uint16 creation_counter_; // Temporizador de creación
|
Uint16 creation_counter_; // Temporizador de creación
|
||||||
Uint16 creation_counter_ini_; // Valor inicial del temporizador de creación
|
Uint16 creation_counter_ini_; // Valor inicial del temporizador de creación
|
||||||
Uint16 score_; // Puntos al destruir el globo
|
Uint16 score_; // Puntos al destruir el globo
|
||||||
BalloonType type_; // Tipo de globo
|
BalloonType type_; // Tipo de globo
|
||||||
BalloonSize size_; // Tamaño de globo
|
BalloonSize size_; // Tamaño de globo
|
||||||
Uint8 menace_; // Amenaza que genera el globo
|
Uint8 menace_; // Amenaza que genera el globo
|
||||||
Uint32 counter_ = 0; // Contador interno
|
Uint32 counter_ = 0; // Contador interno
|
||||||
float travel_y_ = 1.0f; // Distancia a recorrer en Y antes de aplicar gravedad
|
float travel_y_ = 1.0f; // Distancia a recorrer en Y antes de aplicar gravedad
|
||||||
float speed_; // Velocidad del globo
|
float speed_; // Velocidad del globo
|
||||||
Uint8 power_; // Poder que alberga el globo
|
Uint8 power_; // Poder que alberga el globo
|
||||||
SDL_FRect play_area_; // Zona de movimiento del globo
|
SDL_FRect play_area_; // Zona de movimiento del globo
|
||||||
std::string sound_; // Archivo de sonido al rebotar
|
std::string bouncing_sound_; // Archivo de sonido al rebotar
|
||||||
bool sound_enabled_ = false; // Si debe sonar el globo al rebotar
|
std::string popping_sound_; // Archivo de sonido al explotar
|
||||||
|
bool bouncing_sound_enabled_ = false; // Si debe sonar el globo al rebotar
|
||||||
|
bool poping_sound_enabled_ = true; // Si debe sonar el globo al explotar
|
||||||
|
bool sound_enabled_ = true; // Indica si los globos deben hacer algun sonido
|
||||||
|
|
||||||
// --- Métodos internos ---
|
// --- Métodos internos ---
|
||||||
void shiftColliders(); // Alinea el círculo de colisión
|
void shiftColliders(); // Alinea el círculo de colisión
|
||||||
void shiftSprite(); // Alinea el sprite
|
void shiftSprite(); // Alinea el sprite
|
||||||
void zoomSprite(); // Establece el nivel de zoom del sprite
|
void zoomSprite(); // Establece el nivel de zoom del sprite
|
||||||
void enableBounce(); // Activa el efecto de rebote
|
void enableBounce(); // Activa el efecto de rebote
|
||||||
void disableBounce(); // Detiene el efecto de rebote
|
void disableBounce(); // Detiene el efecto de rebote
|
||||||
void updateBounce(); // Aplica el efecto de rebote
|
void updateBounce(); // Aplica el efecto de rebote
|
||||||
void updateState(); // Actualiza los estados del globo
|
void updateState(); // Actualiza los estados del globo
|
||||||
void setAnimation(); // Establece la animación correspondiente
|
void setAnimation(); // Establece la animación correspondiente
|
||||||
void playSound(); // Reproduce el sonido al rebotar
|
void playSound(const std::string &name); // Reproduce sonido
|
||||||
};
|
};
|
||||||
@@ -180,8 +180,11 @@ std::shared_ptr<Balloon> BalloonManager::createBalloon(float x, int y, BalloonTy
|
|||||||
{
|
{
|
||||||
if (can_deploy_balloons_)
|
if (can_deploy_balloons_)
|
||||||
{
|
{
|
||||||
const int index = static_cast<int>(size);
|
const int INDEX = static_cast<int>(size);
|
||||||
balloons_.emplace_back(std::make_shared<Balloon>(x, y, type, size, velx, speed, creation_timer, play_area_, balloon_textures_.at(index), balloon_animations_.at(index)));
|
balloons_.emplace_back(std::make_shared<Balloon>(x, y, type, size, velx, speed, creation_timer, play_area_, balloon_textures_.at(INDEX), balloon_animations_.at(INDEX)));
|
||||||
|
balloons_.back()->setSound(sound_enabled_);
|
||||||
|
balloons_.back()->setBouncingSound(bouncing_sound_enabled_);
|
||||||
|
balloons_.back()->setPoppingSound(poping_sound_enabled_);
|
||||||
return balloons_.back();
|
return balloons_.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,7 +271,7 @@ int BalloonManager::popBalloon(std::shared_ptr<Balloon> balloon)
|
|||||||
|
|
||||||
// Agrega la explosión y elimina el globo
|
// Agrega la explosión y elimina el globo
|
||||||
explosions_->add(balloon->getPosX(), balloon->getPosY(), static_cast<int>(balloon->getSize()));
|
explosions_->add(balloon->getPosX(), balloon->getPosY(), static_cast<int>(balloon->getSize()));
|
||||||
balloon->disable();
|
balloon->pop(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return score;
|
return score;
|
||||||
@@ -304,7 +307,7 @@ int BalloonManager::destroyBalloon(std::shared_ptr<Balloon> &balloon)
|
|||||||
|
|
||||||
// Destruye el globo
|
// Destruye el globo
|
||||||
explosions_->add(balloon->getPosX(), balloon->getPosY(), static_cast<int>(balloon->getSize()));
|
explosions_->add(balloon->getPosX(), balloon->getPosY(), static_cast<int>(balloon->getSize()));
|
||||||
balloon->disable();
|
balloon->pop();
|
||||||
|
|
||||||
return score;
|
return score;
|
||||||
}
|
}
|
||||||
@@ -398,8 +401,28 @@ int BalloonManager::getMenace()
|
|||||||
// Establece el sonido de los globos
|
// Establece el sonido de los globos
|
||||||
void BalloonManager::setSounds(bool value)
|
void BalloonManager::setSounds(bool value)
|
||||||
{
|
{
|
||||||
|
sound_enabled_ = value;
|
||||||
for (auto &balloon : balloons_)
|
for (auto &balloon : balloons_)
|
||||||
{
|
{
|
||||||
balloon->setSound(value);
|
balloon->setSound(value);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Activa o desactiva los sonidos de rebote los globos
|
||||||
|
void BalloonManager::setBouncingSounds(bool value)
|
||||||
|
{
|
||||||
|
bouncing_sound_enabled_ = value;
|
||||||
|
for (auto &balloon : balloons_)
|
||||||
|
{
|
||||||
|
balloon->setBouncingSound(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Activa o desactiva los sonidos de los globos al explotar
|
||||||
|
void BalloonManager::setPoppingSounds(bool value)
|
||||||
|
{
|
||||||
|
poping_sound_enabled_ = value;
|
||||||
|
for (auto &balloon : balloons_)
|
||||||
|
{
|
||||||
|
balloon->setPoppingSound(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -61,6 +61,8 @@ public:
|
|||||||
|
|
||||||
// Configuración de sonido
|
// Configuración de sonido
|
||||||
void setSounds(bool value); // Activa o desactiva los sonidos de los globos
|
void setSounds(bool value); // Activa o desactiva los sonidos de los globos
|
||||||
|
void setBouncingSounds(bool value); // Activa o desactiva los sonidos de rebote los globos
|
||||||
|
void setPoppingSounds(bool value); // Activa o desactiva los sonidos de los globos al explotar
|
||||||
|
|
||||||
// Configuración de juego
|
// Configuración de juego
|
||||||
void setPlayArea(SDL_FRect play_area) { play_area_ = play_area; }; // Define el área de juego
|
void setPlayArea(SDL_FRect play_area) { play_area_ = play_area; }; // Define el área de juego
|
||||||
@@ -94,7 +96,10 @@ private:
|
|||||||
SDL_FRect play_area_ = param.game.play_area.rect;
|
SDL_FRect play_area_ = param.game.play_area.rect;
|
||||||
bool creation_time_enabled_ = true;
|
bool creation_time_enabled_ = true;
|
||||||
bool can_deploy_balloons_ = true;
|
bool can_deploy_balloons_ = true;
|
||||||
|
bool bouncing_sound_enabled_ = false; // Si debe sonar el globo al rebotar
|
||||||
|
bool poping_sound_enabled_ = true; // Si debe sonar el globo al explotar
|
||||||
|
bool sound_enabled_ = true; // Indica si los globos deben hacer algun sonido
|
||||||
|
|
||||||
// Inicialización interna
|
// Metodos privados
|
||||||
void init();
|
void init();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -635,6 +635,7 @@ void Director::reset()
|
|||||||
{
|
{
|
||||||
Resource::get()->reload();
|
Resource::get()->reload();
|
||||||
}
|
}
|
||||||
|
Input::get()->discoverGameControllers();
|
||||||
ServiceMenu::get()->reset();
|
ServiceMenu::get()->reset();
|
||||||
Section::name = Section::Name::LOGO;
|
Section::name = Section::Name::LOGO;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ void initParam()
|
|||||||
param.game.name_entry_idle_time = 10;
|
param.game.name_entry_idle_time = 10;
|
||||||
param.game.name_entry_total_time = 60;
|
param.game.name_entry_total_time = 60;
|
||||||
param.game.speed = 15;
|
param.game.speed = 15;
|
||||||
|
param.game.hit_stop = true;
|
||||||
|
param.game.hit_stop_ms = 300;
|
||||||
precalculateZones();
|
precalculateZones();
|
||||||
|
|
||||||
// SCOREBOARD
|
// SCOREBOARD
|
||||||
@@ -68,6 +70,8 @@ void initParam()
|
|||||||
param.balloon.color.at(2) = "red";
|
param.balloon.color.at(2) = "red";
|
||||||
param.balloon.color.at(3) = "green";
|
param.balloon.color.at(3) = "green";
|
||||||
|
|
||||||
|
param.balloon.bouncing_sound = false;
|
||||||
|
|
||||||
// NOTIFICATION
|
// NOTIFICATION
|
||||||
param.notification.pos_v = NotifyPosition::TOP;
|
param.notification.pos_v = NotifyPosition::TOP;
|
||||||
param.notification.pos_h = NotifyPosition::LEFT;
|
param.notification.pos_h = NotifyPosition::LEFT;
|
||||||
@@ -171,6 +175,16 @@ bool setParams(const std::string &var, const std::string &value)
|
|||||||
param.game.name_entry_total_time = std::stoi(value);
|
param.game.name_entry_total_time = std::stoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (var == "game.hit_stop")
|
||||||
|
{
|
||||||
|
param.game.hit_stop = stringToBool(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (var == "game.hit_stop_ms")
|
||||||
|
{
|
||||||
|
param.game.hit_stop_ms = std::stoi(value);
|
||||||
|
}
|
||||||
|
|
||||||
// FADE
|
// FADE
|
||||||
else if (var == "fade.color")
|
else if (var == "fade.color")
|
||||||
{
|
{
|
||||||
@@ -361,6 +375,11 @@ bool setParams(const std::string &var, const std::string &value)
|
|||||||
param.balloon.color.at(3) = value;
|
param.balloon.color.at(3) = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (var == "balloon.bouncing_sound")
|
||||||
|
{
|
||||||
|
param.balloon.bouncing_sound = stringToBool(value);
|
||||||
|
}
|
||||||
|
|
||||||
// NOTIFICACIONES
|
// NOTIFICACIONES
|
||||||
else if (var == "notification.pos_h")
|
else if (var == "notification.pos_h")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ struct ParamGame
|
|||||||
int name_entry_idle_time; // Segundos para introducir el nombre al finalizar la partida si no se pulsa nada
|
int name_entry_idle_time; // Segundos para introducir el nombre al finalizar la partida si no se pulsa nada
|
||||||
int name_entry_total_time; // Segundos totales para introducir el nombre al finalizar la partida
|
int name_entry_total_time; // Segundos totales para introducir el nombre al finalizar la partida
|
||||||
Uint32 speed; // Velocidad a la que transcurre el juego
|
Uint32 speed; // Velocidad a la que transcurre el juego
|
||||||
|
bool hit_stop; // Indica si debe haber un paro cuando el jugador es golpeado por un globo
|
||||||
|
Uint32 hit_stop_ms; // Cantidad de milisegundos que dura el hit_stop
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- Parámetros del fade ---
|
// --- Parámetros del fade ---
|
||||||
@@ -61,6 +63,7 @@ struct ParamBalloon
|
|||||||
|
|
||||||
std::array<Settings, 4> settings;
|
std::array<Settings, 4> settings;
|
||||||
std::array<std::string, 4> color;
|
std::array<std::string, 4> color;
|
||||||
|
bool bouncing_sound; // Indica si los globos hacer sonido al rebotar
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- Parámetros de las notificaciones ---
|
// --- Parámetros de las notificaciones ---
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ void Player::move()
|
|||||||
case PlayerState::TITLE_ANIMATION:
|
case PlayerState::TITLE_ANIMATION:
|
||||||
{
|
{
|
||||||
// Si el jugador abandona el area de juego por los laterales lo detiene
|
// Si el jugador abandona el area de juego por los laterales lo detiene
|
||||||
const int X = player_sprite_->getPosX();
|
/*const int X = player_sprite_->getPosX();
|
||||||
const int MIN_X = play_area_.x - WIDTH_;
|
const int MIN_X = play_area_.x - WIDTH_;
|
||||||
const int MAX_X = play_area_.x + play_area_.w;
|
const int MAX_X = play_area_.x + play_area_.w;
|
||||||
if ((X < MIN_X) || (X > MAX_X))
|
if ((X < MIN_X) || (X > MAX_X))
|
||||||
@@ -229,6 +229,28 @@ void Player::move()
|
|||||||
|
|
||||||
// Si el jugador toca el suelo rebota lo detiene
|
// Si el jugador toca el suelo rebota lo detiene
|
||||||
if (player_sprite_->getPosY() > play_area_.h)
|
if (player_sprite_->getPosY() > play_area_.h)
|
||||||
|
{
|
||||||
|
setPlayingState(PlayerState::TITLE_HIDDEN);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
switch (id_)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
setInputPlaying(InputAction::LEFT);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
setInputPlaying(InputAction::RIGHT);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pos_x_ += vel_x_ * 2.0f;
|
||||||
|
const float MIN_X = -WIDTH_;
|
||||||
|
const float MAX_X = play_area_.w;
|
||||||
|
pos_x_ = std::clamp(pos_x_, MIN_X, MAX_X);
|
||||||
|
shiftSprite();
|
||||||
|
|
||||||
|
if (pos_x_ == MIN_X || pos_x_ == MAX_X)
|
||||||
{
|
{
|
||||||
setPlayingState(PlayerState::TITLE_HIDDEN);
|
setPlayingState(PlayerState::TITLE_HIDDEN);
|
||||||
}
|
}
|
||||||
@@ -263,12 +285,12 @@ void Player::move()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pos_x_ += vel_x_;
|
pos_x_ += vel_x_;
|
||||||
const float min_x = -WIDTH_;
|
const float MIN_X = -WIDTH_;
|
||||||
const float max_x = play_area_.w;
|
const float MAX_X = play_area_.w;
|
||||||
pos_x_ = std::clamp(pos_x_, min_x, max_x);
|
pos_x_ = std::clamp(pos_x_, MIN_X, MAX_X);
|
||||||
shiftSprite();
|
shiftSprite();
|
||||||
|
|
||||||
if (pos_x_ == min_x || pos_x_ == max_x)
|
if (pos_x_ == MIN_X || pos_x_ == MAX_X)
|
||||||
{
|
{
|
||||||
setPlayingState(PlayerState::GAME_OVER);
|
setPlayingState(PlayerState::GAME_OVER);
|
||||||
}
|
}
|
||||||
@@ -374,6 +396,7 @@ void Player::setAnimation()
|
|||||||
case PlayerState::ENTERING_NAME_GAME_COMPLETED:
|
case PlayerState::ENTERING_NAME_GAME_COMPLETED:
|
||||||
case PlayerState::ENTERING_SCREEN:
|
case PlayerState::ENTERING_SCREEN:
|
||||||
case PlayerState::LEAVING_SCREEN:
|
case PlayerState::LEAVING_SCREEN:
|
||||||
|
case PlayerState::TITLE_ANIMATION:
|
||||||
case PlayerState::CREDITS:
|
case PlayerState::CREDITS:
|
||||||
{
|
{
|
||||||
// Crea cadenas de texto para componer el nombre de la animación
|
// Crea cadenas de texto para componer el nombre de la animación
|
||||||
@@ -418,7 +441,6 @@ void Player::setAnimation()
|
|||||||
}
|
}
|
||||||
case PlayerState::ROLLING:
|
case PlayerState::ROLLING:
|
||||||
case PlayerState::CONTINUE_TIME_OUT:
|
case PlayerState::CONTINUE_TIME_OUT:
|
||||||
case PlayerState::TITLE_ANIMATION:
|
|
||||||
{
|
{
|
||||||
player_sprite_->setCurrentAnimation("rolling");
|
player_sprite_->setCurrentAnimation("rolling");
|
||||||
break;
|
break;
|
||||||
@@ -638,10 +660,7 @@ void Player::setPlayingState(PlayerState state)
|
|||||||
case PlayerState::TITLE_ANIMATION:
|
case PlayerState::TITLE_ANIMATION:
|
||||||
{
|
{
|
||||||
// Activa la animación de rodar
|
// Activa la animación de rodar
|
||||||
player_sprite_->setCurrentAnimation("rolling");
|
player_sprite_->setCurrentAnimation("walk");
|
||||||
player_sprite_->setAnimationSpeed(5);
|
|
||||||
player_sprite_->setAccelY(0.2f);
|
|
||||||
player_sprite_->setVelY(-6.6f);
|
|
||||||
playSound("voice_thankyou.wav");
|
playSound("voice_thankyou.wav");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,6 +78,8 @@ Game::Game(int player_id, int current_stage, bool demo)
|
|||||||
|
|
||||||
background_->setPos(param.game.play_area.rect);
|
background_->setPos(param.game.play_area.rect);
|
||||||
|
|
||||||
|
balloon_manager_->setBouncingSounds(param.balloon.bouncing_sound);
|
||||||
|
|
||||||
SDL_SetTextureBlendMode(canvas_, SDL_BLENDMODE_BLEND);
|
SDL_SetTextureBlendMode(canvas_, SDL_BLENDMODE_BLEND);
|
||||||
|
|
||||||
// Inicializa el resto de variables
|
// Inicializa el resto de variables
|
||||||
@@ -320,7 +322,7 @@ void Game::updateGameStateGameOver()
|
|||||||
{
|
{
|
||||||
createMessage({paths_.at(2), paths_.at(3)}, Resource::get()->getTexture("game_text_game_over"));
|
createMessage({paths_.at(2), paths_.at(3)}, Resource::get()->getTexture("game_text_game_over"));
|
||||||
Audio::get()->fadeOutMusic(1000);
|
Audio::get()->fadeOutMusic(1000);
|
||||||
balloon_manager_->setSounds(true);
|
balloon_manager_->setBouncingSounds(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
game_over_counter_--;
|
game_over_counter_--;
|
||||||
@@ -607,7 +609,6 @@ void Game::checkBulletCollision()
|
|||||||
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());
|
||||||
playSound("item_drop.wav");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -617,7 +618,6 @@ void Game::checkBulletCollision()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Explota el globo
|
// Explota el globo
|
||||||
const auto SIZE = balloon->getSize();
|
|
||||||
const auto SCORE = balloon_manager_->popBalloon(balloon);
|
const auto SCORE = balloon_manager_->popBalloon(balloon);
|
||||||
evaluateAndSetMenace();
|
evaluateAndSetMenace();
|
||||||
|
|
||||||
@@ -629,26 +629,6 @@ void Game::checkBulletCollision()
|
|||||||
}
|
}
|
||||||
updateHiScore();
|
updateHiScore();
|
||||||
|
|
||||||
// Sonido de explosión
|
|
||||||
switch (SIZE)
|
|
||||||
{
|
|
||||||
case BalloonSize::SIZE1:
|
|
||||||
playSound("balloon1.wav");
|
|
||||||
break;
|
|
||||||
case BalloonSize::SIZE2:
|
|
||||||
playSound("balloon2.wav");
|
|
||||||
break;
|
|
||||||
case BalloonSize::SIZE3:
|
|
||||||
playSound("balloon3.wav");
|
|
||||||
break;
|
|
||||||
case BalloonSize::SIZE4:
|
|
||||||
playSound("balloon4.wav");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
playSound("balloon1.wav");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deshabilita la bala
|
// Deshabilita la bala
|
||||||
bullet->disable();
|
bullet->disable();
|
||||||
|
|
||||||
@@ -789,6 +769,7 @@ ItemType Game::dropItem()
|
|||||||
void Game::createItem(ItemType type, float x, float y)
|
void Game::createItem(ItemType type, float x, float y)
|
||||||
{
|
{
|
||||||
items_.emplace_back(std::make_unique<Item>(type, x, y, param.game.play_area.rect, item_textures_[static_cast<int>(type) - 1], item_animations_[static_cast<int>(type) - 1]));
|
items_.emplace_back(std::make_unique<Item>(type, x, y, param.game.play_area.rect, item_textures_[static_cast<int>(type) - 1], item_animations_[static_cast<int>(type) - 1]));
|
||||||
|
playSound("item_drop.wav");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vacia el vector de items
|
// Vacia el vector de items
|
||||||
@@ -935,8 +916,11 @@ void Game::handlePlayerCollision(std::shared_ptr<Player> &player)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Si no tiene cafes, muere
|
// Si no tiene cafes, muere
|
||||||
balloon_manager_->stopAllBalloons();
|
|
||||||
playSound("player_collision.wav");
|
playSound("player_collision.wav");
|
||||||
|
if (param.game.hit_stop)
|
||||||
|
{
|
||||||
|
SDL_Delay(param.game.hit_stop_ms);
|
||||||
|
}
|
||||||
screen_->shake();
|
screen_->shake();
|
||||||
playSound("voice_no.wav");
|
playSound("voice_no.wav");
|
||||||
player->setPlayingState(PlayerState::ROLLING);
|
player->setPlayingState(PlayerState::ROLLING);
|
||||||
@@ -1066,13 +1050,13 @@ void Game::fillCanvas()
|
|||||||
|
|
||||||
// Dibuja los objetos
|
// Dibuja los objetos
|
||||||
background_->render();
|
background_->render();
|
||||||
renderItems();
|
renderPlayers();
|
||||||
renderSmartSprites();
|
renderSmartSprites();
|
||||||
|
renderItems();
|
||||||
balloon_manager_->render();
|
balloon_manager_->render();
|
||||||
tabe_->render();
|
tabe_->render();
|
||||||
renderBullets();
|
renderBullets();
|
||||||
renderPathSprites();
|
renderPathSprites();
|
||||||
renderPlayers();
|
|
||||||
|
|
||||||
// Deja el renderizador apuntando donde estaba
|
// Deja el renderizador apuntando donde estaba
|
||||||
SDL_SetRenderTarget(renderer_, temp);
|
SDL_SetRenderTarget(renderer_, temp);
|
||||||
@@ -1719,6 +1703,9 @@ void Game::initDemo(int player_id)
|
|||||||
// Configura los marcadores
|
// Configura los marcadores
|
||||||
scoreboard_->setMode(SCOREBOARD_LEFT_PANEL, ScoreboardMode::DEMO);
|
scoreboard_->setMode(SCOREBOARD_LEFT_PANEL, ScoreboardMode::DEMO);
|
||||||
scoreboard_->setMode(SCOREBOARD_RIGHT_PANEL, ScoreboardMode::DEMO);
|
scoreboard_->setMode(SCOREBOARD_RIGHT_PANEL, ScoreboardMode::DEMO);
|
||||||
|
|
||||||
|
// Silencia los globos
|
||||||
|
balloon_manager_->setSounds(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Modo grabar demo
|
// Modo grabar demo
|
||||||
|
|||||||
@@ -90,9 +90,9 @@ void Title::render()
|
|||||||
|
|
||||||
tiled_bg_->render();
|
tiled_bg_->render();
|
||||||
game_logo_->render();
|
game_logo_->render();
|
||||||
|
renderPlayers();
|
||||||
renderStartPrompt();
|
renderStartPrompt();
|
||||||
renderCopyright();
|
renderCopyright();
|
||||||
renderPlayers();
|
|
||||||
|
|
||||||
define_buttons_->render();
|
define_buttons_->render();
|
||||||
fade_->render();
|
fade_->render();
|
||||||
@@ -463,12 +463,13 @@ void Title::initPlayers()
|
|||||||
|
|
||||||
// Crea los dos jugadores
|
// Crea los dos jugadores
|
||||||
constexpr int PLAYER_WIDTH = 32;
|
constexpr int PLAYER_WIDTH = 32;
|
||||||
const int Y = param.title.press_start_position;
|
constexpr int PLAYER_HEIGHT = 32;
|
||||||
|
const int Y = param.title.press_start_position - (PLAYER_HEIGHT / 2);
|
||||||
constexpr bool DEMO = false;
|
constexpr bool DEMO = false;
|
||||||
players_.emplace_back(std::make_unique<Player>(1, param.game.game_area.first_quarter_x - (PLAYER_WIDTH / 2), Y, DEMO, param.game.play_area.rect, player_textures.at(0), player_animations));
|
players_.emplace_back(std::make_unique<Player>(1, param.game.game_area.center_x - (PLAYER_WIDTH / 2), Y, DEMO, param.game.play_area.rect, player_textures.at(0), player_animations));
|
||||||
players_.back()->setPlayingState(PlayerState::TITLE_HIDDEN);
|
players_.back()->setPlayingState(PlayerState::TITLE_HIDDEN);
|
||||||
|
|
||||||
players_.emplace_back(std::make_unique<Player>(2, param.game.game_area.third_quarter_x - (PLAYER_WIDTH / 2), Y, DEMO, param.game.play_area.rect, player_textures.at(1), player_animations));
|
players_.emplace_back(std::make_unique<Player>(2, param.game.game_area.center_x - (PLAYER_WIDTH / 2), Y, DEMO, param.game.play_area.rect, player_textures.at(1), player_animations));
|
||||||
players_.back()->setPlayingState(PlayerState::TITLE_HIDDEN);
|
players_.back()->setPlayingState(PlayerState::TITLE_HIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user