clang-tidy
This commit is contained in:
@@ -466,35 +466,35 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player) {
|
||||
switch (item->getType()) {
|
||||
case ItemType::DISK: {
|
||||
player->addScore(1000, Options::settings.hi_score_table.back().score);
|
||||
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));
|
||||
playSound("item_pickup.wav");
|
||||
break;
|
||||
}
|
||||
case ItemType::GAVINA: {
|
||||
player->addScore(2500, Options::settings.hi_score_table.back().score);
|
||||
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));
|
||||
playSound("item_pickup.wav");
|
||||
break;
|
||||
}
|
||||
case ItemType::PACMAR: {
|
||||
player->addScore(5000, Options::settings.hi_score_table.back().score);
|
||||
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));
|
||||
playSound("item_pickup.wav");
|
||||
break;
|
||||
}
|
||||
case ItemType::DEBIAN: {
|
||||
player->addScore(100000, Options::settings.hi_score_table.back().score);
|
||||
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));
|
||||
playSound("debian_pickup.wav");
|
||||
break;
|
||||
}
|
||||
case ItemType::CLOCK: {
|
||||
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));
|
||||
playSound("item_pickup.wav");
|
||||
break;
|
||||
@@ -502,11 +502,11 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player) {
|
||||
case ItemType::COFFEE: {
|
||||
if (player->getCoffees() == 2) {
|
||||
player->addScore(5000, Options::settings.hi_score_table.back().score);
|
||||
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));
|
||||
} else {
|
||||
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));
|
||||
}
|
||||
playSound("voice_coffee.wav");
|
||||
@@ -515,7 +515,7 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player) {
|
||||
case ItemType::COFFEE_MACHINE: {
|
||||
player->setPowerUp();
|
||||
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));
|
||||
playSound("voice_power_up.wav");
|
||||
break;
|
||||
@@ -582,19 +582,18 @@ void Game::handleTabeHitEffects() {
|
||||
|
||||
// Maneja la colisión entre bala y globos
|
||||
auto Game::checkBulletBalloonCollision(const std::shared_ptr<Bullet> &bullet) -> bool {
|
||||
for (auto &balloon : balloon_manager_->getBalloons()) {
|
||||
return std::ranges::any_of(balloon_manager_->getBalloons(), [this, &bullet](auto &balloon) {
|
||||
if (!balloon->isEnabled() || balloon->isInvulnerable()) {
|
||||
continue;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!checkCollision(balloon->getCollider(), bullet->getCollider())) {
|
||||
continue;
|
||||
return false;
|
||||
}
|
||||
|
||||
processBalloonHit(bullet, balloon);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
// Procesa el impacto en un globo
|
||||
@@ -623,9 +622,9 @@ void Game::handleItemDrop(const std::shared_ptr<Balloon> &balloon, const std::sh
|
||||
}
|
||||
|
||||
// Maneja la destrucción del globo y puntuación
|
||||
void Game::handleBalloonDestruction(std::shared_ptr<Balloon> balloon, const std::shared_ptr<Player> &player) {
|
||||
void Game::handleBalloonDestruction(const std::shared_ptr<Balloon> &balloon, const std::shared_ptr<Player> &player) {
|
||||
if (player->isPlaying()) {
|
||||
auto const SCORE = balloon_manager_->popBalloon(std::move(balloon)) * player->getScoreMultiplier() * difficulty_score_multiplier_;
|
||||
auto const SCORE = balloon_manager_->popBalloon(balloon) * player->getScoreMultiplier() * difficulty_score_multiplier_;
|
||||
player->addScore(SCORE, Options::settings.hi_score_table.back().score);
|
||||
player->incScoreMultiplier();
|
||||
}
|
||||
@@ -874,7 +873,7 @@ void Game::handlePlayerCollision(std::shared_ptr<Player> &player, std::shared_pt
|
||||
if (player->hasExtraHit()) {
|
||||
// Lo pierde
|
||||
player->removeExtraHit();
|
||||
throwCoffee(player->getPosX() + (player->getWidth() / 2), player->getPosY() + (player->getHeight() / 2));
|
||||
throwCoffee(player->getPosX() + (Player::getWidth() / 2), player->getPosY() + (Player::getHeight() / 2));
|
||||
playSound("coffee_out.wav");
|
||||
screen_->shake();
|
||||
} else {
|
||||
@@ -986,9 +985,9 @@ void Game::fillCanvas() {
|
||||
|
||||
// Dibuja los objetos
|
||||
background_->render();
|
||||
|
||||
|
||||
balloon_manager_->render();
|
||||
renderSmartSprites(); // El cafe que sale cuando te golpean
|
||||
renderSmartSprites(); // El cafe que sale cuando te golpean
|
||||
renderItems();
|
||||
tabe_->render();
|
||||
renderBullets();
|
||||
@@ -1033,7 +1032,7 @@ void Game::initPaths() {
|
||||
const auto &texture = Resource::get()->getTexture("game_text_get_ready");
|
||||
const auto W = texture->getWidth();
|
||||
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 Y = param.game.play_area.center_y;
|
||||
paths_.emplace_back(createPath(X0, X1, PathType::HORIZONTAL, Y, 80, easeOutQuint), 20);
|
||||
@@ -1045,7 +1044,7 @@ void Game::initPaths() {
|
||||
const auto &texture = Resource::get()->getTexture("game_text_last_stage");
|
||||
const auto H = texture->getHeight();
|
||||
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 X = param.game.play_area.center_x;
|
||||
paths_.emplace_back(createPath(Y0, Y1, PathType::VERTICAL, X, 80, easeOutQuint), 20);
|
||||
@@ -1058,9 +1057,9 @@ void Game::initPaths() {
|
||||
const auto W = texture->getWidth();
|
||||
const auto H = texture->getHeight();
|
||||
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 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(createPath(X0, X1, PathType::HORIZONTAL, Y, 80, easeOutQuint), 400);
|
||||
paths_.emplace_back(createPath(X1, X2, PathType::HORIZONTAL, Y, 80, easeInQuint), 0);
|
||||
}
|
||||
@@ -1071,9 +1070,9 @@ void Game::initPaths() {
|
||||
const auto W = texture->getWidth();
|
||||
const auto H = texture->getHeight();
|
||||
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 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(createPath(X0, X1, PathType::HORIZONTAL, Y, 80, easeOutQuint), 400);
|
||||
paths_.emplace_back(createPath(X1, X2, PathType::HORIZONTAL, Y, 80, easeInQuint), 0);
|
||||
}
|
||||
@@ -1199,7 +1198,7 @@ void Game::checkPlayersStatusPlaying() {
|
||||
|
||||
// Obtiene un jugador a partir de su "id"
|
||||
auto Game::getPlayer(Player::Id id) -> std::shared_ptr<Player> {
|
||||
auto it = std::find_if(players_.begin(), players_.end(), [id](const auto &player) { return player->getId() == id; });
|
||||
auto it = std::ranges::find_if(players_, [id](const auto &player) { return player->getId() == id; });
|
||||
|
||||
if (it != players_.end()) {
|
||||
return *it;
|
||||
@@ -1304,7 +1303,7 @@ void Game::handleFireInput(const std::shared_ptr<Player> &player, BulletType bul
|
||||
switch (bullet_type) {
|
||||
case BulletType::UP:
|
||||
player->setInput(Input::Action::FIRE_CENTER);
|
||||
bullet.x = 2 + player->getPosX() + (player->getWidth() - Bullet::WIDTH) / 2;
|
||||
bullet.x = 2 + player->getPosX() + (Player::getWidth() - Bullet::WIDTH) / 2;
|
||||
bullet.y = player->getPosY() - (Bullet::HEIGHT / 2);
|
||||
break;
|
||||
case BulletType::LEFT:
|
||||
@@ -1314,7 +1313,7 @@ void Game::handleFireInput(const std::shared_ptr<Player> &player, BulletType bul
|
||||
break;
|
||||
case BulletType::RIGHT:
|
||||
player->setInput(Input::Action::FIRE_RIGHT);
|
||||
bullet.x = player->getPosX() + player->getWidth() - (Bullet::WIDTH / 2);
|
||||
bullet.x = player->getPosX() + Player::getWidth() - (Bullet::WIDTH / 2);
|
||||
bullet.y = player->getPosY();
|
||||
break;
|
||||
default:
|
||||
@@ -1835,9 +1834,9 @@ void Game::sortPlayersByZOrder() {
|
||||
// Procesar jugadores que van al fondo (se dibujan primero)
|
||||
if (!players_to_put_at_back_.empty()) {
|
||||
for (auto &player : players_to_put_at_back_) {
|
||||
auto it = std::find(players_.begin(), players_.end(), player);
|
||||
auto it = std::ranges::find(players_, player);
|
||||
if (it != players_.end() && it != players_.begin()) {
|
||||
std::shared_ptr<Player> dying_player = *it;
|
||||
const std::shared_ptr<Player> &dying_player = *it;
|
||||
players_.erase(it);
|
||||
players_.insert(players_.begin(), dying_player);
|
||||
}
|
||||
@@ -1848,9 +1847,9 @@ void Game::sortPlayersByZOrder() {
|
||||
// Procesar jugadores que van al frente (se dibujan últimos)
|
||||
if (!players_to_put_at_front_.empty()) {
|
||||
for (auto &player : players_to_put_at_front_) {
|
||||
auto it = std::find(players_.begin(), players_.end(), player);
|
||||
auto it = std::ranges::find(players_, player);
|
||||
if (it != players_.end() && it != players_.end() - 1) {
|
||||
std::shared_ptr<Player> front_player = *it;
|
||||
const std::shared_ptr<Player> &front_player = *it;
|
||||
players_.erase(it);
|
||||
players_.push_back(front_player);
|
||||
}
|
||||
@@ -1910,7 +1909,7 @@ void Game::handleDebugEvents(const SDL_Event &event) {
|
||||
}
|
||||
case SDLK_5: // 5.000
|
||||
{
|
||||
const int X = players_.at(0)->getPosX() + (players_.at(0)->getWidth() - game_text_textures_[3]->getWidth()) / 2;
|
||||
const int X = players_.at(0)->getPosX() + ((Player::getWidth() - game_text_textures_[3]->getWidth()) / 2);
|
||||
createItemText(X, game_text_textures_.at(2));
|
||||
break;
|
||||
}
|
||||
@@ -1921,7 +1920,7 @@ void Game::handleDebugEvents(const SDL_Event &event) {
|
||||
}
|
||||
case SDLK_7: // 100.000
|
||||
{
|
||||
const int X = players_.at(0)->getPosX() + (players_.at(0)->getWidth() - game_text_textures_[3]->getWidth()) / 2;
|
||||
const int X = players_.at(0)->getPosX() + ((Player::getWidth() - game_text_textures_[3]->getWidth()) / 2);
|
||||
createItemText(X, game_text_textures_.at(6));
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user