fix: al voler definir els botons dels mandos sense tindre cap mando conectat, petava tot

This commit is contained in:
2024-07-26 11:58:03 +02:00
parent 1632441c31
commit 5e5d7f5f27
3 changed files with 14 additions and 11 deletions

View File

@@ -111,11 +111,11 @@ void DefineButtons::checkInput()
while (SDL_PollEvent(&event)) while (SDL_PollEvent(&event))
{ {
// Evento de salida de la aplicación // Evento de salida de la aplicación
if (event.type == SDL_QUIT) if (event.type == SDL_QUIT)
{ {
section->name = SECTION_PROG_QUIT; section->name = SECTION_PROG_QUIT;
break; break;
} }
if (event.type == SDL_CONTROLLERBUTTONDOWN) if (event.type == SDL_CONTROLLERBUTTONDOWN)
doControllerButtonDown(&event.cbutton); doControllerButtonDown(&event.cbutton);
@@ -126,9 +126,12 @@ void DefineButtons::checkInput()
// Habilita el objeto // Habilita el objeto
void DefineButtons::enable(int index) void DefineButtons::enable(int index)
{ {
enabled = true; if (input->getNumControllers() > 0)
indexController = index; {
indexButton = 0; enabled = true;
indexController = index;
indexButton = 0;
}
} }
// Comprueba si está habilitado // Comprueba si está habilitado

View File

@@ -215,7 +215,7 @@ void Scoreboard::fillBackgroundTexture()
else if (mode[SCOREBOARD_LEFT_SIDE] == SCOREBOARD_MODE_DEMO) 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(offsetScoreP1.x, offsetScoreP1.y, "Mode");
textScoreBoard->writeCentered(offsetMultP1Label.x, offsetMultP1Label.y, "Demo"); textScoreBoard->writeCentered(offsetMultP1Label.x, offsetMultP1Label.y, "Demo");
@@ -235,7 +235,7 @@ void Scoreboard::fillBackgroundTexture()
else if (mode[SCOREBOARD_RIGHT_SIDE] == SCOREBOARD_MODE_DEMO) 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(offsetScoreP2.x, offsetScoreP2.y, "Mode");
textScoreBoard->writeCentered(offsetMultP2Label.x, offsetMultP2Label.y, "Demo"); textScoreBoard->writeCentered(offsetMultP2Label.x, offsetMultP2Label.y, "Demo");

View File

@@ -19,7 +19,7 @@ enum scoreboard_modes_e
#define SCOREBOARD_LEFT_SIDE 0 #define SCOREBOARD_LEFT_SIDE 0
#define SCOREBOARD_RIGHT_SIDE 1 #define SCOREBOARD_RIGHT_SIDE 1
#define SCOREBOARD_TICK_SPEED 1000 #define SCOREBOARD_TICK_SPEED 100
// Clase Scoreboard // Clase Scoreboard
class Scoreboard class Scoreboard