Compare commits

...

4 Commits

8 changed files with 58 additions and 49 deletions

View File

@@ -22,7 +22,7 @@ scoreboard.w 320
scoreboard.h 40 scoreboard.h 40
## TITLE ## TITLE
title.pressStartPosition 170 title.pressStartPosition 180
title.titleDuration 800 title.titleDuration 800
title.arcadeEditionPosition 123 title.arcadeEditionPosition 123
title.titleCCPosition 80 title.titleCCPosition 80

View File

@@ -5,7 +5,7 @@
EnterName::EnterName() EnterName::EnterName()
{ {
// Obtiene el puntero al nombre // Obtiene el puntero al nombre
name = ""; name = "A";
// Inicia la lista de caracteres permitidos // Inicia la lista de caracteres permitidos
// characterList = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; // characterList = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
@@ -15,6 +15,9 @@ EnterName::EnterName()
// Pone la lista de indices para que refleje el nombre // Pone la lista de indices para que refleje el nombre
updateCharacterIndex(); updateCharacterIndex();
// Actualiza el nombre para que ocupe 8 espacios
updateName();
} }
// Destructor // Destructor
@@ -71,11 +74,13 @@ void EnterName::updateName()
// Actualiza la variable // Actualiza la variable
void EnterName::updateCharacterIndex() void EnterName::updateCharacterIndex()
{ {
// Rellena de espacios
for (int i = 0; i < NAME_LENGHT; ++i) for (int i = 0; i < NAME_LENGHT; ++i)
{ {
characterIndex[i] = 0; characterIndex[i] = 0;
} }
// Coloca los índices en funcion de los caracteres que forman el nombre
for (int i = 0; i < (int)name.size(); ++i) for (int i = 0; i < (int)name.size(); ++i)
{ {
characterIndex[i] = findIndex(name.at(i)); characterIndex[i] = findIndex(name.at(i));

View File

@@ -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); 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) if (fire1 || fire2 || fire3)
{ {
player->setInput(input_right);
if (player->getRecordNamePos() == 7) if (player->getRecordNamePos() == 7)
{ {
player->setInput(input_start); player->setInput(input_start);
addScoreToScoreBoard(player->getRecordName(), player->getScore()); addScoreToScoreBoard(player->getRecordName(), player->getScore());
player->setStatusPlaying(PLAYER_STATUS_CONTINUE); 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)) else if (input->checkInput(input_up, INPUT_DO_NOT_ALLOW_REPEAT, options.controller[controllerIndex].deviceType, options.controller[controllerIndex].index))
{ {

View File

@@ -24,8 +24,8 @@ int main(int argc, char *argv[])
// Destruye el objeto Director // Destruye el objeto Director
delete director; delete director;
const std::string endType = exit == 0 ? "to terminal" : "shutdown"; const std::string endType = exit == 0 ? "keyboard" : "controller";
std::cout << "\nGame end -> " << endType << std::endl; std::cout << "\nGame end with " << endType << std::endl;
return exit; return exit;
} }

View File

@@ -34,6 +34,7 @@ Player::Player(int id, float x, int y, SDL_Rect *playArea, std::vector<Texture *
statusPlaying = PLAYER_STATUS_WAITING; statusPlaying = PLAYER_STATUS_WAITING;
scoreBoardPanel = 0; scoreBoardPanel = 0;
name = ""; name = "";
setRecordName(enterName->getName());
init(); init();
} }
@@ -425,7 +426,6 @@ void Player::setStatusPlaying(int value)
break; break;
case PLAYER_STATUS_ENTERING_NAME: case PLAYER_STATUS_ENTERING_NAME:
setRecordName("");
break; break;
case PLAYER_STATUS_DYING: case PLAYER_STATUS_DYING:

View File

@@ -309,26 +309,24 @@ void Scoreboard::fillPanelTextures()
// ENTER NAME // ENTER NAME
textScoreBoard->writeCentered(slot4_3.x, slot4_3.y, lang::getText(106)); textScoreBoard->writeCentered(slot4_3.x, slot4_3.y, lang::getText(106));
//color_t selectorColor = lightenColor(color, 36); SDL_Rect rect = {enterNamePos.x, enterNamePos.y, 5, 7};
color_t textColor = {0xFB, 0xF2, 0x36}; SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xEB, 255);
SDL_Rect rect = {enterNamePos.x, enterNamePos.y, 8, 8};
for (int j = 0; j < (int)recordName[i].size(); ++j) 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]) if (j == selectorPos[i])
{ {// La letra seleccionada se pinta de forma intermitente
// SDL_SetRenderDrawColor(renderer, selectorColor.r, selectorColor.g, selectorColor.b, 255); if (counter % 3 > 0)
// SDL_RenderFillRect(renderer, &rect); {
SDL_SetRenderDrawColor(renderer, textColor.r, textColor.g, textColor.b, 255); SDL_RenderDrawLine(renderer, rect.x, rect.y + rect.h, rect.x + rect.w, rect.y + rect.h);
SDL_RenderDrawLine(renderer, rect.x + 1, rect.y + rect.h + 1, rect.x + rect.w - 2, rect.y + rect.h + 1); textScoreBoard->write(rect.x, rect.y, recordName[i].substr(j, 1));
textScoreBoard->writeColored(rect.x + 1, rect.y + 1, recordName[i].substr(j, 1), textColor); }
} }
else 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; break;
} }
@@ -402,9 +400,9 @@ void Scoreboard::recalculateAnchors()
slot4_4 = {col, row4}; slot4_4 = {col, row4};
// Primer cuadrado para poner el nombre de record // Primer cuadrado para poner el nombre de record
const int enterNameLenght = 8 * 8; const int enterNameLenght = 8 * 7;
enterNamePos.x = (panelWidth - enterNameLenght) / 2; enterNamePos.x = (panelWidth - enterNameLenght) / 2;
enterNamePos.y = row4 - 1; enterNamePos.y = row4;
// Recoloca los sprites // Recoloca los sprites
if (powerMeterSprite) if (powerMeterSprite)

View File

@@ -68,7 +68,7 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer)
fpsCounter = 0; fpsCounter = 0;
fps = 0; fps = 0;
#ifdef DEBUG #ifdef DEBUG
showInfo = false; showInfo = true;
#else #else
showInfo = false; showInfo = false;
#endif #endif

View File

@@ -1,25 +1,25 @@
#include "title.h" #include "title.h"
#include <SDL2/SDL_keycode.h> // for SDLK_1, SDLK_2, SDLK_3 #include <SDL2/SDL_keycode.h> // for SDLK_1, SDLK_2, SDLK_3
#include <SDL2/SDL_render.h> // for SDL_Renderer #include <SDL2/SDL_render.h> // for SDL_Renderer
#include <SDL2/SDL_timer.h> // for SDL_GetTicks #include <SDL2/SDL_timer.h> // for SDL_GetTicks
#include <string> // for allocator, basic_string, char_traits #include <string> // for allocator, basic_string, char_traits
#include <vector> // for vector #include <vector> // for vector
#include "asset.h" // for Asset #include "asset.h" // for Asset
#include "define_buttons.h" // for DefineButtons #include "define_buttons.h" // for DefineButtons
#include "fade.h" // for Fade, FADE_RANDOM_SQUARE #include "fade.h" // for Fade, FADE_RANDOM_SQUARE
#include "game_logo.h" // for GameLogo #include "game_logo.h" // for GameLogo
#include "global_inputs.h" // for checkGlobalInputs #include "global_inputs.h" // for checkGlobalInputs
#include "input.h" // for Input, inputs_e, INPUT_DO_NOT_ALLOW_RE... #include "input.h" // for Input, inputs_e, INPUT_DO_NOT_ALLOW_RE...
#include "jail_audio.h" // for JA_GetMusicState, JA_Music_state, JA_P... #include "jail_audio.h" // for JA_GetMusicState, JA_Music_state, JA_P...
#include "lang.h" // for getText #include "lang.h" // for getText
#include "options.h" // for options #include "options.h" // for options
#include "param.h" // for param #include "param.h" // for param
#include "screen.h" // for Screen #include "screen.h" // for Screen
#include "section.h" // for options_e, options, name_e, name #include "section.h" // for options_e, options, name_e, name
#include "sprite.h" // for Sprite #include "sprite.h" // for Sprite
#include "text.h" // for Text, TXT_CENTER, TXT_SHADOW #include "text.h" // for Text, TXT_CENTER, TXT_SHADOW
#include "texture.h" // for Texture #include "texture.h" // for Texture
#include "tiled_bg.h" // for Tiledbg, TILED_MODE_RANDOM #include "tiled_bg.h" // for Tiledbg, TILED_MODE_RANDOM
struct JA_Music_t; struct JA_Music_t;
// Constructor // Constructor
@@ -299,12 +299,15 @@ void Title::checkInput()
// Comprueba el botón de START de los mandos // Comprueba el botón de START de los mandos
if (input->checkInput(input_start, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i)) if (input->checkInput(input_start, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{ { // Si no está el botón de servicio activo
if (section::options == section::OPTIONS_TITLE_2 || ALLOW_TITLE_ANIMATION_SKIP) if (!input->checkInput(input_service, INPUT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{ {
fade->activate(); if (section::options == section::OPTIONS_TITLE_2 || ALLOW_TITLE_ANIMATION_SKIP)
postFade = options.controller[i].playerId; {
return; fade->activate();
postFade = options.controller[i].playerId;
return;
}
} }
} }
} }
@@ -313,7 +316,7 @@ void Title::checkInput()
// Comprueba el input para el resto de objetos // Comprueba el input para el resto de objetos
screen->checkInput(); screen->checkInput();
defineButtons->checkInput(); defineButtons->checkInput();
// Comprueba los inputs que se pueden introducir en cualquier sección del juego // Comprueba los inputs que se pueden introducir en cualquier sección del juego
checkGlobalInputs(); checkGlobalInputs();
} }