fix: la clase title no hacía fade al pasar al modo demo

This commit is contained in:
2024-07-07 22:48:00 +02:00
parent caca21cba5
commit dfc14da179
6 changed files with 44 additions and 24 deletions

View File

@@ -485,3 +485,12 @@ inputs_e Input::to_inputs_e(std::string name)
return input_null;
}
// Activa todos los inputs. Sirve para evitar inputs sin repeticiones pero que ya vienen pulsados cuando checkInput no estaba monitorizando
void Input::allActive(int index)
{
for (int i = 0; i < (int)buttonInputs.size(); ++i)
{
gameControllerBindings[index][i].active = true;
}
}

View File

@@ -149,6 +149,9 @@ public:
// Obtiene el indice a partir del nombre del mando
int getIndexByName(std::string name);
// Activa todos los inputs. Sirve para evitar inputs sin repeticiones pero que ya vienen pulsados cuando checkInput no estaba monitorizando
void allActive(int index);
};
#endif

View File

@@ -69,9 +69,9 @@ void DefineButtons::render()
{
if (enabled)
{
text->writeCentered(x, y - 20, "PLAYER " + std::to_string(indexController + 1));
text->writeCentered(x, y - 10, controllerNames[indexController]);
text->writeCentered(x, y, buttons[indexButton].label);
text->writeCentered(x, y - 10, "PLAYER " + std::to_string(indexController + 1));
text->writeCentered(x, y, controllerNames[indexController]);
text->writeCentered(x, y + 10, buttons[indexButton].label);
}
}
@@ -143,6 +143,8 @@ void DefineButtons::incIndexButton()
// Guarda los cambios en las opciones
saveBindingsToOptions();
//input->allActive(indexController);
// Reinicia variables
indexButton = 0;
indexController = 0;

View File

@@ -16,7 +16,7 @@ Director::Director(int argc, char *argv[])
{
// Inicializa variables
section = new section_t();
section->name = SECTION_PROG_TITLE;
section->name = SECTION_PROG_LOGO;
// Comprueba los parametros del programa
checkProgramArguments(argc, argv);

View File

@@ -206,6 +206,12 @@ void Fade::update()
// Activa el fade
void Fade::activate()
{
// Si ya está habilitado, no hay que volverlo a activar
if (enabled)
{
return;
}
enabled = true;
finished = false;
counter = 0;

View File

@@ -91,6 +91,7 @@ void Title::update()
// Actualiza el objeto 'background'
background->update();
// Actualiza el objeto 'defineButtons'
defineButtons->update();
// Comprueba el fade y si se ha acabado
@@ -133,29 +134,28 @@ void Title::update()
// Sección 2 - La pantalla con el titulo, el fondo animado y la música
else if (section->subsection == SUBSECTION_TITLE_2)
{
if (counter < param->titleCounter)
// El contador solo sube si no estamos definiendo botones
if (!defineButtons->isEnabled())
{
// El contador solo sube si no estamos definiendo botones
if (!defineButtons->isEnabled())
{
counter++;
}
// Reproduce la música
if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED))
{
JA_PlayMusic(music);
}
// Actualiza el logo con el título del juego
gameLogo->update();
// Actualiza el mosaico de fondo
tiledbg->update();
counter++;
}
else if (counter >= param->titleCounter)
// Reproduce la música
if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED))
{
section->name = SECTION_PROG_GAME_DEMO;
JA_PlayMusic(music);
}
// Actualiza el logo con el título del juego
gameLogo->update();
// Actualiza el mosaico de fondo
tiledbg->update();
if (counter == param->titleCounter)
{
fade->activate();
postFade = 3;
}
}
}