Compare commits

..

3 Commits

Author SHA1 Message Date
1d3b016b85 modificada la animació del titol per començar a jugar 2025-07-14 17:17:49 +02:00
72d2525e61 els jugadors ara es dibuixen al fondo de la resta de elements
modificat la veu de 'thankyou' per a que incloga el sonido de començar a jugar clasic
els globos ja son ells qui fan el seu propi so
2025-07-14 16:43:15 +02:00
6bc5cf1e93 recuperat el hit_stop al ser colpejat per un globo (modificable al fitxer de parametres) 2025-07-14 15:34:26 +02:00
13 changed files with 198 additions and 108 deletions

View File

@@ -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.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.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.color 1F2B30 # Color hexadecimal para el efecto de fundido
@@ -57,6 +59,8 @@ balloon.color[1] orange # Color del globo normal
balloon.color[2] red # Color de creación 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.pos_v TOP # Posición vertical de la notificación (TOP/BOTTOM)
notification.pos_h LEFT # Posición horizontal de la notificación (LEFT/RIGHT)

View File

@@ -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.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.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.color 1F2B30 # Color hexadecimal para el efecto de fundido
@@ -57,6 +59,8 @@ balloon.color[1] orange # Color del globo normal
balloon.color[2] red # Color de creación 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.pos_v TOP # Posición vertical de la notificación (TOP/BOTTOM)
notification.pos_h LEFT # Posición horizontal de la notificación (LEFT/RIGHT)

Binary file not shown.

View File

@@ -38,7 +38,8 @@ Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel
power_ = BALLOON_POWER[index];
menace_ = BALLOON_MENACE[index];
score_ = BALLOON_SCORE[index];
sound_ = BALLOON_SOUND[index];
bouncing_sound_ = BALLOON_BOUNCING_SOUND[index];
popping_sound_ = BALLOON_POPPING_SOUND[index];
break;
}
@@ -53,7 +54,8 @@ Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel
power_ = BALLOON_POWER[index];
menace_ = BALLOON_MENACE[index];
score_ = BALLOON_SCORE[index];
sound_ = BALLOON_SOUND[index];
bouncing_sound_ = BALLOON_BOUNCING_SOUND[index];
popping_sound_ = BALLOON_POPPING_SOUND[index];
break;
}
@@ -62,7 +64,7 @@ Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel
{
constexpr int index = 3;
h_ = w_ = BALLOON_SIZE[4];
sound_ = BALLOON_SOUND[3];
bouncing_sound_ = BALLOON_BOUNCING_SOUND[3];
power_ = score_ = menace_ = 0;
vy_ = 0;
@@ -162,7 +164,8 @@ void Balloon::move()
const float max_x = play_area_.x + play_area_.w - w_ + clip;
if (x_ < min_x || x_ > max_x)
{
playSound();
if (bouncing_sound_enabled_)
playSound(bouncing_sound_);
x_ = std::clamp(x_, min_x, max_x);
vx_ = -vx_;
// Activa el efecto de rebote o invierte la rotación
@@ -185,7 +188,8 @@ void Balloon::move()
const int min_y = play_area_.y;
if (y_ < min_y)
{
playSound();
if (bouncing_sound_enabled_)
playSound(bouncing_sound_);
y_ = min_y;
vy_ = -vy_;
enableBounce();
@@ -196,7 +200,8 @@ void Balloon::move()
const int max_y = play_area_.y + play_area_.h - h_;
if (y_ > max_y)
{
playSound();
if (bouncing_sound_enabled_)
playSound(bouncing_sound_);
y_ = max_y;
vy_ = -default_vy_;
if (type_ != BalloonType::POWERBALL)
@@ -409,11 +414,24 @@ void Balloon::useNormalColor()
setAnimation();
}
// Reproduce el sonido al rebotar
void Balloon::playSound()
// Reproduce sonido
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)
{
Audio::get()->playSound(sound_);
if (should_sound)
{
if (poping_sound_enabled_)
playSound(popping_sound_);
}
enabled_ = false;
}

View File

@@ -17,7 +17,8 @@ constexpr int BALLOON_SCORE[] = {50, 100, 200, 400};
constexpr int BALLOON_POWER[] = {1, 3, 7, 15};
constexpr int BALLOON_MENACE[] = {1, 2, 4, 8};
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
{
@@ -71,6 +72,7 @@ public:
void update(); // Actualiza el globo (posición, animación, contadores)
void stop(); // Detiene el globo
void start(); // Pone el globo en movimiento
void pop(bool should_sound = false); // Explota el globo
// --- Métodos de color ---
void useReverseColor(); // Pone el color alternativo en el globo
@@ -99,8 +101,9 @@ public:
void setVelY(float vel_y) { vy_ = vel_y; }
void setSpeed(float speed) { speed_ = speed; }
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 disable() { enabled_ = false; }
private:
// --- Estructura para el efecto de rebote ---
@@ -158,8 +161,11 @@ private:
float speed_; // Velocidad del globo
Uint8 power_; // Poder que alberga el globo
SDL_FRect play_area_; // Zona de movimiento del globo
std::string sound_; // Archivo de sonido al rebotar
bool sound_enabled_ = false; // Si debe sonar el globo al rebotar
std::string bouncing_sound_; // Archivo de sonido 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 ---
void shiftColliders(); // Alinea el círculo de colisión
@@ -170,5 +176,5 @@ private:
void updateBounce(); // Aplica el efecto de rebote
void updateState(); // Actualiza los estados del globo
void setAnimation(); // Establece la animación correspondiente
void playSound(); // Reproduce el sonido al rebotar
void playSound(const std::string &name); // Reproduce sonido
};

View File

@@ -180,8 +180,11 @@ std::shared_ptr<Balloon> BalloonManager::createBalloon(float x, int y, BalloonTy
{
if (can_deploy_balloons_)
{
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)));
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_.back()->setSound(sound_enabled_);
balloons_.back()->setBouncingSound(bouncing_sound_enabled_);
balloons_.back()->setPoppingSound(poping_sound_enabled_);
return balloons_.back();
}
@@ -268,7 +271,7 @@ int BalloonManager::popBalloon(std::shared_ptr<Balloon> balloon)
// Agrega la explosión y elimina el globo
explosions_->add(balloon->getPosX(), balloon->getPosY(), static_cast<int>(balloon->getSize()));
balloon->disable();
balloon->pop(true);
}
return score;
@@ -304,7 +307,7 @@ int BalloonManager::destroyBalloon(std::shared_ptr<Balloon> &balloon)
// Destruye el globo
explosions_->add(balloon->getPosX(), balloon->getPosY(), static_cast<int>(balloon->getSize()));
balloon->disable();
balloon->pop();
return score;
}
@@ -398,8 +401,28 @@ int BalloonManager::getMenace()
// Establece el sonido de los globos
void BalloonManager::setSounds(bool value)
{
sound_enabled_ = value;
for (auto &balloon : balloons_)
{
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);
}
}

View File

@@ -61,6 +61,8 @@ public:
// Configuración de sonido
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
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;
bool creation_time_enabled_ = 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();
};

View File

@@ -635,6 +635,7 @@ void Director::reset()
{
Resource::get()->reload();
}
Input::get()->discoverGameControllers();
ServiceMenu::get()->reset();
Section::name = Section::Name::LOGO;
}

View File

@@ -26,6 +26,8 @@ void initParam()
param.game.name_entry_idle_time = 10;
param.game.name_entry_total_time = 60;
param.game.speed = 15;
param.game.hit_stop = true;
param.game.hit_stop_ms = 300;
precalculateZones();
// SCOREBOARD
@@ -68,6 +70,8 @@ void initParam()
param.balloon.color.at(2) = "red";
param.balloon.color.at(3) = "green";
param.balloon.bouncing_sound = false;
// NOTIFICATION
param.notification.pos_v = NotifyPosition::TOP;
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);
}
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
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;
}
else if (var == "balloon.bouncing_sound")
{
param.balloon.bouncing_sound = stringToBool(value);
}
// NOTIFICACIONES
else if (var == "notification.pos_h")
{

View File

@@ -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_total_time; // Segundos totales para introducir el nombre al finalizar la partida
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 ---
@@ -61,6 +63,7 @@ struct ParamBalloon
std::array<Settings, 4> settings;
std::array<std::string, 4> color;
bool bouncing_sound; // Indica si los globos hacer sonido al rebotar
};
// --- Parámetros de las notificaciones ---

View File

@@ -219,7 +219,7 @@ void Player::move()
case PlayerState::TITLE_ANIMATION:
{
// 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 MAX_X = play_area_.x + play_area_.w;
if ((X < MIN_X) || (X > MAX_X))
@@ -229,6 +229,28 @@ void Player::move()
// Si el jugador toca el suelo rebota lo detiene
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);
}
@@ -263,12 +285,12 @@ void Player::move()
break;
}
pos_x_ += vel_x_;
const float min_x = -WIDTH_;
const float max_x = play_area_.w;
pos_x_ = std::clamp(pos_x_, min_x, max_x);
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)
if (pos_x_ == MIN_X || pos_x_ == MAX_X)
{
setPlayingState(PlayerState::GAME_OVER);
}
@@ -374,6 +396,7 @@ void Player::setAnimation()
case PlayerState::ENTERING_NAME_GAME_COMPLETED:
case PlayerState::ENTERING_SCREEN:
case PlayerState::LEAVING_SCREEN:
case PlayerState::TITLE_ANIMATION:
case PlayerState::CREDITS:
{
// Crea cadenas de texto para componer el nombre de la animación
@@ -418,7 +441,6 @@ void Player::setAnimation()
}
case PlayerState::ROLLING:
case PlayerState::CONTINUE_TIME_OUT:
case PlayerState::TITLE_ANIMATION:
{
player_sprite_->setCurrentAnimation("rolling");
break;
@@ -638,10 +660,7 @@ void Player::setPlayingState(PlayerState state)
case PlayerState::TITLE_ANIMATION:
{
// Activa la animación de rodar
player_sprite_->setCurrentAnimation("rolling");
player_sprite_->setAnimationSpeed(5);
player_sprite_->setAccelY(0.2f);
player_sprite_->setVelY(-6.6f);
player_sprite_->setCurrentAnimation("walk");
playSound("voice_thankyou.wav");
break;
}

View File

@@ -78,6 +78,8 @@ Game::Game(int player_id, int current_stage, bool demo)
background_->setPos(param.game.play_area.rect);
balloon_manager_->setBouncingSounds(param.balloon.bouncing_sound);
SDL_SetTextureBlendMode(canvas_, SDL_BLENDMODE_BLEND);
// 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"));
Audio::get()->fadeOutMusic(1000);
balloon_manager_->setSounds(true);
balloon_manager_->setBouncingSounds(true);
}
game_over_counter_--;
@@ -607,7 +609,6 @@ void Game::checkBulletCollision()
if (dropped_item != ItemType::COFFEE_MACHINE)
{
createItem(dropped_item, balloon->getPosX(), balloon->getPosY());
playSound("item_drop.wav");
}
else
{
@@ -617,7 +618,6 @@ void Game::checkBulletCollision()
}
// Explota el globo
const auto SIZE = balloon->getSize();
const auto SCORE = balloon_manager_->popBalloon(balloon);
evaluateAndSetMenace();
@@ -629,26 +629,6 @@ void Game::checkBulletCollision()
}
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
bullet->disable();
@@ -789,6 +769,7 @@ ItemType Game::dropItem()
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]));
playSound("item_drop.wav");
}
// Vacia el vector de items
@@ -935,8 +916,11 @@ void Game::handlePlayerCollision(std::shared_ptr<Player> &player)
else
{
// Si no tiene cafes, muere
balloon_manager_->stopAllBalloons();
playSound("player_collision.wav");
if (param.game.hit_stop)
{
SDL_Delay(param.game.hit_stop_ms);
}
screen_->shake();
playSound("voice_no.wav");
player->setPlayingState(PlayerState::ROLLING);
@@ -1066,13 +1050,13 @@ void Game::fillCanvas()
// Dibuja los objetos
background_->render();
renderItems();
renderPlayers();
renderSmartSprites();
renderItems();
balloon_manager_->render();
tabe_->render();
renderBullets();
renderPathSprites();
renderPlayers();
// Deja el renderizador apuntando donde estaba
SDL_SetRenderTarget(renderer_, temp);
@@ -1719,6 +1703,9 @@ void Game::initDemo(int player_id)
// Configura los marcadores
scoreboard_->setMode(SCOREBOARD_LEFT_PANEL, ScoreboardMode::DEMO);
scoreboard_->setMode(SCOREBOARD_RIGHT_PANEL, ScoreboardMode::DEMO);
// Silencia los globos
balloon_manager_->setSounds(false);
}
// Modo grabar demo

View File

@@ -90,9 +90,9 @@ void Title::render()
tiled_bg_->render();
game_logo_->render();
renderPlayers();
renderStartPrompt();
renderCopyright();
renderPlayers();
define_buttons_->render();
fade_->render();
@@ -463,12 +463,13 @@ void Title::initPlayers()
// Crea los dos jugadores
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;
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_.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);
}