El malo nou ja suca cosetes, falta ajustar un poc els paràmetres
This commit is contained in:
@@ -140,6 +140,7 @@ void Game::setResources()
|
||||
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_powerup"));
|
||||
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_one_hit"));
|
||||
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_stop"));
|
||||
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_100000_points"));
|
||||
}
|
||||
|
||||
// Texturas - Items
|
||||
@@ -149,6 +150,7 @@ void Game::setResources()
|
||||
item_textures_.emplace_back(Resource::get()->getTexture("item_points3_pacmar.png"));
|
||||
item_textures_.emplace_back(Resource::get()->getTexture("item_clock.png"));
|
||||
item_textures_.emplace_back(Resource::get()->getTexture("item_coffee.png"));
|
||||
item_textures_.emplace_back(Resource::get()->getTexture("item_debian.png"));
|
||||
item_textures_.emplace_back(Resource::get()->getTexture("item_coffee_machine.png"));
|
||||
}
|
||||
|
||||
@@ -181,6 +183,7 @@ void Game::setResources()
|
||||
item_animations_.emplace_back(Resource::get()->getAnimation("item_points3_pacmar.ani"));
|
||||
item_animations_.emplace_back(Resource::get()->getAnimation("item_clock.ani"));
|
||||
item_animations_.emplace_back(Resource::get()->getAnimation("item_coffee.ani"));
|
||||
item_animations_.emplace_back(Resource::get()->getAnimation("item_debian.ani"));
|
||||
item_animations_.emplace_back(Resource::get()->getAnimation("item_coffee_machine.ani"));
|
||||
}
|
||||
}
|
||||
@@ -297,7 +300,7 @@ void Game::updateGameStateGameOver()
|
||||
updateSmartSprites();
|
||||
updatePathSprites();
|
||||
updateTimeStopped();
|
||||
checkBulletBalloonCollision();
|
||||
checkBulletCollision();
|
||||
cleanVectors();
|
||||
|
||||
if (game_over_counter_ > 0)
|
||||
@@ -462,37 +465,36 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
|
||||
case ItemType::DISK:
|
||||
{
|
||||
player->addScore(1000);
|
||||
const auto x =
|
||||
item->getPosX() +
|
||||
(item->getWidth() - game_text_textures_[0]->getWidth()) / 2;
|
||||
createItemText(x, game_text_textures_[0]);
|
||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(0)->getWidth()) / 2;
|
||||
createItemText(x, game_text_textures_.at(0));
|
||||
break;
|
||||
}
|
||||
case ItemType::GAVINA:
|
||||
{
|
||||
player->addScore(2500);
|
||||
const auto x =
|
||||
item->getPosX() +
|
||||
(item->getWidth() - game_text_textures_[1]->getWidth()) / 2;
|
||||
createItemText(x, game_text_textures_[1]);
|
||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(1)->getWidth()) / 2;
|
||||
createItemText(x, game_text_textures_.at(1));
|
||||
break;
|
||||
}
|
||||
case ItemType::PACMAR:
|
||||
{
|
||||
player->addScore(5000);
|
||||
const auto x =
|
||||
item->getPosX() +
|
||||
(item->getWidth() - game_text_textures_[2]->getWidth()) / 2;
|
||||
createItemText(x, game_text_textures_[2]);
|
||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(2)->getWidth()) / 2;
|
||||
createItemText(x, game_text_textures_.at(2));
|
||||
break;
|
||||
}
|
||||
case ItemType::DEBIAN:
|
||||
{
|
||||
player->addScore(100000);
|
||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(6)->getWidth()) / 2;
|
||||
createItemText(x, game_text_textures_.at(6));
|
||||
break;
|
||||
}
|
||||
case ItemType::CLOCK:
|
||||
{
|
||||
enableTimeStopItem();
|
||||
const auto x =
|
||||
item->getPosX() +
|
||||
(item->getWidth() - game_text_textures_[5]->getWidth()) / 2;
|
||||
createItemText(x, game_text_textures_[5]);
|
||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(5)->getWidth()) / 2;
|
||||
createItemText(x, game_text_textures_.at(5));
|
||||
break;
|
||||
}
|
||||
case ItemType::COFFEE:
|
||||
@@ -500,18 +502,14 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
|
||||
if (player->getCoffees() == 2)
|
||||
{
|
||||
player->addScore(5000);
|
||||
const auto x =
|
||||
item->getPosX() +
|
||||
(item->getWidth() - game_text_textures_[2]->getWidth()) / 2;
|
||||
createItemText(x, game_text_textures_[2]);
|
||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(2)->getWidth()) / 2;
|
||||
createItemText(x, game_text_textures_.at(2));
|
||||
}
|
||||
else
|
||||
{
|
||||
player->giveExtraHit();
|
||||
const auto x =
|
||||
item->getPosX() +
|
||||
(item->getWidth() - game_text_textures_[4]->getWidth()) / 2;
|
||||
createItemText(x, game_text_textures_[4]);
|
||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(4)->getWidth()) / 2;
|
||||
createItemText(x, game_text_textures_.at(4));
|
||||
}
|
||||
JA_PlaySound(Resource::get()->getSound("voice_coffee.wav"));
|
||||
break;
|
||||
@@ -520,10 +518,8 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
|
||||
{
|
||||
player->setPowerUp();
|
||||
coffee_machine_enabled_ = false;
|
||||
const auto x =
|
||||
item->getPosX() +
|
||||
(item->getWidth() - game_text_textures_[3]->getWidth()) / 2;
|
||||
createItemText(x, game_text_textures_[3]);
|
||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(3)->getWidth()) / 2;
|
||||
createItemText(x, game_text_textures_.at(3));
|
||||
JA_PlaySound(Resource::get()->getSound("voice_power_up.wav"));
|
||||
break;
|
||||
}
|
||||
@@ -539,11 +535,23 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba y procesa la colisión entre las balas y los globos
|
||||
void Game::checkBulletBalloonCollision()
|
||||
// Comprueba y procesa la colisión de las balas
|
||||
void Game::checkBulletCollision()
|
||||
{
|
||||
for (auto &bullet : bullets_)
|
||||
{
|
||||
// Comprueba la colisión con el Tabe
|
||||
if (bullet->isEnabled() && tabe_->isEnabled())
|
||||
if (checkCollision(bullet->getCollider(), tabe_->getCollider()))
|
||||
{
|
||||
tabe_->setState(TabeState::HIT);
|
||||
bullet->disable();
|
||||
auto pos = tabe_->getCollider();
|
||||
createItem(tabe_->tryToGetBonus() ? ItemType::DEBIAN : ItemType::COFFEE, pos.x, pos.y);
|
||||
break;
|
||||
}
|
||||
|
||||
// Comprueba la colisión con los globos
|
||||
for (auto &balloon : balloon_manager_->getBalloons())
|
||||
{
|
||||
if (balloon->isEnabled() && (!balloon->isInvulnerable()) && bullet->isEnabled())
|
||||
@@ -1246,7 +1254,8 @@ void Game::checkEvents()
|
||||
}
|
||||
case SDLK_7: // Flash
|
||||
{
|
||||
screen_->flash(flash_color, 3);
|
||||
// screen_->flash(flash_color, 3);
|
||||
tabe_->setState(TabeState::HIT);
|
||||
break;
|
||||
}
|
||||
case SDLK_8:
|
||||
@@ -1941,7 +1950,7 @@ void Game::updateGameStatePlaying()
|
||||
updatePathSprites();
|
||||
updateTimeStopped();
|
||||
updateHelper();
|
||||
checkBulletBalloonCollision();
|
||||
checkBulletCollision();
|
||||
updateMenace();
|
||||
checkAndUpdateBalloonSpeed();
|
||||
checkState();
|
||||
|
||||
Reference in New Issue
Block a user