treball en curs: correccions de tidy
This commit is contained in:
+253
-225
@@ -29,6 +29,28 @@
|
||||
#include "game/ui/menu.h" // for Menu
|
||||
struct JA_Sound_t;
|
||||
|
||||
namespace {
|
||||
// Constantes geométricas y temporales compartidas por los helpers de initEnemyFormations
|
||||
constexpr int Y4 = (PLAY_AREA_TOP - BLOCK);
|
||||
constexpr int X4_0 = PLAY_AREA_LEFT;
|
||||
constexpr int X4_100 = PLAY_AREA_RIGHT - Balloon::WIDTH_4;
|
||||
|
||||
constexpr int Y3 = (PLAY_AREA_TOP - BLOCK);
|
||||
constexpr int X3_0 = PLAY_AREA_LEFT;
|
||||
constexpr int X3_100 = PLAY_AREA_RIGHT - Balloon::WIDTH_3;
|
||||
|
||||
constexpr int Y2 = (PLAY_AREA_TOP - BLOCK);
|
||||
constexpr int X2_0 = PLAY_AREA_LEFT;
|
||||
constexpr int X2_100 = PLAY_AREA_RIGHT - Balloon::WIDTH_2;
|
||||
|
||||
constexpr int Y1 = (PLAY_AREA_TOP - BLOCK);
|
||||
constexpr int X1_0 = PLAY_AREA_LEFT;
|
||||
constexpr int X1_50 = PLAY_AREA_CENTER_X - (Balloon::WIDTH_1 / 2);
|
||||
constexpr int X1_100 = PLAY_AREA_RIGHT - Balloon::WIDTH_1;
|
||||
|
||||
constexpr Uint16 CREATION_TIME = 300;
|
||||
} // namespace
|
||||
|
||||
// Constructor
|
||||
Game::Game(int num_players, int current_stage, SDL_Renderer *renderer, bool demo, Section *section)
|
||||
: last_stage_reached_(current_stage) {
|
||||
@@ -45,8 +67,8 @@ Game::Game(int num_players, int current_stage, SDL_Renderer *renderer, bool demo
|
||||
this->current_stage_ = current_stage;
|
||||
#endif
|
||||
if (num_players == 1) { // Si solo juega un jugador, permite jugar tanto con teclado como con mando
|
||||
player_one_control_ = Options::inputs[0].deviceType;
|
||||
Options::inputs[0].deviceType = INPUT_USE_ANY;
|
||||
player_one_control_ = Options::inputs[0].device_type;
|
||||
Options::inputs[0].device_type = INPUT_USE_ANY;
|
||||
}
|
||||
difficulty_ = Options::settings.difficulty;
|
||||
|
||||
@@ -93,7 +115,7 @@ Game::~Game() {
|
||||
|
||||
// Restaura el metodo de control
|
||||
if (num_players_ == 1) {
|
||||
Options::inputs[0].deviceType = player_one_control_;
|
||||
Options::inputs[0].device_type = player_one_control_;
|
||||
}
|
||||
|
||||
// Elimina todos los objetos contenidos en vectores (jugadores, balas, etc.)
|
||||
@@ -517,10 +539,10 @@ auto Game::loadDemoFile() -> bool {
|
||||
for (auto &i : demo_.data_file) {
|
||||
demo_.keys.left = 0;
|
||||
demo_.keys.right = 0;
|
||||
demo_.keys.noInput = 0;
|
||||
demo_.keys.no_input = 0;
|
||||
demo_.keys.fire = 0;
|
||||
demo_.keys.fireLeft = 0;
|
||||
demo_.keys.fireRight = 0;
|
||||
demo_.keys.fire_left = 0;
|
||||
demo_.keys.fire_right = 0;
|
||||
i = demo_.keys;
|
||||
}
|
||||
}
|
||||
@@ -583,24 +605,14 @@ auto Game::saveDemoFile() -> bool {
|
||||
|
||||
// Inicializa las formaciones enemigas
|
||||
void Game::initEnemyFormations() {
|
||||
const int Y4 = (PLAY_AREA_TOP - BLOCK);
|
||||
const int X4_0 = PLAY_AREA_LEFT;
|
||||
const int X4_100 = (PLAY_AREA_RIGHT)-Balloon::WIDTH_4;
|
||||
initEnemyFormationsZero();
|
||||
initEnemyFormationsLinear();
|
||||
initEnemyFormationsSymmetric();
|
||||
initEnemyFormationsHexagonsAndTest();
|
||||
}
|
||||
|
||||
const int Y3 = (PLAY_AREA_TOP - BLOCK);
|
||||
const int X3_0 = PLAY_AREA_LEFT;
|
||||
const int X3_100 = (PLAY_AREA_RIGHT)-Balloon::WIDTH_3;
|
||||
|
||||
const int Y2 = (PLAY_AREA_TOP - BLOCK);
|
||||
const int X2_0 = PLAY_AREA_LEFT;
|
||||
const int X2_100 = (PLAY_AREA_RIGHT)-Balloon::WIDTH_2;
|
||||
|
||||
const int Y1 = (PLAY_AREA_TOP - BLOCK);
|
||||
const int X1_0 = PLAY_AREA_LEFT;
|
||||
const int X1_50 = PLAY_AREA_CENTER_X - (Balloon::WIDTH_1 / 2);
|
||||
const int X1_100 = (PLAY_AREA_RIGHT)-Balloon::WIDTH_1;
|
||||
|
||||
// Inicializa a cero las variables
|
||||
// Pone a cero todas las formaciones
|
||||
void Game::initEnemyFormationsZero() {
|
||||
for (auto &i : enemy_formation_) {
|
||||
i.number_of_enemies = 0;
|
||||
for (auto &j : i.init) {
|
||||
@@ -611,8 +623,10 @@ void Game::initEnemyFormations() {
|
||||
j.creation_counter = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const Uint16 CREATION_TIME = 300;
|
||||
// Formaciones 0..19: bucles lineales (todos los enemigos van en la misma dirección)
|
||||
void Game::initEnemyFormationsLinear() {
|
||||
int inc_x = 0;
|
||||
Uint8 inc_time = 0;
|
||||
Uint8 j = 0;
|
||||
@@ -876,6 +890,13 @@ void Game::initEnemyFormations() {
|
||||
enemy_formation_[j].init[i].kind = Balloon::BALLOON_1;
|
||||
enemy_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
|
||||
}
|
||||
}
|
||||
|
||||
// Formaciones 20..25: simétricas (la primera mitad va hacia un lado, la segunda hacia el otro)
|
||||
void Game::initEnemyFormationsSymmetric() {
|
||||
int inc_x = 0;
|
||||
Uint8 inc_time = 0;
|
||||
Uint8 j = 0;
|
||||
|
||||
// #20 - Dos enemigos BALLOON4 seguidos desde la izquierda/derecha. Simetricos
|
||||
j = 20;
|
||||
@@ -993,9 +1014,14 @@ void Game::initEnemyFormations() {
|
||||
enemy_formation_[j].init[i].y = Y1;
|
||||
enemy_formation_[j].init[i].kind = Balloon::BALLOON_1;
|
||||
}
|
||||
}
|
||||
|
||||
// Duplica las formaciones 0..25 como hexágonos en el rango 50..75, y configura la formación 99 (TEST)
|
||||
void Game::initEnemyFormationsHexagonsAndTest() {
|
||||
constexpr Uint8 LAST_SYMMETRIC = 25;
|
||||
|
||||
// Crea las mismas formaciones pero con hexagonos a partir de la posición 50 del vector
|
||||
for (int k = 0; k < j + 1; k++) {
|
||||
for (int k = 0; k < LAST_SYMMETRIC + 1; k++) {
|
||||
enemy_formation_[k + 50].number_of_enemies = enemy_formation_[k].number_of_enemies;
|
||||
for (int i = 0; i < enemy_formation_[k + 50].number_of_enemies; i++) {
|
||||
enemy_formation_[k + 50].init[i].x = enemy_formation_[k].init[i].x;
|
||||
@@ -1843,44 +1869,48 @@ void Game::checkPlayerItemCollision(Player *player) {
|
||||
void Game::checkBulletBalloonCollision() {
|
||||
for (auto *bullet : bullets_) {
|
||||
for (auto *balloon : balloons_) {
|
||||
if (balloon->isEnabled() && (!balloon->isInvulnerable()) && bullet->isEnabled()) {
|
||||
if (checkCollision(balloon->getCollider(), bullet->getCollider())) {
|
||||
// Otorga los puntos correspondientes al globo al jugador que disparó la bala
|
||||
int index = bullet->getOwner();
|
||||
players_[index]->incScoreMultiplier();
|
||||
players_[index]->addScore(Uint32(balloon->getScore() * players_[index]->getScoreMultiplier() * difficulty_score_multiplier_));
|
||||
updateHiScore();
|
||||
|
||||
// Explota el globo
|
||||
popBalloon(balloon);
|
||||
|
||||
// Si no es el modo demo, genera un sonido
|
||||
if (!demo_.enabled) {
|
||||
Audio::get()->playSound(balloon_sound_);
|
||||
}
|
||||
|
||||
// Deshabilita la bala
|
||||
bullet->disable();
|
||||
|
||||
// Suelta el item en caso de que salga uno
|
||||
const Item::Id droppeditem = dropItem();
|
||||
if ((droppeditem != Item::Id::NONE) && !(demo_.enabled) && !(demo_.recording)) {
|
||||
if (droppeditem != Item::Id::COFFEE_MACHINE) {
|
||||
createItem(droppeditem, balloon->getPosX(), balloon->getPosY());
|
||||
Audio::get()->playSound(item_drop_sound_);
|
||||
} else {
|
||||
createItem(droppeditem, players_[index]->getPosX(), 0);
|
||||
coffee_machine_enabled_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
if (!balloon->isEnabled() || balloon->isInvulnerable() || !bullet->isEnabled()) {
|
||||
continue;
|
||||
}
|
||||
if (checkCollision(balloon->getCollider(), bullet->getCollider())) {
|
||||
resolveBulletBalloonHit(bullet, balloon);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Resuelve un impacto bala-globo: puntos, sonido, explosión, drop de item
|
||||
void Game::resolveBulletBalloonHit(Bullet *bullet, Balloon *balloon) {
|
||||
// Otorga los puntos al jugador que disparó la bala
|
||||
const int INDEX = bullet->getOwner();
|
||||
players_[INDEX]->incScoreMultiplier();
|
||||
players_[INDEX]->addScore(Uint32(balloon->getScore() * players_[INDEX]->getScoreMultiplier() * difficulty_score_multiplier_));
|
||||
updateHiScore();
|
||||
|
||||
popBalloon(balloon);
|
||||
|
||||
if (!demo_.enabled) {
|
||||
Audio::get()->playSound(balloon_sound_);
|
||||
}
|
||||
|
||||
bullet->disable();
|
||||
|
||||
// Suelta el item en caso de que salga uno
|
||||
const Item::Id DROPPED_ITEM = dropItem();
|
||||
if ((DROPPED_ITEM == Item::Id::NONE) || demo_.enabled || demo_.recording) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (DROPPED_ITEM != Item::Id::COFFEE_MACHINE) {
|
||||
createItem(DROPPED_ITEM, balloon->getPosX(), balloon->getPosY());
|
||||
Audio::get()->playSound(item_drop_sound_);
|
||||
} else {
|
||||
createItem(DROPPED_ITEM, players_[INDEX]->getPosX(), 0);
|
||||
coffee_machine_enabled_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Mueve las balas activas
|
||||
void Game::moveBullets() {
|
||||
for (auto *bullet : bullets_) {
|
||||
@@ -2422,145 +2452,136 @@ void Game::updateMenace() {
|
||||
void Game::checkGameInput() {
|
||||
demo_.keys.left = 0;
|
||||
demo_.keys.right = 0;
|
||||
demo_.keys.noInput = 0;
|
||||
demo_.keys.no_input = 0;
|
||||
demo_.keys.fire = 0;
|
||||
demo_.keys.fireLeft = 0;
|
||||
demo_.keys.fireRight = 0;
|
||||
demo_.keys.fire_left = 0;
|
||||
demo_.keys.fire_right = 0;
|
||||
|
||||
// Atalls globals (zoom finestra, fullscreen, shaders, presets, ...)
|
||||
GlobalInputs::handle();
|
||||
|
||||
// Modo Demo activo
|
||||
if (demo_.enabled) {
|
||||
const int INDEX = 0;
|
||||
if (demo_.data_file[demo_.counter].left == 1) {
|
||||
players_[INDEX]->setInput(input_left);
|
||||
}
|
||||
processDemoInput();
|
||||
} else {
|
||||
processLiveInput();
|
||||
}
|
||||
}
|
||||
|
||||
if (demo_.data_file[demo_.counter].right == 1) {
|
||||
players_[INDEX]->setInput(input_right);
|
||||
}
|
||||
// Rama de checkGameInput: reproduce el input grabado en data_file
|
||||
void Game::processDemoInput() {
|
||||
const int INDEX = 0;
|
||||
const DemoKeys &keys = demo_.data_file[demo_.counter];
|
||||
|
||||
if (demo_.data_file[demo_.counter].noInput == 1) {
|
||||
players_[INDEX]->setInput(input_null);
|
||||
}
|
||||
if (keys.left == 1) {
|
||||
players_[INDEX]->setInput(LEFT);
|
||||
}
|
||||
if (keys.right == 1) {
|
||||
players_[INDEX]->setInput(RIGHT);
|
||||
}
|
||||
if (keys.no_input == 1) {
|
||||
players_[INDEX]->setInput(INVALID);
|
||||
}
|
||||
|
||||
if (demo_.data_file[demo_.counter].fire == 1) {
|
||||
if (players_[INDEX]->canFire()) {
|
||||
players_[INDEX]->setInput(input_fire_center);
|
||||
createBullet(players_[INDEX]->getPosX() + (players_[INDEX]->getWidth() / 2) - 4, players_[INDEX]->getPosY() + (players_[INDEX]->getHeight() / 2), Bullet::Kind::UP, players_[INDEX]->isPowerUp(), INDEX);
|
||||
players_[INDEX]->setFireCooldown(10);
|
||||
}
|
||||
}
|
||||
if (keys.fire == 1 && players_[INDEX]->canFire()) {
|
||||
players_[INDEX]->setInput(FIRE_CENTER);
|
||||
createBullet(players_[INDEX]->getPosX() + (players_[INDEX]->getWidth() / 2) - 4, players_[INDEX]->getPosY() + (players_[INDEX]->getHeight() / 2), Bullet::Kind::UP, players_[INDEX]->isPowerUp(), INDEX);
|
||||
players_[INDEX]->setFireCooldown(10);
|
||||
}
|
||||
|
||||
if (demo_.data_file[demo_.counter].fireLeft == 1) {
|
||||
if (players_[INDEX]->canFire()) {
|
||||
players_[INDEX]->setInput(input_fire_left);
|
||||
createBullet(players_[INDEX]->getPosX() + (players_[INDEX]->getWidth() / 2) - 4, players_[INDEX]->getPosY() + (players_[INDEX]->getHeight() / 2), Bullet::Kind::LEFT, players_[INDEX]->isPowerUp(), INDEX);
|
||||
players_[INDEX]->setFireCooldown(10);
|
||||
}
|
||||
}
|
||||
if (keys.fire_left == 1 && players_[INDEX]->canFire()) {
|
||||
players_[INDEX]->setInput(FIRE_LEFT);
|
||||
createBullet(players_[INDEX]->getPosX() + (players_[INDEX]->getWidth() / 2) - 4, players_[INDEX]->getPosY() + (players_[INDEX]->getHeight() / 2), Bullet::Kind::LEFT, players_[INDEX]->isPowerUp(), INDEX);
|
||||
players_[INDEX]->setFireCooldown(10);
|
||||
}
|
||||
|
||||
if (demo_.data_file[demo_.counter].fireRight == 1) {
|
||||
if (players_[INDEX]->canFire()) {
|
||||
players_[INDEX]->setInput(input_fire_right);
|
||||
createBullet(players_[INDEX]->getPosX() + (players_[INDEX]->getWidth() / 2) - 4, players_[INDEX]->getPosY() + (players_[INDEX]->getHeight() / 2), Bullet::Kind::RIGHT, players_[INDEX]->isPowerUp(), INDEX);
|
||||
players_[INDEX]->setFireCooldown(10);
|
||||
}
|
||||
}
|
||||
if (keys.fire_right == 1 && players_[INDEX]->canFire()) {
|
||||
players_[INDEX]->setInput(FIRE_RIGHT);
|
||||
createBullet(players_[INDEX]->getPosX() + (players_[INDEX]->getWidth() / 2) - 4, players_[INDEX]->getPosY() + (players_[INDEX]->getHeight() / 2), Bullet::Kind::RIGHT, players_[INDEX]->isPowerUp(), INDEX);
|
||||
players_[INDEX]->setFireCooldown(10);
|
||||
}
|
||||
|
||||
// Si se pulsa cualquier tecla, se sale del modo demo
|
||||
if (Input::get()->checkAnyInput()) {
|
||||
section_->name = SECTION_PROG_TITLE;
|
||||
}
|
||||
// Si se pulsa cualquier tecla, se sale del modo demo
|
||||
if (Input::get()->checkAnyInput()) {
|
||||
section_->name = SECTION_PROG_TITLE;
|
||||
}
|
||||
|
||||
// Incrementa el contador de la demo
|
||||
if (demo_.counter < TOTAL_DEMO_DATA) {
|
||||
demo_.counter++;
|
||||
} else {
|
||||
section_->name = SECTION_PROG_TITLE;
|
||||
section_->subsection = SUBSECTION_TITLE_INSTRUCTIONS;
|
||||
// Incrementa el contador de la demo
|
||||
if (demo_.counter < TOTAL_DEMO_DATA) {
|
||||
demo_.counter++;
|
||||
} else {
|
||||
section_->name = SECTION_PROG_TITLE;
|
||||
section_->subsection = SUBSECTION_TITLE_INSTRUCTIONS;
|
||||
}
|
||||
}
|
||||
|
||||
// Rama de checkGameInput: lee inputs reales del teclado/gamepad por jugador
|
||||
void Game::processLiveInput() {
|
||||
int i = 0;
|
||||
for (auto *player : players_) {
|
||||
if (player->isAlive()) {
|
||||
processPlayerLiveInput(player, i);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
// Modo Demo no activo
|
||||
else {
|
||||
int i = 0;
|
||||
for (auto *player : players_) {
|
||||
if (player->isAlive()) {
|
||||
// Input a la izquierda
|
||||
if (Input::get()->checkInput(input_left, REPEAT_TRUE, Options::inputs[i].deviceType, Options::inputs[i].id)) {
|
||||
player->setInput(input_left);
|
||||
demo_.keys.left = 1;
|
||||
} else {
|
||||
// Input a la derecha
|
||||
if (Input::get()->checkInput(input_right, REPEAT_TRUE, Options::inputs[i].deviceType, Options::inputs[i].id)) {
|
||||
player->setInput(input_right);
|
||||
demo_.keys.right = 1;
|
||||
} else {
|
||||
// Ninguno de los dos inputs anteriores
|
||||
player->setInput(input_null);
|
||||
demo_.keys.noInput = 1;
|
||||
}
|
||||
}
|
||||
// Comprueba el input de disparar al centro
|
||||
if (Input::get()->checkInput(input_fire_center, REPEAT_TRUE, Options::inputs[i].deviceType, Options::inputs[i].id)) {
|
||||
if (player->canFire()) {
|
||||
player->setInput(input_fire_center);
|
||||
createBullet(player->getPosX() + (player->getWidth() / 2) - 4, player->getPosY() + (player->getHeight() / 2), Bullet::Kind::UP, player->isPowerUp(), i);
|
||||
player->setFireCooldown(10);
|
||||
}
|
||||
|
||||
// Reproduce el sonido de disparo
|
||||
Audio::get()->playSound(bullet_sound_);
|
||||
// Cuerpo per-player de processLiveInput
|
||||
void Game::processPlayerLiveInput(Player *player, int i) {
|
||||
auto *input = Input::get();
|
||||
const auto &device = Options::inputs[i];
|
||||
|
||||
demo_.keys.fire = 1;
|
||||
}
|
||||
}
|
||||
// Movimiento izquierda / derecha / nada
|
||||
if (input->checkInput(LEFT, REPEAT_TRUE, device.device_type, device.id)) {
|
||||
player->setInput(LEFT);
|
||||
demo_.keys.left = 1;
|
||||
} else if (input->checkInput(RIGHT, REPEAT_TRUE, device.device_type, device.id)) {
|
||||
player->setInput(RIGHT);
|
||||
demo_.keys.right = 1;
|
||||
} else {
|
||||
player->setInput(INVALID);
|
||||
demo_.keys.no_input = 1;
|
||||
}
|
||||
|
||||
// Comprueba el input de disparar a la izquierda
|
||||
if (Input::get()->checkInput(input_fire_left, REPEAT_TRUE, Options::inputs[i].deviceType, Options::inputs[i].id)) {
|
||||
if (player->canFire()) {
|
||||
player->setInput(input_fire_left);
|
||||
createBullet(player->getPosX() + (player->getWidth() / 2) - 4, player->getPosY() + (player->getHeight() / 2), Bullet::Kind::LEFT, player->isPowerUp(), i);
|
||||
player->setFireCooldown(10);
|
||||
// Disparo al centro
|
||||
if (input->checkInput(FIRE_CENTER, REPEAT_TRUE, device.device_type, device.id) && player->canFire()) {
|
||||
player->setInput(FIRE_CENTER);
|
||||
createBullet(player->getPosX() + (player->getWidth() / 2) - 4, player->getPosY() + (player->getHeight() / 2), Bullet::Kind::UP, player->isPowerUp(), i);
|
||||
player->setFireCooldown(10);
|
||||
Audio::get()->playSound(bullet_sound_);
|
||||
demo_.keys.fire = 1;
|
||||
}
|
||||
|
||||
// Reproduce el sonido de disparo
|
||||
Audio::get()->playSound(bullet_sound_);
|
||||
// Disparo a la izquierda
|
||||
if (input->checkInput(FIRE_LEFT, REPEAT_TRUE, device.device_type, device.id) && player->canFire()) {
|
||||
player->setInput(FIRE_LEFT);
|
||||
createBullet(player->getPosX() + (player->getWidth() / 2) - 4, player->getPosY() + (player->getHeight() / 2), Bullet::Kind::LEFT, player->isPowerUp(), i);
|
||||
player->setFireCooldown(10);
|
||||
Audio::get()->playSound(bullet_sound_);
|
||||
demo_.keys.fire_left = 1;
|
||||
}
|
||||
|
||||
demo_.keys.fireLeft = 1;
|
||||
}
|
||||
}
|
||||
// Disparo a la derecha
|
||||
if (input->checkInput(FIRE_RIGHT, REPEAT_TRUE, device.device_type, device.id) && player->canFire()) {
|
||||
player->setInput(FIRE_RIGHT);
|
||||
createBullet(player->getPosX() + (player->getWidth() / 2) - 4, player->getPosY() + (player->getHeight() / 2), Bullet::Kind::RIGHT, player->isPowerUp(), i);
|
||||
player->setFireCooldown(10);
|
||||
Audio::get()->playSound(bullet_sound_);
|
||||
demo_.keys.fire_right = 1;
|
||||
}
|
||||
|
||||
// Comprueba el input de disparar a la derecha
|
||||
if (Input::get()->checkInput(input_fire_right, REPEAT_TRUE, Options::inputs[i].deviceType, Options::inputs[i].id)) {
|
||||
if (player->canFire()) {
|
||||
player->setInput(input_fire_right);
|
||||
createBullet(player->getPosX() + (player->getWidth() / 2) - 4, player->getPosY() + (player->getHeight() / 2), Bullet::Kind::RIGHT, player->isPowerUp(), i);
|
||||
player->setFireCooldown(10);
|
||||
// Pausa
|
||||
if (input->checkInput(PAUSE, REPEAT_FALSE, device.device_type, device.id)) {
|
||||
section_->subsection = SUBSECTION_GAME_PAUSE;
|
||||
}
|
||||
|
||||
// Reproduce el sonido de disparo
|
||||
Audio::get()->playSound(bullet_sound_);
|
||||
|
||||
demo_.keys.fireRight = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba el input de pausa
|
||||
if (Input::get()->checkInput(input_pause, REPEAT_FALSE, Options::inputs[i].deviceType, Options::inputs[i].id)) {
|
||||
section_->subsection = SUBSECTION_GAME_PAUSE;
|
||||
}
|
||||
|
||||
if (demo_.counter < TOTAL_DEMO_DATA) {
|
||||
if (demo_.recording) {
|
||||
demo_.data_file[demo_.counter] = demo_.keys;
|
||||
}
|
||||
demo_.counter++;
|
||||
} else if (demo_.recording) {
|
||||
section_->name = SECTION_PROG_QUIT;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
// Grabación de demo
|
||||
if (demo_.counter < TOTAL_DEMO_DATA) {
|
||||
if (demo_.recording) {
|
||||
demo_.data_file[demo_.counter] = demo_.keys;
|
||||
}
|
||||
demo_.counter++;
|
||||
} else if (demo_.recording) {
|
||||
section_->name = SECTION_PROG_QUIT;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2767,60 +2788,67 @@ void Game::run() {
|
||||
|
||||
// Actualiza las variables del menu de pausa del juego
|
||||
void Game::updatePausedGame() {
|
||||
// Calcula la lógica de los objetos
|
||||
if (SDL_GetTicks() - ticks_ > ticks_speed_) {
|
||||
// Actualiza el contador de ticks
|
||||
ticks_ = SDL_GetTicks();
|
||||
if (SDL_GetTicks() - ticks_ <= ticks_speed_) {
|
||||
return;
|
||||
}
|
||||
ticks_ = SDL_GetTicks();
|
||||
|
||||
// Atalls globals (zoom finestra, fullscreen, shaders, presets, ...)
|
||||
GlobalInputs::handle();
|
||||
// Atalls globals (zoom finestra, fullscreen, shaders, presets, ...)
|
||||
GlobalInputs::handle();
|
||||
|
||||
if (leaving_pause_menu_) {
|
||||
if (pause_counter_ > 0) { // El contador está descendiendo
|
||||
const bool A = pause_counter_ == 90;
|
||||
const bool B = pause_counter_ == 60;
|
||||
const bool C = pause_counter_ == 30;
|
||||
if (A || B || C) {
|
||||
Audio::get()->playSound(clock_sound_);
|
||||
}
|
||||
pause_counter_--;
|
||||
} else { // Ha finalizado el contador
|
||||
section_->name = SECTION_PROG_GAME;
|
||||
section_->subsection = num_players_ == 1 ? SUBSECTION_GAME_PLAY_1P : SUBSECTION_GAME_PLAY_2P;
|
||||
if (leaving_pause_menu_) {
|
||||
updateLeavingPauseMenu();
|
||||
} else {
|
||||
updatePauseMenuUI();
|
||||
}
|
||||
}
|
||||
|
||||
if (Audio::getRealMusicState() == Audio::MusicState::PAUSED) {
|
||||
Audio::get()->resumeMusic();
|
||||
}
|
||||
}
|
||||
} else { // Actualiza la lógica del menu de pausa
|
||||
pause_menu_->update();
|
||||
|
||||
// Comprueba las entradas para el menu
|
||||
pause_menu_->checkInput();
|
||||
|
||||
// Comprueba si se ha seleccionado algún item del menú
|
||||
switch (pause_menu_->getItemSelected()) {
|
||||
case 1:
|
||||
leaving_pause_menu_ = true;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
fade_->setFadeType(FADE_CENTER);
|
||||
fade_->activateFade();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Actualiza el fade
|
||||
fade_->update();
|
||||
if (fade_->hasEnded()) {
|
||||
section_->name = SECTION_PROG_TITLE;
|
||||
section_->subsection = SUBSECTION_TITLE_1;
|
||||
Audio::get()->stopMusic();
|
||||
}
|
||||
// Rama de updatePausedGame: cuenta atrás de salida y vuelta al juego
|
||||
void Game::updateLeavingPauseMenu() {
|
||||
if (pause_counter_ > 0) { // El contador está descendiendo
|
||||
const bool A = pause_counter_ == 90;
|
||||
const bool B = pause_counter_ == 60;
|
||||
const bool C = pause_counter_ == 30;
|
||||
if (A || B || C) {
|
||||
Audio::get()->playSound(clock_sound_);
|
||||
}
|
||||
pause_counter_--;
|
||||
return;
|
||||
}
|
||||
|
||||
// Ha finalizado el contador
|
||||
section_->name = SECTION_PROG_GAME;
|
||||
section_->subsection = num_players_ == 1 ? SUBSECTION_GAME_PLAY_1P : SUBSECTION_GAME_PLAY_2P;
|
||||
|
||||
if (Audio::getRealMusicState() == Audio::MusicState::PAUSED) {
|
||||
Audio::get()->resumeMusic();
|
||||
}
|
||||
}
|
||||
|
||||
// Rama de updatePausedGame: lógica del menú de pausa
|
||||
void Game::updatePauseMenuUI() {
|
||||
pause_menu_->update();
|
||||
pause_menu_->checkInput();
|
||||
|
||||
switch (pause_menu_->getItemSelected()) {
|
||||
case 1:
|
||||
leaving_pause_menu_ = true;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
fade_->setFadeType(FADE_CENTER);
|
||||
fade_->activateFade();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
fade_->update();
|
||||
if (fade_->hasEnded()) {
|
||||
section_->name = SECTION_PROG_TITLE;
|
||||
section_->subsection = SUBSECTION_TITLE_1;
|
||||
Audio::get()->stopMusic();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3027,7 +3055,7 @@ void Game::initPaths() {
|
||||
|
||||
// Letrero de STAGE #
|
||||
const int FIRST_PART = STAGE_COUNTER / 4; // 50
|
||||
const int SECOND_PART = FIRST_PART * 3; // 150
|
||||
const int SECOND_PART = FIRST_PART * 3; // 150
|
||||
const int CENTER_POINT = PLAY_AREA_CENTER_Y - (BLOCK * 2);
|
||||
const int DISTANCE = (PLAY_AREA_BOTTOM) - (PLAY_AREA_CENTER_Y - 16);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user