idem
This commit is contained in:
120
source/game.cpp
120
source/game.cpp
@@ -95,7 +95,7 @@ Game::Game(int playerID, int currentStage, bool demo, JA_Music_t *music)
|
||||
Game::~Game()
|
||||
{
|
||||
// Guarda las puntuaciones en un fichero
|
||||
auto manager = std::make_unique<ManageHiScoreTable>(&options.game.hiScoreTable);
|
||||
auto manager = std::make_unique<ManageHiScoreTable>(&options.game.hi_score_table);
|
||||
manager->saveToFile(asset->get("score.bin"));
|
||||
#ifdef RECORDING
|
||||
saveDemoFile(asset->get("demo1.bin"));
|
||||
@@ -122,14 +122,14 @@ void Game::init(int playerID)
|
||||
players.clear();
|
||||
|
||||
// Crea los dos jugadores
|
||||
auto player1 = std::make_unique<Player>(1, (param.game.play_area.firstQuarterX * ((0 * 2) + 1)) - 11, param.game.play_area.rect.h - 30, demo.enabled, ¶m.game.play_area.rect, playerTextures[0], playerAnimations);
|
||||
auto player1 = std::make_unique<Player>(1, (param.game.play_area.first_quarter_x * ((0 * 2) + 1)) - 11, param.game.play_area.rect.h - 30, demo.enabled, ¶m.game.play_area.rect, playerTextures[0], playerAnimations);
|
||||
player1->setScoreBoardPanel(SCOREBOARD_LEFT_PANEL);
|
||||
player1->setName(lang::getText(53));
|
||||
const auto controller1 = getController(player1->getId());
|
||||
player1->setController(controller1);
|
||||
players.push_back(std::move(player1));
|
||||
|
||||
auto player2 = std::make_unique<Player>(2, (param.game.play_area.firstQuarterX * ((1 * 2) + 1)) - 11, param.game.play_area.rect.h - 30, demo.enabled, ¶m.game.play_area.rect, playerTextures[1], playerAnimations);
|
||||
auto player2 = std::make_unique<Player>(2, (param.game.play_area.first_quarter_x * ((1 * 2) + 1)) - 11, param.game.play_area.rect.h - 30, demo.enabled, ¶m.game.play_area.rect, playerTextures[1], playerAnimations);
|
||||
player2->setScoreBoardPanel(SCOREBOARD_RIGHT_PANEL);
|
||||
player2->setName(lang::getText(54));
|
||||
const auto controller2 = getController(player2->getId());
|
||||
@@ -152,7 +152,7 @@ void Game::init(int playerID)
|
||||
{
|
||||
defaultEnemySpeed = BALLOON_SPEED_1;
|
||||
difficultyScoreMultiplier = 0.5f;
|
||||
difficultyColor = difficultyEasyColor;
|
||||
difficultyColor = difficulty_easy_color;
|
||||
scoreboard->setColor(difficultyColor);
|
||||
break;
|
||||
}
|
||||
@@ -161,8 +161,8 @@ void Game::init(int playerID)
|
||||
{
|
||||
defaultEnemySpeed = BALLOON_SPEED_1;
|
||||
difficultyScoreMultiplier = 1.0f;
|
||||
difficultyColor = difficultyNormalColor;
|
||||
scoreboard->setColor(scoreboardColor);
|
||||
difficultyColor = difficulty_normal_color;
|
||||
scoreboard->setColor(scoreboard_color);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ void Game::init(int playerID)
|
||||
{
|
||||
defaultEnemySpeed = BALLOON_SPEED_5;
|
||||
difficultyScoreMultiplier = 1.5f;
|
||||
difficultyColor = difficultyHardColor;
|
||||
difficultyColor = difficulty_hard_color;
|
||||
scoreboard->setColor(difficultyColor);
|
||||
break;
|
||||
}
|
||||
@@ -192,8 +192,8 @@ void Game::init(int playerID)
|
||||
scoreboard->setMode(SCOREBOARD_CENTER_PANEL, ScoreboardMode::STAGE_INFO);
|
||||
|
||||
// Resto de variables
|
||||
hiScore.score = options.game.hiScoreTable[0].score;
|
||||
hiScore.name = options.game.hiScoreTable[0].name;
|
||||
hiScore.score = options.game.hi_score_table[0].score;
|
||||
hiScore.name = options.game.hi_score_table[0].name;
|
||||
paused = false;
|
||||
gameCompleted = false;
|
||||
gameCompletedCounter = 0;
|
||||
@@ -289,8 +289,8 @@ void Game::init(int playerID)
|
||||
demo.counter = 0;
|
||||
|
||||
// Inicializa el objeto para el fundido
|
||||
fade->setColor(fadeColor.r, fadeColor.g, fadeColor.b);
|
||||
fade->setPost(param.fade.postDuration);
|
||||
fade->setColor(fade_color.r, fade_color.g, fade_color.b);
|
||||
fade->setPost(param.fade.post_duration);
|
||||
fade->setType(FadeType::VENETIAN);
|
||||
|
||||
// Con los globos creados, calcula el nivel de amenaza
|
||||
@@ -608,15 +608,15 @@ bool Game::loadDemoFile(std::string filePath, DemoKeys (*dataFile)[TOTAL_DEMO_DA
|
||||
// Inicializas los datos y los guarda en el fichero
|
||||
for (int i = 0; i < TOTAL_DEMO_DATA; ++i)
|
||||
{
|
||||
DemoKeys tmp;
|
||||
tmp.left = 0;
|
||||
tmp.right = 0;
|
||||
tmp.noInput = 0;
|
||||
tmp.fire = 0;
|
||||
tmp.fireLeft = 0;
|
||||
tmp.fireRight = 0;
|
||||
(*dataFile)[i] = tmp;
|
||||
SDL_RWwrite(file, &tmp, sizeof(DemoKeys), 1);
|
||||
DemoKeys dk;
|
||||
dk.left = 0;
|
||||
dk.right = 0;
|
||||
dk.no_input = 0;
|
||||
dk.fire = 0;
|
||||
dk.fire_left = 0;
|
||||
dk.fire_right = 0;
|
||||
(*dataFile)[i] = dk;
|
||||
SDL_RWwrite(file, &dk, sizeof(DemoKeys), 1);
|
||||
}
|
||||
|
||||
// Cerramos el fichero
|
||||
@@ -837,7 +837,7 @@ void Game::updateStage()
|
||||
stageBitmapCounter = 0;
|
||||
enemySpeed = defaultEnemySpeed;
|
||||
setBalloonSpeed(enemySpeed);
|
||||
screen->flash(flashColor, 5);
|
||||
screen->flash(flash_color, 5);
|
||||
screen->shake();
|
||||
}
|
||||
|
||||
@@ -922,7 +922,7 @@ void Game::createPowerBall()
|
||||
constexpr auto posY = -BLOCK;
|
||||
|
||||
const auto left = param.game.play_area.rect.x;
|
||||
const auto center = param.game.play_area.centerX - (BALLOON_WIDTH_4 / 2);
|
||||
const auto center = param.game.play_area.center_x - (BALLOON_WIDTH_4 / 2);
|
||||
const auto right = param.game.play_area.rect.w - BALLOON_WIDTH_4;
|
||||
|
||||
const auto vpos = BALLOON_VELX_POSITIVE;
|
||||
@@ -1177,7 +1177,7 @@ void Game::destroyAllBalloons()
|
||||
|
||||
enemyDeployCounter = 300;
|
||||
JA_PlaySound(powerBallSound);
|
||||
screen->flash(flashColor, 5);
|
||||
screen->flash(flash_color, 5);
|
||||
screen->shake();
|
||||
}
|
||||
|
||||
@@ -1980,7 +1980,7 @@ void Game::checkInput()
|
||||
player->setInput(input_right);
|
||||
}
|
||||
|
||||
else if (demo.dataFile[i][demo.counter].noInput == 1)
|
||||
else if (demo.dataFile[i][demo.counter].no_input == 1)
|
||||
{
|
||||
player->setInput(input_null);
|
||||
}
|
||||
@@ -1996,7 +1996,7 @@ void Game::checkInput()
|
||||
}
|
||||
}
|
||||
|
||||
else if (demo.dataFile[i][demo.counter].fireLeft == 1)
|
||||
else if (demo.dataFile[i][demo.counter].fire_left == 1)
|
||||
{
|
||||
if (player->canFire())
|
||||
{
|
||||
@@ -2006,7 +2006,7 @@ void Game::checkInput()
|
||||
}
|
||||
}
|
||||
|
||||
else if (demo.dataFile[i][demo.counter].fireRight == 1)
|
||||
else if (demo.dataFile[i][demo.counter].fire_right == 1)
|
||||
{
|
||||
if (player->canFire())
|
||||
{
|
||||
@@ -2034,10 +2034,10 @@ void Game::checkInput()
|
||||
// Resetea el teclado
|
||||
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;
|
||||
#endif
|
||||
for (auto &player : players)
|
||||
{
|
||||
@@ -2046,7 +2046,7 @@ void Game::checkInput()
|
||||
if (player->isPlaying())
|
||||
{
|
||||
// Input a la izquierda
|
||||
if (input->checkInput(input_left, INPUT_ALLOW_REPEAT, options.controller[controllerIndex].deviceType, options.controller[controllerIndex].index))
|
||||
if (input->checkInput(input_left, INPUT_ALLOW_REPEAT, options.controller[controllerIndex].device_type, options.controller[controllerIndex].index))
|
||||
{
|
||||
player->setInput(input_left);
|
||||
#ifdef RECORDING
|
||||
@@ -2056,7 +2056,7 @@ void Game::checkInput()
|
||||
else
|
||||
{
|
||||
// Input a la derecha
|
||||
if (input->checkInput(input_right, INPUT_ALLOW_REPEAT, options.controller[controllerIndex].deviceType, options.controller[controllerIndex].index))
|
||||
if (input->checkInput(input_right, INPUT_ALLOW_REPEAT, options.controller[controllerIndex].device_type, options.controller[controllerIndex].index))
|
||||
{
|
||||
player->setInput(input_right);
|
||||
#ifdef RECORDING
|
||||
@@ -2068,12 +2068,12 @@ void Game::checkInput()
|
||||
// Ninguno de los dos inputs anteriores
|
||||
player->setInput(input_null);
|
||||
#ifdef RECORDING
|
||||
demo.keys.noInput = 1;
|
||||
demo.keys.no_input = 1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
// Comprueba el input de disparar al centro
|
||||
if (input->checkInput(input_fire_center, autofire, options.controller[controllerIndex].deviceType, options.controller[controllerIndex].index))
|
||||
if (input->checkInput(input_fire_center, autofire, options.controller[controllerIndex].device_type, options.controller[controllerIndex].index))
|
||||
{
|
||||
if (player->canFire())
|
||||
{
|
||||
@@ -2090,7 +2090,7 @@ void Game::checkInput()
|
||||
}
|
||||
|
||||
// Comprueba el input de disparar a la izquierda
|
||||
else if (input->checkInput(input_fire_left, autofire, options.controller[controllerIndex].deviceType, options.controller[controllerIndex].index))
|
||||
else if (input->checkInput(input_fire_left, autofire, options.controller[controllerIndex].device_type, options.controller[controllerIndex].index))
|
||||
{
|
||||
if (player->canFire())
|
||||
{
|
||||
@@ -2101,13 +2101,13 @@ void Game::checkInput()
|
||||
// Reproduce el sonido de disparo
|
||||
JA_PlaySound(bulletSound);
|
||||
#ifdef RECORDING
|
||||
demo.keys.fireLeft = 1;
|
||||
demo.keys.fire_left = 1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba el input de disparar a la derecha
|
||||
else if (input->checkInput(input_fire_right, autofire, options.controller[controllerIndex].deviceType, options.controller[controllerIndex].index))
|
||||
else if (input->checkInput(input_fire_right, autofire, options.controller[controllerIndex].device_type, options.controller[controllerIndex].index))
|
||||
{
|
||||
if (player->canFire())
|
||||
{
|
||||
@@ -2118,7 +2118,7 @@ void Game::checkInput()
|
||||
// Reproduce el sonido de disparo
|
||||
JA_PlaySound(bulletSound);
|
||||
#ifdef RECORDING
|
||||
demo.keys.fireRight = 1;
|
||||
demo.keys.fire_right = 1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -2135,15 +2135,15 @@ void Game::checkInput()
|
||||
else if (player->isContinue() || player->isWaiting())
|
||||
{
|
||||
// Si no está jugando, el botón de start le permite continuar jugando
|
||||
if (input->checkInput(input_start, INPUT_DO_NOT_ALLOW_REPEAT, options.controller[controllerIndex].deviceType, options.controller[controllerIndex].index))
|
||||
if (input->checkInput(input_start, INPUT_DO_NOT_ALLOW_REPEAT, options.controller[controllerIndex].device_type, options.controller[controllerIndex].index))
|
||||
{
|
||||
player->setStatusPlaying(PlayerStatus::PLAYING);
|
||||
}
|
||||
|
||||
// Si está continuando, los botones de fuego hacen decrementar el contador
|
||||
const auto fire1 = input->checkInput(input_fire_left, INPUT_DO_NOT_ALLOW_REPEAT, options.controller[controllerIndex].deviceType, options.controller[controllerIndex].index);
|
||||
const auto fire2 = input->checkInput(input_fire_center, INPUT_DO_NOT_ALLOW_REPEAT, options.controller[controllerIndex].deviceType, options.controller[controllerIndex].index);
|
||||
const auto fire3 = input->checkInput(input_fire_right, INPUT_DO_NOT_ALLOW_REPEAT, options.controller[controllerIndex].deviceType, options.controller[controllerIndex].index);
|
||||
const auto fire1 = input->checkInput(input_fire_left, INPUT_DO_NOT_ALLOW_REPEAT, options.controller[controllerIndex].device_type, options.controller[controllerIndex].index);
|
||||
const auto fire2 = input->checkInput(input_fire_center, INPUT_DO_NOT_ALLOW_REPEAT, options.controller[controllerIndex].device_type, options.controller[controllerIndex].index);
|
||||
const auto fire3 = input->checkInput(input_fire_right, INPUT_DO_NOT_ALLOW_REPEAT, options.controller[controllerIndex].device_type, options.controller[controllerIndex].index);
|
||||
if (fire1 || fire2 || fire3)
|
||||
{
|
||||
player->decContinueCounter();
|
||||
@@ -2151,9 +2151,9 @@ void Game::checkInput()
|
||||
}
|
||||
else if (player->isEnteringName())
|
||||
{
|
||||
const auto fire1 = input->checkInput(input_fire_left, INPUT_DO_NOT_ALLOW_REPEAT, options.controller[controllerIndex].deviceType, options.controller[controllerIndex].index);
|
||||
const auto fire2 = input->checkInput(input_fire_center, INPUT_DO_NOT_ALLOW_REPEAT, options.controller[controllerIndex].deviceType, options.controller[controllerIndex].index);
|
||||
const auto fire3 = input->checkInput(input_fire_right, INPUT_DO_NOT_ALLOW_REPEAT, options.controller[controllerIndex].deviceType, options.controller[controllerIndex].index);
|
||||
const auto fire1 = input->checkInput(input_fire_left, INPUT_DO_NOT_ALLOW_REPEAT, options.controller[controllerIndex].device_type, options.controller[controllerIndex].index);
|
||||
const auto fire2 = input->checkInput(input_fire_center, INPUT_DO_NOT_ALLOW_REPEAT, options.controller[controllerIndex].device_type, options.controller[controllerIndex].index);
|
||||
const auto fire3 = input->checkInput(input_fire_right, INPUT_DO_NOT_ALLOW_REPEAT, options.controller[controllerIndex].device_type, options.controller[controllerIndex].index);
|
||||
if (fire1 || fire2 || fire3)
|
||||
{
|
||||
if (player->getRecordNamePos() == 7)
|
||||
@@ -2167,23 +2167,23 @@ void Game::checkInput()
|
||||
player->setInput(input_right);
|
||||
}
|
||||
}
|
||||
else if (input->checkInput(input_up, INPUT_DO_NOT_ALLOW_REPEAT, options.controller[controllerIndex].deviceType, options.controller[controllerIndex].index))
|
||||
else if (input->checkInput(input_up, INPUT_DO_NOT_ALLOW_REPEAT, options.controller[controllerIndex].device_type, options.controller[controllerIndex].index))
|
||||
{
|
||||
player->setInput(input_up);
|
||||
}
|
||||
else if (input->checkInput(input_down, INPUT_DO_NOT_ALLOW_REPEAT, options.controller[controllerIndex].deviceType, options.controller[controllerIndex].index))
|
||||
else if (input->checkInput(input_down, INPUT_DO_NOT_ALLOW_REPEAT, options.controller[controllerIndex].device_type, options.controller[controllerIndex].index))
|
||||
{
|
||||
player->setInput(input_down);
|
||||
}
|
||||
else if (input->checkInput(input_left, INPUT_DO_NOT_ALLOW_REPEAT, options.controller[controllerIndex].deviceType, options.controller[controllerIndex].index))
|
||||
else if (input->checkInput(input_left, INPUT_DO_NOT_ALLOW_REPEAT, options.controller[controllerIndex].device_type, options.controller[controllerIndex].index))
|
||||
{
|
||||
player->setInput(input_left);
|
||||
}
|
||||
else if (input->checkInput(input_right, INPUT_DO_NOT_ALLOW_REPEAT, options.controller[controllerIndex].deviceType, options.controller[controllerIndex].index))
|
||||
else if (input->checkInput(input_right, INPUT_DO_NOT_ALLOW_REPEAT, options.controller[controllerIndex].device_type, options.controller[controllerIndex].index))
|
||||
{
|
||||
player->setInput(input_right);
|
||||
}
|
||||
else if (input->checkInput(input_start, INPUT_DO_NOT_ALLOW_REPEAT, options.controller[controllerIndex].deviceType, options.controller[controllerIndex].index))
|
||||
else if (input->checkInput(input_start, INPUT_DO_NOT_ALLOW_REPEAT, options.controller[controllerIndex].device_type, options.controller[controllerIndex].index))
|
||||
{
|
||||
player->setInput(input_start);
|
||||
addScoreToScoreBoard(player->getRecordName(), player->getScore());
|
||||
@@ -2206,7 +2206,7 @@ void Game::renderMessages()
|
||||
// GetReady
|
||||
if (counter < STAGE_COUNTER && !demo.enabled)
|
||||
{
|
||||
textNokiaBig2->write((int)getReadyBitmapPath[counter], param.game.play_area.centerY - 8, lang::getText(75), -2);
|
||||
textNokiaBig2->write((int)getReadyBitmapPath[counter], param.game.play_area.center_y - 8, lang::getText(75), -2);
|
||||
}
|
||||
|
||||
// Time Stopped
|
||||
@@ -2214,7 +2214,7 @@ void Game::renderMessages()
|
||||
{
|
||||
if (timeStoppedCounter > 100 || timeStoppedCounter % 10 > 4)
|
||||
{
|
||||
textNokia2->writeDX(TXT_CENTER, param.game.play_area.centerX, param.game.play_area.firstQuarterY, lang::getText(36) + std::to_string(timeStoppedCounter / 10), -1, noColor, 1, shdwTxtColor);
|
||||
textNokia2->writeDX(TXT_CENTER, param.game.play_area.center_x, param.game.play_area.first_quarter_y, lang::getText(36) + std::to_string(timeStoppedCounter / 10), -1, no_color, 1, shdw_txt_color);
|
||||
}
|
||||
|
||||
if (timeStoppedCounter > 100)
|
||||
@@ -2250,13 +2250,13 @@ void Game::renderMessages()
|
||||
|
||||
if (!gameCompleted)
|
||||
{ // Escribe el número de fases restantes
|
||||
textNokiaBig2->writeDX(TXT_CENTER, param.game.play_area.centerX, stageBitmapPath[stageBitmapCounter], text, -2, noColor, 2, shdwTxtColor);
|
||||
textNokiaBig2->writeDX(TXT_CENTER, param.game.play_area.center_x, stageBitmapPath[stageBitmapCounter], text, -2, no_color, 2, shdw_txt_color);
|
||||
}
|
||||
else
|
||||
{ // Escribe el texto de juego completado
|
||||
text = lang::getText(50);
|
||||
textNokiaBig2->writeDX(TXT_CENTER, param.game.play_area.centerX, stageBitmapPath[stageBitmapCounter], text, -2, noColor, 1, shdwTxtColor);
|
||||
textNokia2->writeDX(TXT_CENTER, param.game.play_area.centerX, stageBitmapPath[stageBitmapCounter] + textNokiaBig2->getCharacterSize() + 2, lang::getText(76), -1, noColor, 1, shdwTxtColor);
|
||||
textNokiaBig2->writeDX(TXT_CENTER, param.game.play_area.center_x, stageBitmapPath[stageBitmapCounter], text, -2, no_color, 1, shdw_txt_color);
|
||||
textNokia2->writeDX(TXT_CENTER, param.game.play_area.center_x, stageBitmapPath[stageBitmapCounter] + textNokiaBig2->getCharacterSize() + 2, lang::getText(76), -1, no_color, 1, shdw_txt_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2353,8 +2353,8 @@ void Game::initPaths()
|
||||
// Letrero de STAGE #
|
||||
constexpr auto firstPart = STAGE_COUNTER / 4; // 50
|
||||
constexpr auto secondPart = firstPart * 3; // 150
|
||||
const auto centerPoint = param.game.play_area.centerY - (BLOCK * 2);
|
||||
const auto distance = (param.game.play_area.rect.h) - (param.game.play_area.centerY - 16);
|
||||
const auto centerPoint = param.game.play_area.center_y - (BLOCK * 2);
|
||||
const auto distance = (param.game.play_area.rect.h) - (param.game.play_area.center_y - 16);
|
||||
|
||||
for (int i = 0; i < STAGE_COUNTER; ++i)
|
||||
{
|
||||
@@ -2378,7 +2378,7 @@ void Game::initPaths()
|
||||
const auto size = textNokiaBig2->lenght(lang::getText(75), -2);
|
||||
|
||||
const float start1 = param.game.play_area.rect.x - size;
|
||||
const float finish1 = param.game.play_area.centerX - (size / 2);
|
||||
const float finish1 = param.game.play_area.center_x - (size / 2);
|
||||
|
||||
const float start2 = finish1;
|
||||
const float finish2 = param.game.play_area.rect.w;
|
||||
@@ -2669,7 +2669,7 @@ void Game::pause(bool value)
|
||||
void Game::addScoreToScoreBoard(std::string name, int score)
|
||||
{
|
||||
const auto entry = (HiScoreEntry){trim(name), score};
|
||||
auto manager = std::make_unique<ManageHiScoreTable>(&options.game.hiScoreTable);
|
||||
auto manager = std::make_unique<ManageHiScoreTable>(&options.game.hi_score_table);
|
||||
manager->add(entry);
|
||||
manager->saveToFile(asset->get("score.bin"));
|
||||
}
|
||||
@@ -2723,11 +2723,11 @@ std::shared_ptr<Player> Game::getPlayer(int id)
|
||||
}
|
||||
|
||||
// Obtiene un controlador a partir del "id" del jugador
|
||||
int Game::getController(int playerId)
|
||||
int Game::getController(int player_id)
|
||||
{
|
||||
for (int i = 0; i < (int)options.controller.size(); ++i)
|
||||
{
|
||||
if (options.controller[i].playerId == playerId)
|
||||
if (options.controller[i].player_id == player_id)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user