From 5e5d7f5f2784ae8bf4c96b480350eab8db23a0e9 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Fri, 26 Jul 2024 11:58:03 +0200 Subject: [PATCH] fix: al voler definir els botons dels mandos sense tindre cap mando conectat, petava tot --- source/define_buttons.cpp | 19 +++++++++++-------- source/scoreboard.cpp | 4 ++-- source/scoreboard.h | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/source/define_buttons.cpp b/source/define_buttons.cpp index 12c1204..5c4b4a0 100644 --- a/source/define_buttons.cpp +++ b/source/define_buttons.cpp @@ -111,11 +111,11 @@ void DefineButtons::checkInput() 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_QUIT) + { + section->name = SECTION_PROG_QUIT; + break; + } if (event.type == SDL_CONTROLLERBUTTONDOWN) doControllerButtonDown(&event.cbutton); @@ -126,9 +126,12 @@ void DefineButtons::checkInput() // Habilita el objeto void DefineButtons::enable(int index) { - enabled = true; - indexController = index; - indexButton = 0; + if (input->getNumControllers() > 0) + { + enabled = true; + indexController = index; + indexButton = 0; + } } // Comprueba si está habilitado diff --git a/source/scoreboard.cpp b/source/scoreboard.cpp index e0da421..bfd1aaa 100644 --- a/source/scoreboard.cpp +++ b/source/scoreboard.cpp @@ -215,7 +215,7 @@ void Scoreboard::fillBackgroundTexture() else if (mode[SCOREBOARD_LEFT_SIDE] == SCOREBOARD_MODE_DEMO) { - if (counter % 2 == 0) + if (counter % 10 < 8) { textScoreBoard->writeCentered(offsetScoreP1.x, offsetScoreP1.y, "Mode"); textScoreBoard->writeCentered(offsetMultP1Label.x, offsetMultP1Label.y, "Demo"); @@ -235,7 +235,7 @@ void Scoreboard::fillBackgroundTexture() else if (mode[SCOREBOARD_RIGHT_SIDE] == SCOREBOARD_MODE_DEMO) { - if (counter % 2 == 0) + if (counter % 10 < 8) { textScoreBoard->writeCentered(offsetScoreP2.x, offsetScoreP2.y, "Mode"); textScoreBoard->writeCentered(offsetMultP2Label.x, offsetMultP2Label.y, "Demo"); diff --git a/source/scoreboard.h b/source/scoreboard.h index d794ee7..ee792e0 100644 --- a/source/scoreboard.h +++ b/source/scoreboard.h @@ -19,7 +19,7 @@ enum scoreboard_modes_e #define SCOREBOARD_LEFT_SIDE 0 #define SCOREBOARD_RIGHT_SIDE 1 -#define SCOREBOARD_TICK_SPEED 1000 +#define SCOREBOARD_TICK_SPEED 100 // Clase Scoreboard class Scoreboard