From 0af441b5df3973cd0c69f8cb77760c599bb7cfd4 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Mon, 30 Sep 2024 19:35:41 +0200 Subject: [PATCH] =?UTF-8?q?Finalitzada=20la=20part=20de=20entrar=20nom.=20?= =?UTF-8?q?Falta=20posar=20un=20temporitzador=20i=20una=20animaci=C3=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/enter_name.cpp | 7 ++++++- source/game.cpp | 5 ++++- source/player.cpp | 2 +- source/scoreboard.cpp | 28 +++++++++++++--------------- source/screen.cpp | 2 +- 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/source/enter_name.cpp b/source/enter_name.cpp index 0d0132f..a9e7de2 100644 --- a/source/enter_name.cpp +++ b/source/enter_name.cpp @@ -5,7 +5,7 @@ EnterName::EnterName() { // Obtiene el puntero al nombre - name = ""; + name = "A"; // Inicia la lista de caracteres permitidos // characterList = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; @@ -15,6 +15,9 @@ EnterName::EnterName() // Pone la lista de indices para que refleje el nombre updateCharacterIndex(); + + // Actualiza el nombre para que ocupe 8 espacios + updateName(); } // Destructor @@ -71,11 +74,13 @@ void EnterName::updateName() // Actualiza la variable void EnterName::updateCharacterIndex() { + // Rellena de espacios for (int i = 0; i < NAME_LENGHT; ++i) { characterIndex[i] = 0; } + // Coloca los índices en funcion de los caracteres que forman el nombre for (int i = 0; i < (int)name.size(); ++i) { characterIndex[i] = findIndex(name.at(i)); diff --git a/source/game.cpp b/source/game.cpp index 02665ae..e125f1a 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -2265,13 +2265,16 @@ void Game::checkInput() const bool fire3 = input->checkInput(input_fire_right, INPUT_DO_NOT_ALLOW_REPEAT, options.controller[controllerIndex].deviceType, options.controller[controllerIndex].index); if (fire1 || fire2 || fire3) { - player->setInput(input_right); if (player->getRecordNamePos() == 7) { player->setInput(input_start); addScoreToScoreBoard(player->getRecordName(), player->getScore()); player->setStatusPlaying(PLAYER_STATUS_CONTINUE); } + else + { + player->setInput(input_right); + } } else if (input->checkInput(input_up, INPUT_DO_NOT_ALLOW_REPEAT, options.controller[controllerIndex].deviceType, options.controller[controllerIndex].index)) { diff --git a/source/player.cpp b/source/player.cpp index 40ccc9c..066c02e 100644 --- a/source/player.cpp +++ b/source/player.cpp @@ -34,6 +34,7 @@ Player::Player(int id, float x, int y, SDL_Rect *playArea, std::vectorgetName()); init(); } @@ -425,7 +426,6 @@ void Player::setStatusPlaying(int value) break; case PLAYER_STATUS_ENTERING_NAME: - setRecordName(""); break; case PLAYER_STATUS_DYING: diff --git a/source/scoreboard.cpp b/source/scoreboard.cpp index 38d2167..efc15c0 100644 --- a/source/scoreboard.cpp +++ b/source/scoreboard.cpp @@ -309,26 +309,24 @@ void Scoreboard::fillPanelTextures() // ENTER NAME textScoreBoard->writeCentered(slot4_3.x, slot4_3.y, lang::getText(106)); - //color_t selectorColor = lightenColor(color, 36); - color_t textColor = {0xFB, 0xF2, 0x36}; - SDL_Rect rect = {enterNamePos.x, enterNamePos.y, 8, 8}; + SDL_Rect rect = {enterNamePos.x, enterNamePos.y, 5, 7}; + SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xEB, 255); for (int j = 0; j < (int)recordName[i].size(); ++j) { - SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 255); - SDL_RenderDrawLine(renderer, rect.x + 1, rect.y + rect.h + 1, rect.x + rect.w - 2, rect.y + rect.h + 1); if (j == selectorPos[i]) - { - // SDL_SetRenderDrawColor(renderer, selectorColor.r, selectorColor.g, selectorColor.b, 255); - // SDL_RenderFillRect(renderer, &rect); - SDL_SetRenderDrawColor(renderer, textColor.r, textColor.g, textColor.b, 255); - SDL_RenderDrawLine(renderer, rect.x + 1, rect.y + rect.h + 1, rect.x + rect.w - 2, rect.y + rect.h + 1); - textScoreBoard->writeColored(rect.x + 1, rect.y + 1, recordName[i].substr(j, 1), textColor); + {// La letra seleccionada se pinta de forma intermitente + if (counter % 3 > 0) + { + SDL_RenderDrawLine(renderer, rect.x, rect.y + rect.h, rect.x + rect.w, rect.y + rect.h); + textScoreBoard->write(rect.x, rect.y, recordName[i].substr(j, 1)); + } } else { - textScoreBoard->write(rect.x + 1, rect.y + 1, recordName[i].substr(j, 1)); + SDL_RenderDrawLine(renderer, rect.x, rect.y + rect.h, rect.x + rect.w, rect.y + rect.h); + textScoreBoard->write(rect.x, rect.y, recordName[i].substr(j, 1)); } - rect.x += 8; + rect.x += 7; } break; } @@ -402,9 +400,9 @@ void Scoreboard::recalculateAnchors() slot4_4 = {col, row4}; // Primer cuadrado para poner el nombre de record - const int enterNameLenght = 8 * 8; + const int enterNameLenght = 8 * 7; enterNamePos.x = (panelWidth - enterNameLenght) / 2; - enterNamePos.y = row4 - 1; + enterNamePos.y = row4; // Recoloca los sprites if (powerMeterSprite) diff --git a/source/screen.cpp b/source/screen.cpp index 303224c..ce8d3f7 100644 --- a/source/screen.cpp +++ b/source/screen.cpp @@ -68,7 +68,7 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer) fpsCounter = 0; fps = 0; #ifdef DEBUG - showInfo = false; + showInfo = true; #else showInfo = false; #endif