Redissenyat el time stopper
This commit is contained in:
364
source/game.cpp
364
source/game.cpp
@@ -124,6 +124,7 @@ void Game::setResources()
|
||||
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_5000_points.png"));
|
||||
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_powerup.png"));
|
||||
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_one_hit.png"));
|
||||
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_stop.png"));
|
||||
}
|
||||
|
||||
// Texturas - Globos
|
||||
@@ -438,6 +439,20 @@ std::shared_ptr<Balloon> Game::createBalloon(float x, int y, BalloonType type, B
|
||||
return balloons_.back();
|
||||
}
|
||||
|
||||
// Crea un globo a partir de otro globo
|
||||
void Game::createChildBalloon(const std::shared_ptr<Balloon> &balloon, const std::string &direction)
|
||||
{
|
||||
const float vx = direction == "LEFT" ? BALLOON_VELX_NEGATIVE : BALLOON_VELX_POSITIVE;
|
||||
const auto lower_size = static_cast<BalloonSize>(static_cast<int>(balloon->getSize()) - 1);
|
||||
auto b = createBalloon(0, balloon->getPosY(), balloon->getType(), lower_size, vx, balloon_speed_, 0);
|
||||
b->alignTo(balloon->getPosX() + (balloon->getWidth() / 2));
|
||||
b->setVelY(b->getType() == BalloonType::BALLOON ? -2.50f : vx * 2.0f);
|
||||
if (balloon->isStopped())
|
||||
b->stop();
|
||||
if (balloon->isUsingReversedColor())
|
||||
b->useReverseColor();
|
||||
}
|
||||
|
||||
// Crea una PowerBall
|
||||
void Game::createPowerBall()
|
||||
{
|
||||
@@ -491,7 +506,6 @@ void Game::updateBalloonSpeed()
|
||||
// Explosiona un globo. Lo destruye y crea otros dos si es el caso
|
||||
void Game::popBalloon(std::shared_ptr<Balloon> balloon)
|
||||
{
|
||||
// Aumenta el poder de la fase
|
||||
increaseStageCurrentPower(1);
|
||||
balloons_popped_++;
|
||||
|
||||
@@ -503,29 +517,15 @@ void Game::popBalloon(std::shared_ptr<Balloon> balloon)
|
||||
}
|
||||
else
|
||||
{
|
||||
const int size = static_cast<int>(balloon->getSize());
|
||||
if (size == static_cast<int>(BalloonSize::SIZE1))
|
||||
if (balloon->getSize() != BalloonSize::SIZE1)
|
||||
{
|
||||
// Si es del tipo más pequeño, simplemente elimina el globo
|
||||
explosions_->add(balloon->getPosX(), balloon->getPosY(), size);
|
||||
balloon->pop();
|
||||
createChildBalloon(balloon, "LEFT");
|
||||
createChildBalloon(balloon, "RIGHT");
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto lower_size = static_cast<BalloonSize>(size - 1);
|
||||
// En cualquier otro caso, crea dos globos de un tipo inferior
|
||||
auto balloon_left = createBalloon(0, balloon->getPosY(), balloon->getType(), lower_size, BALLOON_VELX_NEGATIVE, balloon_speed_, 0);
|
||||
balloon_left->alignTo(balloon->getPosX() + (balloon->getWidth() / 2));
|
||||
balloon_left->setVelY(balloon_left->getType() == BalloonType::BALLOON ? -2.50f : BALLOON_VELX_NEGATIVE * 2.0f);
|
||||
|
||||
auto balloon_right = createBalloon(0, balloon->getPosY(), balloon->getType(), lower_size, BALLOON_VELX_POSITIVE, balloon_speed_, 0);
|
||||
balloon_right->alignTo(balloon->getPosX() + (balloon->getWidth() / 2));
|
||||
balloon_right->setVelY(balloon_right->getType() == BalloonType::BALLOON ? -2.50f : BALLOON_VELX_NEGATIVE * 2.0f);
|
||||
|
||||
// Elimina el globo
|
||||
explosions_->add(balloon->getPosX(), balloon->getPosY(), size);
|
||||
balloon->pop();
|
||||
}
|
||||
// Agrega la explosión y elimina el globo
|
||||
explosions_->add(balloon->getPosX(), balloon->getPosY(), static_cast<int>(balloon->getSize()));
|
||||
balloon->pop();
|
||||
}
|
||||
|
||||
// Recalcula el nivel de amenaza
|
||||
@@ -543,19 +543,15 @@ void Game::destroyBalloon(std::shared_ptr<Balloon> &balloon)
|
||||
case BalloonSize::SIZE4:
|
||||
score = BALLOON_SCORE[3] + (2 * BALLOON_SCORE[2]) + (4 * BALLOON_SCORE[1]) + (8 * BALLOON_SCORE[0]);
|
||||
break;
|
||||
|
||||
case BalloonSize::SIZE3:
|
||||
score = BALLOON_SCORE[2] + (2 * BALLOON_SCORE[1]) + (4 * BALLOON_SCORE[0]);
|
||||
break;
|
||||
|
||||
case BalloonSize::SIZE2:
|
||||
score = BALLOON_SCORE[1] + (2 * BALLOON_SCORE[0]);
|
||||
break;
|
||||
|
||||
case BalloonSize::SIZE1:
|
||||
score = BALLOON_SCORE[0];
|
||||
break;
|
||||
|
||||
default:
|
||||
score = 0;
|
||||
break;
|
||||
@@ -563,9 +559,7 @@ void Game::destroyBalloon(std::shared_ptr<Balloon> &balloon)
|
||||
|
||||
// Otorga los puntos correspondientes al globo
|
||||
for (auto &player : players_)
|
||||
{
|
||||
player->addScore(score * player->getScoreMultiplier() * difficulty_score_multiplier_);
|
||||
}
|
||||
updateHiScore();
|
||||
|
||||
// Aumenta el poder de la fase
|
||||
@@ -576,21 +570,14 @@ void Game::destroyBalloon(std::shared_ptr<Balloon> &balloon)
|
||||
// Destruye el globo
|
||||
explosions_->add(balloon->getPosX(), balloon->getPosY(), static_cast<int>(balloon->getSize()));
|
||||
balloon->pop();
|
||||
|
||||
// Recalcula el nivel de amenaza
|
||||
evaluateAndSetMenace();
|
||||
}
|
||||
|
||||
// Destruye todos los globos
|
||||
void Game::destroyAllBalloons()
|
||||
{
|
||||
for (auto &balloon : balloons_)
|
||||
{
|
||||
if (balloon->canBeDestroyed())
|
||||
{
|
||||
destroyBalloon(balloon);
|
||||
}
|
||||
}
|
||||
|
||||
balloon_deploy_counter_ = 300;
|
||||
JA_PlaySound(Resource::get()->getSound("powerball.wav"));
|
||||
@@ -599,29 +586,32 @@ void Game::destroyAllBalloons()
|
||||
}
|
||||
|
||||
// Detiene todos los globos
|
||||
void Game::stopAllBalloons(int time)
|
||||
void Game::stopAllBalloons()
|
||||
{
|
||||
for (auto &balloon : balloons_)
|
||||
{
|
||||
if (balloon->isEnabled())
|
||||
{
|
||||
balloon->setStop(true);
|
||||
balloon->setStoppedTimer(time);
|
||||
}
|
||||
}
|
||||
balloon->stop();
|
||||
}
|
||||
|
||||
// Pone en marcha todos los globos
|
||||
void Game::startAllBalloons()
|
||||
{
|
||||
for (auto &balloon : balloons_)
|
||||
{
|
||||
if ((balloon->isEnabled()) && (!balloon->isBeingCreated()))
|
||||
{
|
||||
balloon->setStop(false);
|
||||
balloon->setStoppedTimer(0);
|
||||
}
|
||||
}
|
||||
if (!balloon->isBeingCreated())
|
||||
balloon->start();
|
||||
}
|
||||
|
||||
// Cambia el color de todos los globos
|
||||
void Game::reverseColorsToAllBalloons()
|
||||
{
|
||||
for (auto &balloon : balloons_)
|
||||
balloon->useReverseColor();
|
||||
}
|
||||
|
||||
// Cambia el color de todos los globos
|
||||
void Game::normalColorsToAllBalloons()
|
||||
{
|
||||
for (auto &balloon : balloons_)
|
||||
balloon->useNormalColor();
|
||||
}
|
||||
|
||||
// Vacia del vector de globos los globos que ya no sirven
|
||||
@@ -637,15 +627,9 @@ void Game::freeBalloons()
|
||||
bool Game::checkPlayerBalloonCollision(std::shared_ptr<Player> &player)
|
||||
{
|
||||
for (auto &balloon : balloons_)
|
||||
{
|
||||
if ((balloon->isEnabled()) && !(balloon->isStopped()) && !(balloon->isInvulnerable()))
|
||||
{
|
||||
if (checkCollision(player->getCollider(), balloon->getCollider()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -654,9 +638,7 @@ bool Game::checkPlayerBalloonCollision(std::shared_ptr<Player> &player)
|
||||
void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
|
||||
{
|
||||
if (!player->isPlaying())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto &item : items_)
|
||||
{
|
||||
@@ -672,27 +654,24 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
|
||||
createItemScoreSprite(item->getPosX() + (item->getWidth() / 2) - (game_text_textures_[0]->getWidth() / 2), player->getPosY(), game_text_textures_[0]);
|
||||
break;
|
||||
}
|
||||
|
||||
case ItemType::GAVINA:
|
||||
{
|
||||
player->addScore(2500);
|
||||
createItemScoreSprite(item->getPosX() + (item->getWidth() / 2) - (game_text_textures_[1]->getWidth() / 2), player->getPosY(), game_text_textures_[1]);
|
||||
break;
|
||||
}
|
||||
|
||||
case ItemType::PACMAR:
|
||||
{
|
||||
player->addScore(5000);
|
||||
createItemScoreSprite(item->getPosX() + (item->getWidth() / 2) - (game_text_textures_[2]->getWidth() / 2), player->getPosY(), game_text_textures_[2]);
|
||||
break;
|
||||
}
|
||||
|
||||
case ItemType::CLOCK:
|
||||
{
|
||||
enableTimeStopItem();
|
||||
createItemScoreSprite(item->getPosX() + (item->getWidth() / 2) - (game_text_textures_[5]->getWidth() / 2), player->getPosY(), game_text_textures_[5]);
|
||||
break;
|
||||
}
|
||||
|
||||
case ItemType::COFFEE:
|
||||
{
|
||||
if (player->getCoffees() == 2)
|
||||
@@ -707,7 +686,6 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ItemType::COFFEE_MACHINE:
|
||||
{
|
||||
player->setPowerUp();
|
||||
@@ -715,7 +693,6 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
|
||||
createItemScoreSprite(item->getPosX() + (item->getWidth() / 2) - (game_text_textures_[3]->getWidth() / 2), player->getPosY(), game_text_textures_[3]);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -785,27 +762,15 @@ void Game::checkBulletBalloonCollision()
|
||||
void Game::moveBullets()
|
||||
{
|
||||
for (auto &bullet : bullets_)
|
||||
{
|
||||
if (bullet->isEnabled())
|
||||
{
|
||||
if (bullet->move() == BulletMoveStatus::OUT)
|
||||
{
|
||||
getPlayer(bullet->getOwner())->decScoreMultiplier();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bullet->move() == BulletMoveStatus::OUT)
|
||||
getPlayer(bullet->getOwner())->decScoreMultiplier();
|
||||
}
|
||||
|
||||
// Pinta las balas activas
|
||||
void Game::renderBullets()
|
||||
{
|
||||
for (auto &bullet : bullets_)
|
||||
{
|
||||
if (bullet->isEnabled())
|
||||
{
|
||||
bullet->render();
|
||||
}
|
||||
}
|
||||
bullet->render();
|
||||
}
|
||||
|
||||
// Crea un objeto bala
|
||||
@@ -818,22 +783,15 @@ void Game::createBullet(int x, int y, BulletType kind, bool powered_up, int owne
|
||||
void Game::freeBullets()
|
||||
{
|
||||
if (!bullets_.empty())
|
||||
{
|
||||
for (int i = bullets_.size() - 1; i >= 0; --i)
|
||||
{
|
||||
if (!bullets_[i]->isEnabled())
|
||||
{
|
||||
bullets_.erase(bullets_.begin() + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza los items
|
||||
void Game::updateItems()
|
||||
{
|
||||
for (auto &item : items_)
|
||||
{
|
||||
if (item->isEnabled())
|
||||
{
|
||||
item->update();
|
||||
@@ -843,16 +801,13 @@ void Game::updateItems()
|
||||
screen_->shake();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Pinta los items activos
|
||||
void Game::renderItems()
|
||||
{
|
||||
for (auto &item : items_)
|
||||
{
|
||||
item->render();
|
||||
}
|
||||
}
|
||||
|
||||
// Devuelve un item al azar y luego segun sus probabilidades
|
||||
@@ -869,28 +824,24 @@ ItemType Game::dropItem()
|
||||
return ItemType::DISK;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (lucky_number < helper_.item_gavina_odds)
|
||||
{
|
||||
return ItemType::GAVINA;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (lucky_number < helper_.item_pacmar_odds)
|
||||
{
|
||||
return ItemType::GAVINA;
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if (lucky_number < helper_.item_clock_odds)
|
||||
{
|
||||
return ItemType::CLOCK;
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if (lucky_number < helper_.item_coffee_odds)
|
||||
{
|
||||
@@ -900,30 +851,22 @@ ItemType Game::dropItem()
|
||||
else
|
||||
{
|
||||
if (helper_.need_coffee)
|
||||
{
|
||||
helper_.item_coffee_odds++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 5:
|
||||
if (lucky_number < helper_.item_coffee_machine_odds)
|
||||
{
|
||||
helper_.item_coffee_machine_odds = ITEM_COFFEE_MACHINE_ODDS_;
|
||||
if (!coffee_machine_enabled_ && helper_.need_coffee_machine)
|
||||
{
|
||||
return ItemType::COFFEE_MACHINE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (helper_.need_coffee_machine)
|
||||
{
|
||||
helper_.item_coffee_machine_odds++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -941,15 +884,9 @@ void Game::createItem(ItemType type, float x, float y)
|
||||
void Game::freeItems()
|
||||
{
|
||||
if (!items_.empty())
|
||||
{
|
||||
for (int i = items_.size() - 1; i >= 0; --i)
|
||||
{
|
||||
if (!items_[i]->isEnabled())
|
||||
{
|
||||
items_.erase(items_.begin() + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Crea un objeto SpriteSmart para mostrar la puntuación al coger un objeto
|
||||
@@ -980,15 +917,9 @@ void Game::createItemScoreSprite(int x, int y, std::shared_ptr<Texture> texture)
|
||||
void Game::freeSpriteSmarts()
|
||||
{
|
||||
if (!smart_sprites_.empty())
|
||||
{
|
||||
for (int i = smart_sprites_.size() - 1; i >= 0; --i)
|
||||
{
|
||||
if (smart_sprites_[i]->hasFinished())
|
||||
{
|
||||
smart_sprites_.erase(smart_sprites_.begin() + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Crea un SpriteSmart para arrojar el item café al recibir un impacto
|
||||
@@ -1018,18 +949,14 @@ void Game::throwCoffee(int x, int y)
|
||||
void Game::updateSpriteSmarts()
|
||||
{
|
||||
for (auto &ss : smart_sprites_)
|
||||
{
|
||||
ss->update();
|
||||
}
|
||||
}
|
||||
|
||||
// Pinta los SpriteSmarts activos
|
||||
void Game::renderSpriteSmarts()
|
||||
{
|
||||
for (auto &ss : smart_sprites_)
|
||||
{
|
||||
ss->render();
|
||||
}
|
||||
}
|
||||
|
||||
// Acciones a realizar cuando el jugador muere
|
||||
@@ -1052,20 +979,13 @@ void Game::killPlayer(std::shared_ptr<Player> &player)
|
||||
else
|
||||
{
|
||||
// Si no tiene cafes, muere
|
||||
if (!demo_.enabled)
|
||||
{
|
||||
JA_PauseMusic();
|
||||
}
|
||||
stopAllBalloons(10);
|
||||
pauseMusic();
|
||||
stopAllBalloons();
|
||||
JA_PlaySound(Resource::get()->getSound("player_collision.wav"));
|
||||
screen_->shake();
|
||||
JA_PlaySound(Resource::get()->getSound("coffeeout.wav"));
|
||||
player->setStatusPlaying(PlayerStatus::DYING);
|
||||
if (!demo_.enabled)
|
||||
{
|
||||
// En el modo DEMO ni se para la musica ni se añade la puntuación a la tabla
|
||||
allPlayersAreNotPlaying() ? JA_StopMusic() : JA_ResumeMusic();
|
||||
}
|
||||
allPlayersAreNotPlaying() ? stopMusic() : resumeMusic();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1076,60 +996,36 @@ void Game::evaluateAndSetMenace()
|
||||
{ return sum + (balloon->isEnabled() ? balloon->getMenace() : 0); });
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int Game::getMenace() const
|
||||
{
|
||||
return menace_current_;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Game::setTimeStopped(bool value)
|
||||
{
|
||||
time_stopped_ = value;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool Game::isTimeStopped() const
|
||||
{
|
||||
return time_stopped_;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Game::setTimeStoppedCounter(int value)
|
||||
{
|
||||
time_stopped_counter_ = value;
|
||||
}
|
||||
|
||||
// Incrementa el valor de la variable
|
||||
void Game::incTimeStoppedCounter(int value)
|
||||
{
|
||||
time_stopped_counter_ += value;
|
||||
}
|
||||
|
||||
// Actualiza y comprueba el valor de la variable
|
||||
void Game::updateTimeStoppedCounter()
|
||||
void Game::updateTimeStopped()
|
||||
{
|
||||
if (isTimeStopped())
|
||||
if (time_stopped_counter_ > 0)
|
||||
{
|
||||
if (time_stopped_counter_ > 0)
|
||||
time_stopped_counter_--;
|
||||
if (time_stopped_counter_ > 120)
|
||||
{
|
||||
time_stopped_counter_--;
|
||||
stopAllBalloons(TIME_STOPPED_COUNTER_);
|
||||
if (time_stopped_counter_ % 30 == 0)
|
||||
JA_PlaySound(Resource::get()->getSound("clock.wav"));
|
||||
}
|
||||
else
|
||||
{
|
||||
disableTimeStopItem();
|
||||
if (time_stopped_counter_ % 15 == 0)
|
||||
JA_PlaySound(Resource::get()->getSound("clock.wav"));
|
||||
if (time_stopped_counter_ % 30 == 0)
|
||||
normalColorsToAllBalloons();
|
||||
if (time_stopped_counter_ % 30 == 15)
|
||||
reverseColorsToAllBalloons();
|
||||
}
|
||||
}
|
||||
else
|
||||
disableTimeStopItem();
|
||||
}
|
||||
|
||||
// Actualiza la variable enemyDeployCounter
|
||||
void Game::updateBalloonDeployCounter()
|
||||
{
|
||||
if (balloon_deploy_counter_ > 0)
|
||||
{
|
||||
--balloon_deploy_counter_;
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza el juego
|
||||
@@ -1149,9 +1045,7 @@ void Game::update()
|
||||
{
|
||||
// Incrementa el contador de la demo
|
||||
if (demo_.counter < TOTAL_DEMO_DATA)
|
||||
{
|
||||
demo_.counter++;
|
||||
}
|
||||
|
||||
// Activa el fundido antes de acabar con los datos de la demo
|
||||
if (demo_.counter == TOTAL_DEMO_DATA - 200)
|
||||
@@ -1174,9 +1068,7 @@ void Game::update()
|
||||
|
||||
// Incrementa el contador de la demo
|
||||
if (demo_.counter < TOTAL_DEMO_DATA)
|
||||
{
|
||||
demo_.counter++;
|
||||
}
|
||||
|
||||
// Si se ha llenado el vector con datos, sale del programa
|
||||
else
|
||||
@@ -1229,7 +1121,7 @@ void Game::update()
|
||||
updateSpriteSmarts();
|
||||
|
||||
// Actualiza los contadores de estado y efectos
|
||||
updateTimeStoppedCounter();
|
||||
updateTimeStopped();
|
||||
updateBalloonDeployCounter();
|
||||
|
||||
// Actualiza el ayudante
|
||||
@@ -1273,9 +1165,7 @@ void Game::updateBackground()
|
||||
{
|
||||
// Si el juego está completado, se reduce la velocidad de las nubes
|
||||
if (game_completed_)
|
||||
{
|
||||
balloons_popped_ = (balloons_popped_ > 400) ? (balloons_popped_ - 25) : 200;
|
||||
}
|
||||
|
||||
// Calcula la velocidad en función de los globos explotados y el total de globos a explotar para acabar el juego
|
||||
constexpr auto clouds_initial_speed = 0.05f;
|
||||
@@ -1337,9 +1227,7 @@ void Game::render()
|
||||
void Game::updateMenace()
|
||||
{
|
||||
if (game_completed_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const auto stage = balloon_formations_->getStage(current_stage_);
|
||||
const float percent = current_power_ / stage.power_to_complete;
|
||||
@@ -1364,33 +1252,7 @@ void Game::renderMessages()
|
||||
{
|
||||
// GetReady
|
||||
if (counter_ < STAGE_COUNTER_ && !demo_.enabled)
|
||||
{
|
||||
text_nokia2_big_->write((int)get_ready_bitmap_path_[counter_], param.game.play_area.center_y - 8, lang::getText(75), -2);
|
||||
}
|
||||
|
||||
// Time Stopped
|
||||
if (time_stopped_)
|
||||
{
|
||||
if (time_stopped_counter_ > 100 || time_stopped_counter_ % 10 > 4)
|
||||
{
|
||||
text_nokia2_->writeDX(TEXT_CENTER, param.game.play_area.center_x, param.game.play_area.first_quarter_y, lang::getText(36) + std::to_string(time_stopped_counter_ / 10), -1, no_color, 1, shdw_txt_color);
|
||||
}
|
||||
|
||||
if (time_stopped_counter_ > 100)
|
||||
{
|
||||
if (time_stopped_counter_ % 30 == 0)
|
||||
{
|
||||
JA_PlaySound(Resource::get()->getSound("clock.wav"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (time_stopped_counter_ % 15 == 0)
|
||||
{
|
||||
JA_PlaySound(Resource::get()->getSound("clock.wav"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// STAGE NUMBER
|
||||
if (stage_bitmap_counter_ < STAGE_COUNTER_)
|
||||
@@ -1399,20 +1261,24 @@ void Game::renderMessages()
|
||||
std::string text;
|
||||
|
||||
if (stage_number == 10)
|
||||
{ // Ultima fase
|
||||
{
|
||||
// Ultima fase
|
||||
text = lang::getText(79);
|
||||
}
|
||||
else
|
||||
{ // X fases restantes
|
||||
{
|
||||
// X fases restantes
|
||||
text = std::to_string(11 - stage_number) + lang::getText(38);
|
||||
}
|
||||
|
||||
if (!game_completed_)
|
||||
{ // Escribe el número de fases restantes
|
||||
{
|
||||
// Escribe el número de fases restantes
|
||||
text_nokia2_big_->writeDX(TEXT_CENTER, param.game.play_area.center_x, stage_bitmap_path_[stage_bitmap_counter_], text, -2, no_color, 2, shdw_txt_color);
|
||||
}
|
||||
else
|
||||
{ // Escribe el texto de juego completado
|
||||
{
|
||||
// Escribe el texto de juego completado
|
||||
text = lang::getText(50);
|
||||
text_nokia2_big_->writeDX(TEXT_CENTER, param.game.play_area.center_x, stage_bitmap_path_[stage_bitmap_counter_], text, -2, no_color, 1, shdw_txt_color);
|
||||
text_nokia2_->writeDX(TEXT_CENTER, param.game.play_area.center_x, stage_bitmap_path_[stage_bitmap_counter_] + text_nokia2_big_->getCharacterSize() + 2, lang::getText(76), -1, no_color, 1, shdw_txt_color);
|
||||
@@ -1423,25 +1289,17 @@ void Game::renderMessages()
|
||||
// Habilita el efecto del item de detener el tiempo
|
||||
void Game::enableTimeStopItem()
|
||||
{
|
||||
stopAllBalloons(TIME_STOPPED_COUNTER_);
|
||||
setTimeStopped(true);
|
||||
incTimeStoppedCounter(TIME_STOPPED_COUNTER_);
|
||||
if (JA_GetMusicState() == JA_MUSIC_PLAYING && !demo_.enabled)
|
||||
{
|
||||
JA_PauseMusic();
|
||||
}
|
||||
stopAllBalloons();
|
||||
reverseColorsToAllBalloons();
|
||||
time_stopped_counter_ = TIME_STOPPED_COUNTER_;
|
||||
}
|
||||
|
||||
// Deshabilita el efecto del item de detener el tiempo
|
||||
void Game::disableTimeStopItem()
|
||||
{
|
||||
time_stopped_ = false;
|
||||
setTimeStoppedCounter(0);
|
||||
time_stopped_counter_ = 0;
|
||||
startAllBalloons();
|
||||
if (JA_GetMusicState() == JA_MUSIC_PAUSED && !demo_.enabled)
|
||||
{
|
||||
JA_ResumeMusic();
|
||||
}
|
||||
normalColorsToAllBalloons();
|
||||
}
|
||||
|
||||
// Comprueba si la música ha de estar sonando
|
||||
@@ -1449,10 +1307,8 @@ void Game::checkMusicStatus()
|
||||
{
|
||||
// Si la música no está sonando
|
||||
if (JA_GetMusicState() == JA_MUSIC_INVALID || JA_GetMusicState() == JA_MUSIC_STOPPED)
|
||||
{
|
||||
// Si se ha completado el juego o los jugadores han terminado, detiene la música
|
||||
game_completed_ || allPlayersAreGameOver() ? JA_StopMusic() : JA_PlayMusic(Resource::get()->getMusic("playing.ogg"));
|
||||
}
|
||||
}
|
||||
|
||||
// Bucle para el juego
|
||||
@@ -1491,9 +1347,7 @@ void Game::initPaths()
|
||||
// Vector con los valores del seno para 360 grados
|
||||
float sin[360];
|
||||
for (int i = 0; i < 360; ++i)
|
||||
{
|
||||
sin[i] = SDL_sinf((float)i * 3.14f / 180.0f);
|
||||
}
|
||||
|
||||
// Letrero de STAGE #
|
||||
constexpr auto first_part = STAGE_COUNTER_ / 4; // 50
|
||||
@@ -1508,9 +1362,7 @@ void Game::initPaths()
|
||||
}
|
||||
|
||||
for (int i = first_part; i < second_part; ++i)
|
||||
{
|
||||
stage_bitmap_path_[i] = center_point;
|
||||
}
|
||||
|
||||
for (int i = second_part; i < STAGE_COUNTER_; ++i)
|
||||
{
|
||||
@@ -1536,9 +1388,7 @@ void Game::initPaths()
|
||||
}
|
||||
|
||||
for (int i = first_part; i < second_part; ++i)
|
||||
{
|
||||
get_ready_bitmap_path_[i] = (int)finish1;
|
||||
}
|
||||
|
||||
for (int i = second_part; i < STAGE_COUNTER_; ++i)
|
||||
{
|
||||
@@ -1552,9 +1402,7 @@ void Game::initPaths()
|
||||
void Game::updateGameCompleted()
|
||||
{
|
||||
if (game_completed_)
|
||||
{
|
||||
game_completed_counter_++;
|
||||
}
|
||||
|
||||
if (game_completed_counter_ == GAME_COMPLETED_END_)
|
||||
{
|
||||
@@ -1581,9 +1429,7 @@ void Game::updateHelper()
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
helper_.need_coffee = helper_.need_coffee_machine = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba si todos los jugadores han terminado de jugar
|
||||
@@ -1591,9 +1437,7 @@ bool Game::allPlayersAreWaitingOrGameOver()
|
||||
{
|
||||
auto success = true;
|
||||
for (const auto &player : players_)
|
||||
{
|
||||
success &= player->isWaiting() || player->isGameOver();
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
@@ -1603,9 +1447,7 @@ bool Game::allPlayersAreGameOver()
|
||||
{
|
||||
auto success = true;
|
||||
for (const auto &player : players_)
|
||||
{
|
||||
success &= player->isGameOver();
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
@@ -1615,9 +1457,7 @@ bool Game::allPlayersAreNotPlaying()
|
||||
{
|
||||
auto success = true;
|
||||
for (const auto &player : players_)
|
||||
{
|
||||
success &= !player->isPlaying();
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
@@ -1642,10 +1482,7 @@ void Game::checkEvents()
|
||||
{
|
||||
case SDL_WINDOWEVENT_FOCUS_LOST:
|
||||
{
|
||||
if (!demo_.enabled)
|
||||
{
|
||||
pause(true);
|
||||
}
|
||||
pause(!demo_.enabled);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1654,13 +1491,11 @@ void Game::checkEvents()
|
||||
pause(false);
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||
{
|
||||
reloadTextures();
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -1671,28 +1506,27 @@ void Game::checkEvents()
|
||||
{
|
||||
switch (event.key.keysym.sym)
|
||||
{
|
||||
// Crea una powerball
|
||||
case SDLK_1:
|
||||
case SDLK_1: // Crea una powerball
|
||||
{
|
||||
createPowerBall();
|
||||
break;
|
||||
}
|
||||
|
||||
// Crea dos globos gordos
|
||||
case SDLK_2:
|
||||
case SDLK_2: // Crea dos globos gordos
|
||||
{
|
||||
createTwoBigBalloons();
|
||||
}
|
||||
break;
|
||||
|
||||
// Activa el modo para pasar el juego automaticamente
|
||||
case SDLK_3:
|
||||
case SDLK_3: // Activa el modo para pasar el juego automaticamente
|
||||
{
|
||||
auto_pop_balloons_ = !auto_pop_balloons_;
|
||||
Notifier::get()->showText("auto_pop_balloons_ " + boolToString(auto_pop_balloons_));
|
||||
break;
|
||||
}
|
||||
|
||||
case SDLK_4: // Suelta un item
|
||||
{
|
||||
createItem(ItemType::CLOCK, players_.at(0)->getPosX(), players_.at(0)->getPosY() - 40);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -1705,27 +1539,17 @@ void Game::checkEvents()
|
||||
void Game::reloadTextures()
|
||||
{
|
||||
for (auto &texture : item_textures_)
|
||||
{
|
||||
texture->reLoad();
|
||||
}
|
||||
|
||||
for (auto &texture : balloon_textures_)
|
||||
{
|
||||
texture->reLoad();
|
||||
}
|
||||
|
||||
for (auto &textures : player_textures_)
|
||||
{
|
||||
for (auto &texture : textures)
|
||||
{
|
||||
texture->reLoad();
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &texture : game_text_textures_)
|
||||
{
|
||||
texture->reLoad();
|
||||
}
|
||||
|
||||
bullet_texture_->reLoad();
|
||||
background_->reloadTextures();
|
||||
@@ -1881,7 +1705,6 @@ void Game::handleDemoMode()
|
||||
}
|
||||
|
||||
// Procesa las entradas para un jugador específico durante el modo demo.
|
||||
// Incluye movimientos (izquierda, derecha, sin movimiento) y disparos automáticos.
|
||||
void Game::handleDemoPlayerInput(const std::shared_ptr<Player> &player, int index)
|
||||
{
|
||||
const auto &demoData = demo_.data[index][demo_.counter];
|
||||
@@ -2202,4 +2025,25 @@ void Game::createTwoBigBalloons()
|
||||
auto p = set.init[i];
|
||||
createBalloon(p.x, p.y, p.type, p.size, p.vel_x, balloon_speed_, p.creation_counter);
|
||||
}
|
||||
}
|
||||
|
||||
// Pausa la música
|
||||
void Game::pauseMusic()
|
||||
{
|
||||
if (JA_GetMusicState() == JA_MUSIC_PLAYING && !demo_.enabled)
|
||||
JA_PauseMusic();
|
||||
}
|
||||
|
||||
// Reanuda la música
|
||||
void Game::resumeMusic()
|
||||
{
|
||||
if (JA_GetMusicState() == JA_MUSIC_PAUSED && !demo_.enabled)
|
||||
JA_ResumeMusic();
|
||||
}
|
||||
|
||||
// Detiene la música
|
||||
void Game::stopMusic()
|
||||
{
|
||||
if (!demo_.enabled)
|
||||
JA_StopMusic();
|
||||
}
|
||||
Reference in New Issue
Block a user