guardar partida pq ja estic fent canvis a cegues a vore si trac açò

This commit is contained in:
2024-07-07 14:38:46 +02:00
parent 3ee04f7e1c
commit ceafe931f1
14 changed files with 201 additions and 111 deletions

View File

@@ -72,9 +72,12 @@ void DefineButtons::render()
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);
if (indexButton > 0)
text->writeCentered(x, y + 10, std::to_string(buttons[indexButton - 1].button));
}
}
// Comprueba el botón que se ha pulsado
void DefineButtons::doJoystickButtonDown(SDL_JoyButtonEvent *event)
{
int i = input->getJoyIndex(event->which);
@@ -89,6 +92,15 @@ void DefineButtons::doJoystickButtonDown(SDL_JoyButtonEvent *event)
incIndexButton();
}
// Asigna los botones definidos al input
void DefineButtons::bindButtons()
{
for (int i = 0; i < (int)buttons.size(); ++i)
{
input->bindGameControllerButton(indexController, buttons[i].input, buttons[i].button);
}
}
// Comprueba las entradas
void DefineButtons::checkInput()
{
@@ -109,8 +121,10 @@ void DefineButtons::checkInput()
void DefineButtons::enable(int index)
{
enabled = true;
indexController = index - 1;
indexController = index;
indexButton = 0;
input->printBindings(INPUT_USE_GAMECONTROLLER, indexController);
}
// Comprueba si está habilitado
@@ -124,8 +138,16 @@ void DefineButtons::incIndexButton()
{
indexButton++;
// Comprueba si ha finalizado
if (indexButton == (int)buttons.size())
{
// Asigna los botones definidos al input
bindButtons();
input->printBindings(INPUT_USE_GAMECONTROLLER, indexController);
// Reinicia variables
indexButton = 0;
indexController = 0;
enabled = false;
}
}