Ya funcionan los nuevos inputs de teclado y mando durante las instrucciones

This commit is contained in:
2023-02-12 19:19:39 +01:00
parent 856415c8c4
commit b8bb1b144f
3 changed files with 57 additions and 24 deletions

View File

@@ -4,12 +4,13 @@
const Uint8 SELF = 0;
// Constructor
Instructions::Instructions(SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang)
Instructions::Instructions(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang)
{
// Copia los punteros
this->renderer = renderer;
this->screen = screen;
this->asset = asset;
this->input = input;
this->lang = lang;
// Reserva memoria para los punteros
@@ -75,6 +76,9 @@ void Instructions::update()
// Comprueba los eventos
checkEventHandler();
// Comprueba las entradas
checkInput();
// Actualiza las variables
if (SDL_GetTicks() - ticks > ticksSpeed)
{
@@ -216,8 +220,33 @@ void Instructions::checkEventHandler()
section.name = PROG_SECTION_QUIT;
break;
}
}
}
if ((eventHandler->type == SDL_KEYUP) || (eventHandler->type == SDL_JOYBUTTONUP))
// Comprueba las entradas
void Instructions::checkInput()
{
if (input->checkInput(input_exit, REPEAT_FALSE))
{
section.name = PROG_SECTION_QUIT;
}
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
{
screen->switchVideoMode();
}
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
{
screen->decWindowSize();
}
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
{
screen->incWindowSize();
}
else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_fire_left, REPEAT_FALSE) || input->checkInput(input_fire_center, REPEAT_FALSE) || input->checkInput(input_fire_right, REPEAT_FALSE))
{
if (mode == m_auto)
{
@@ -233,7 +262,6 @@ void Instructions::checkEventHandler()
}
}
}
}
}
// Bucle para la pantalla de instrucciones

View File

@@ -2,6 +2,7 @@
#include <SDL2/SDL.h>
#include "common/asset.h"
#include "common/input.h"
#include "common/jail_audio.h"
#include "common/screen.h"
#include "common/sprite.h"
@@ -30,6 +31,7 @@ private:
SDL_Texture *backbuffer; // Textura para usar como backbuffer
Sprite *sprite; // Sprite con la textura de las instrucciones
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
Input *input; // Objeto pata gestionar la entrada
Lang *lang; // Objeto para gestionar los textos en diferentes idiomas
Text *text; // Objeto para escribir texto
@@ -51,9 +53,12 @@ private:
// Comprueba los eventos
void checkEventHandler();
// Comprueba las entradas
void checkInput();
public:
// Constructor
Instructions(SDL_Renderer *renderer, Screen *screen, Asset *mAsset, Lang *lang);
Instructions(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang);
// Destructor
~Instructions();

View File

@@ -957,7 +957,7 @@ section_t Title::run()
// Ejecuta la parte donde se muestran las instrucciones
section_t Title::runInstructions(mode_e mode)
{
instructions = new Instructions(renderer, screen, asset, lang);
instructions = new Instructions(renderer, screen, asset, input, lang);
section = instructions->run(mode);
delete instructions;