diff --git a/data/config/param.txt b/data/config/param.txt index c7ac439..d12ecf0 100644 --- a/data/config/param.txt +++ b/data/config/param.txt @@ -12,9 +12,9 @@ venetianSize 16 #SCOREBOARD scoreboard.x 0 -scoreboard.y 208 +scoreboard.y 200 scoreboard.w 320 -scoreboard.h 32 +scoreboard.h 40 #TITLE pressStart 160 diff --git a/source/const.h b/source/const.h index 8f03f67..f16010a 100644 --- a/source/const.h +++ b/source/const.h @@ -14,15 +14,9 @@ #define WIDTH 320 #define HEIGHT 240 -// Marcador -const int SCOREBOARD_WIDTH = WIDTH; -const int SCOREBOARD_HEIGHT = 32; -const int SCOREBOARD_X = 0; -const int SCOREBOARD_Y = HEIGHT - SCOREBOARD_HEIGHT; - // Zona de juego const SDL_Rect windowArea = {0, 0, WIDTH, HEIGHT}; -const SDL_Rect playArea = {0, 0, WIDTH, HEIGHT - SCOREBOARD_HEIGHT}; +const SDL_Rect playArea = {0, 0, WIDTH, 200}; const int PLAY_AREA_TOP = 0; const int PLAY_AREA_BOTTOM = playArea.h; const int PLAY_AREA_LEFT = 0; diff --git a/source/define_buttons.cpp b/source/define_buttons.cpp index 2843b34..12c1204 100644 --- a/source/define_buttons.cpp +++ b/source/define_buttons.cpp @@ -1,7 +1,7 @@ #include "define_buttons.h" // Constructor -DefineButtons::DefineButtons(SDL_Renderer *renderer, Input *input, Text *text, param_t *param, options_t *options) +DefineButtons::DefineButtons(SDL_Renderer *renderer, Input *input, Text *text, param_t *param, options_t *options, section_t *section) { // Copia punteros a los objetos this->renderer = renderer; @@ -9,6 +9,7 @@ DefineButtons::DefineButtons(SDL_Renderer *renderer, Input *input, Text *text, p this->text = text; this->param = param; this->options = options; + this->section = section; // Inicializa variables enabled = false; @@ -109,6 +110,13 @@ void DefineButtons::checkInput() // Comprueba los eventos que hay en la cola while (SDL_PollEvent(&event)) { + // Evento de salida de la aplicación + if (event.type == SDL_QUIT) + { + section->name = SECTION_PROG_QUIT; + break; + } + if (event.type == SDL_CONTROLLERBUTTONDOWN) doControllerButtonDown(&event.cbutton); } @@ -143,7 +151,7 @@ void DefineButtons::incIndexButton() // Guarda los cambios en las opciones saveBindingsToOptions(); - //input->allActive(indexController); + input->allActive(indexController); // Reinicia variables indexButton = 0; diff --git a/source/define_buttons.h b/source/define_buttons.h index 5acd04e..f719698 100644 --- a/source/define_buttons.h +++ b/source/define_buttons.h @@ -3,6 +3,7 @@ #include #include "common/input.h" #include "common/text.h" +#include "const.h" #ifndef DEFINE_BUTTONS_H #define DEFINE_BUTTONS_H @@ -26,6 +27,7 @@ private: // Variables options_t *options; // Variable con todas las variables de las opciones del programa param_t *param; // Puntero con todos los parametros del programa + section_t *section; // Indicador para el bucle del titulo bool enabled; // Indica si el objeto está habilitado int x; // Posición donde dibujar el texto int y; // Posición donde dibujar el texto @@ -48,7 +50,7 @@ private: public: // Constructor - DefineButtons(SDL_Renderer *renderer, Input *input, Text *text, param_t *param, options_t *options); + DefineButtons(SDL_Renderer *renderer, Input *input, Text *text, param_t *param, options_t *options, section_t *section); // Destructor ~DefineButtons(); diff --git a/source/game.cpp b/source/game.cpp index ebb5789..03a42f2 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -2653,7 +2653,7 @@ void Game::renderSeparator() { // Dibuja la linea que separa el marcador de la zona de juego SDL_SetRenderDrawColor(renderer, separator.r, separator.g, separator.b, 255); - SDL_RenderDrawLine(renderer, SCOREBOARD_X, SCOREBOARD_Y, SCOREBOARD_X + SCOREBOARD_WIDTH, SCOREBOARD_Y); + SDL_RenderDrawLine(renderer, param->scoreboard.x, param->scoreboard.y, param->scoreboard.x + param->scoreboard.w, param->scoreboard.y); } // Dibuja los elementos de la zona de juego en su textura diff --git a/source/title.cpp b/source/title.cpp index 04ff1d9..e2eba0e 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -36,7 +36,7 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset, gameLogo = new GameLogo(renderer, screen, asset, param, GAMECANVAS_CENTER_X, GAMECANVAS_FIRST_QUARTER_Y + 20); gameLogo->enable(); - defineButtons = new DefineButtons(renderer, input, text2, param, options); + defineButtons = new DefineButtons(renderer, input, text2, param, options, section); // Inicializa los valores init(); @@ -220,10 +220,22 @@ void Title::checkEvents() break; } + // Recarga las texturas else if (eventHandler->type == SDL_RENDER_DEVICE_RESET || eventHandler->type == SDL_RENDER_TARGETS_RESET) { reLoadTextures(); } + + // Comprueba en el primer mando el botón de salir del programa + else if (eventHandler->type == SDL_CONTROLLERBUTTONDOWN) + { + if ((SDL_GameControllerButton)eventHandler->cbutton.which == 0) + if ((SDL_GameControllerButton)eventHandler->cbutton.button == input->getControllerBinding(0, input_exit)) + { + section->name = SECTION_PROG_QUIT; + break; + } + } } } } @@ -241,17 +253,14 @@ void Title::checkInput() fade->activate(); postFade = index; } - } - // Comprueba el teclado para salir - if (input->checkInput(input_exit, DO_NOT_ALLOW_REPEAT)) - { - section->name = SECTION_PROG_QUIT; - } + // Comprueba el teclado para salir + if (input->checkInput(input_exit, DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD)) + { + section->name = SECTION_PROG_QUIT; + } - // Comprueba si se ha pulsado la tecla 1 o 2 para definir los controladores - if (!defineButtons->isEnabled()) - { + // Comprueba si se ha pulsado la tecla 1 o 2 para definir los controladores const Uint8 *keyStates = SDL_GetKeyboardState(nullptr); if (keyStates[SDL_SCANCODE_1] != 0)