Reasignados los controles para ordenador, mando y consola
This commit is contained in:
@@ -11,17 +11,15 @@ Input::Input(std::string file)
|
|||||||
keyBindings_t kb;
|
keyBindings_t kb;
|
||||||
kb.scancode = 0;
|
kb.scancode = 0;
|
||||||
kb.active = false;
|
kb.active = false;
|
||||||
keyBindings.resize(17, kb);
|
keyBindings.resize(input_number_of_inputs, kb);
|
||||||
|
|
||||||
GameControllerBindings_t gcb;
|
GameControllerBindings_t gcb;
|
||||||
gcb.button = SDL_CONTROLLER_BUTTON_INVALID;
|
gcb.button = SDL_CONTROLLER_BUTTON_INVALID;
|
||||||
gcb.active = false;
|
gcb.active = false;
|
||||||
gameControllerBindings.resize(17, gcb);
|
gameControllerBindings.resize(input_number_of_inputs, gcb);
|
||||||
|
|
||||||
verbose = true;
|
verbose = true;
|
||||||
enabled = true;
|
enabled = true;
|
||||||
|
|
||||||
numGamepads = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el estado del objeto
|
// Actualiza el estado del objeto
|
||||||
|
|||||||
@@ -7,23 +7,30 @@
|
|||||||
#ifndef INPUT_H
|
#ifndef INPUT_H
|
||||||
#define INPUT_H
|
#define INPUT_H
|
||||||
|
|
||||||
#define INPUT_NULL 0
|
enum inputs_e
|
||||||
#define INPUT_UP 1
|
{
|
||||||
#define INPUT_DOWN 2
|
// Inputs obligatorios
|
||||||
#define INPUT_LEFT 3
|
input_null,
|
||||||
#define INPUT_RIGHT 4
|
input_up,
|
||||||
#define INPUT_ACCEPT 5
|
input_down,
|
||||||
#define INPUT_CANCEL 6
|
input_left,
|
||||||
#define INPUT_BUTTON_1 7
|
input_right,
|
||||||
#define INPUT_BUTTON_2 8
|
input_pause,
|
||||||
#define INPUT_BUTTON_3 9
|
input_exit,
|
||||||
#define INPUT_BUTTON_4 10
|
input_accept,
|
||||||
#define INPUT_BUTTON_5 11
|
input_cancel,
|
||||||
#define INPUT_BUTTON_6 12
|
|
||||||
#define INPUT_BUTTON_7 13
|
// Inputs personalizados
|
||||||
#define INPUT_BUTTON_8 14
|
input_fire_left,
|
||||||
#define INPUT_BUTTON_PAUSE 15
|
input_fire_center,
|
||||||
#define INPUT_BUTTON_ESCAPE 16
|
input_fire_right,
|
||||||
|
input_window_fullscreen,
|
||||||
|
input_window_inc_size,
|
||||||
|
input_window_dec_size,
|
||||||
|
|
||||||
|
// Input obligatorio
|
||||||
|
input_number_of_inputs
|
||||||
|
};
|
||||||
|
|
||||||
#define REPEAT_TRUE true
|
#define REPEAT_TRUE true
|
||||||
#define REPEAT_FALSE false
|
#define REPEAT_FALSE false
|
||||||
@@ -81,7 +88,7 @@ public:
|
|||||||
void bindGameControllerButton(Uint8 input, SDL_GameControllerButton button);
|
void bindGameControllerButton(Uint8 input, SDL_GameControllerButton button);
|
||||||
|
|
||||||
// Comprueba si un input esta activo
|
// Comprueba si un input esta activo
|
||||||
bool checkInput(Uint8 input, bool repeat, int device = INPUT_USE_ANY, int index = 0);
|
bool checkInput(Uint8 input, bool repeat = true, int device = INPUT_USE_ANY, int index = 0);
|
||||||
|
|
||||||
// Comprueba si hay almenos un input activo
|
// Comprueba si hay almenos un input activo
|
||||||
bool checkAnyInput(int device = INPUT_USE_ANY, int index = 0);
|
bool checkAnyInput(int device = INPUT_USE_ANY, int index = 0);
|
||||||
|
|||||||
@@ -851,7 +851,7 @@ void Menu::setDefaultActionWhenCancel(int item)
|
|||||||
// Gestiona la entrada de teclado y mando durante el menu
|
// Gestiona la entrada de teclado y mando durante el menu
|
||||||
void Menu::checkInput()
|
void Menu::checkInput()
|
||||||
{
|
{
|
||||||
if (input->checkInput(INPUT_UP, REPEAT_FALSE))
|
if (input->checkInput(input_up, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
if (decreaseSelectorIndex())
|
if (decreaseSelectorIndex())
|
||||||
{
|
{
|
||||||
@@ -862,7 +862,7 @@ void Menu::checkInput()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input->checkInput(INPUT_DOWN, REPEAT_FALSE))
|
if (input->checkInput(input_down, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
if (increaseSelectorIndex())
|
if (increaseSelectorIndex())
|
||||||
{
|
{
|
||||||
@@ -873,7 +873,7 @@ void Menu::checkInput()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input->checkInput(INPUT_ACCEPT, REPEAT_FALSE))
|
if (input->checkInput(input_accept, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
itemSelected = selector.index;
|
itemSelected = selector.index;
|
||||||
if (soundAccept)
|
if (soundAccept)
|
||||||
@@ -882,7 +882,7 @@ void Menu::checkInput()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input->checkInput(INPUT_CANCEL, REPEAT_FALSE))
|
if (input->checkInput(input_cancel, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
itemSelected = defaultActionWhenCancel;
|
itemSelected = defaultActionWhenCancel;
|
||||||
if (soundCancel)
|
if (soundCancel)
|
||||||
|
|||||||
@@ -78,31 +78,46 @@ Director::~Director()
|
|||||||
// Inicializa el objeto input
|
// Inicializa el objeto input
|
||||||
void Director::initInput()
|
void Director::initInput()
|
||||||
{
|
{
|
||||||
// Teclado
|
// Establece si ha de mostrar mensajes
|
||||||
input->bindKey(INPUT_UP, SDL_SCANCODE_UP);
|
input->setVerbose(options->console);
|
||||||
input->bindKey(INPUT_DOWN, SDL_SCANCODE_DOWN);
|
|
||||||
input->bindKey(INPUT_LEFT, SDL_SCANCODE_LEFT);
|
|
||||||
input->bindKey(INPUT_RIGHT, SDL_SCANCODE_RIGHT);
|
|
||||||
input->bindKey(INPUT_ACCEPT, SDL_SCANCODE_RETURN);
|
|
||||||
input->bindKey(INPUT_CANCEL, SDL_SCANCODE_ESCAPE);
|
|
||||||
input->bindKey(INPUT_BUTTON_1, SDL_SCANCODE_Q);
|
|
||||||
input->bindKey(INPUT_BUTTON_2, SDL_SCANCODE_W);
|
|
||||||
input->bindKey(INPUT_BUTTON_3, SDL_SCANCODE_E);
|
|
||||||
input->bindKey(INPUT_BUTTON_PAUSE, SDL_SCANCODE_ESCAPE); // PAUSE
|
|
||||||
input->bindKey(INPUT_BUTTON_ESCAPE, SDL_SCANCODE_ESCAPE); // ESCAPE
|
|
||||||
|
|
||||||
// Mando
|
// Busca si hay un mando conectado
|
||||||
input->bindGameControllerButton(INPUT_UP, SDL_CONTROLLER_BUTTON_DPAD_UP);
|
input->discoverGameController();
|
||||||
input->bindGameControllerButton(INPUT_DOWN, SDL_CONTROLLER_BUTTON_DPAD_DOWN);
|
|
||||||
input->bindGameControllerButton(INPUT_LEFT, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
|
// Teclado - Movimiento del jugador
|
||||||
input->bindGameControllerButton(INPUT_RIGHT, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
|
input->bindKey(input_up, SDL_SCANCODE_UP);
|
||||||
input->bindGameControllerButton(INPUT_ACCEPT, SDL_CONTROLLER_BUTTON_B);
|
input->bindKey(input_down, SDL_SCANCODE_DOWN);
|
||||||
input->bindGameControllerButton(INPUT_CANCEL, SDL_CONTROLLER_BUTTON_A);
|
input->bindKey(input_left, SDL_SCANCODE_LEFT);
|
||||||
input->bindGameControllerButton(INPUT_BUTTON_1, SDL_CONTROLLER_BUTTON_X);
|
input->bindKey(input_right, SDL_SCANCODE_RIGHT);
|
||||||
input->bindGameControllerButton(INPUT_BUTTON_2, SDL_CONTROLLER_BUTTON_Y);
|
input->bindKey(input_fire_left, SDL_SCANCODE_Q);
|
||||||
input->bindGameControllerButton(INPUT_BUTTON_3, SDL_CONTROLLER_BUTTON_B);
|
input->bindKey(input_fire_center, SDL_SCANCODE_W);
|
||||||
input->bindGameControllerButton(INPUT_BUTTON_PAUSE, SDL_CONTROLLER_BUTTON_GUIDE); // PAUSE
|
input->bindKey(input_fire_right, SDL_SCANCODE_E);
|
||||||
input->bindGameControllerButton(INPUT_BUTTON_ESCAPE, SDL_CONTROLLER_BUTTON_GUIDE); // ESCAPE
|
|
||||||
|
// Teclado - Otros
|
||||||
|
input->bindKey(input_accept, SDL_SCANCODE_RETURN);
|
||||||
|
input->bindKey(input_cancel, SDL_SCANCODE_ESCAPE);
|
||||||
|
input->bindKey(input_pause, SDL_SCANCODE_ESCAPE);
|
||||||
|
input->bindKey(input_exit, SDL_SCANCODE_ESCAPE);
|
||||||
|
|
||||||
|
// Mando - Movimiento del jugador
|
||||||
|
input->bindGameControllerButton(input_up, SDL_CONTROLLER_BUTTON_DPAD_UP);
|
||||||
|
input->bindGameControllerButton(input_down, SDL_CONTROLLER_BUTTON_DPAD_DOWN);
|
||||||
|
input->bindGameControllerButton(input_left, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
|
||||||
|
input->bindGameControllerButton(input_right, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
|
||||||
|
input->bindGameControllerButton(input_fire_left, SDL_CONTROLLER_BUTTON_X);
|
||||||
|
input->bindGameControllerButton(input_fire_center, SDL_CONTROLLER_BUTTON_Y);
|
||||||
|
input->bindGameControllerButton(input_fire_right, SDL_CONTROLLER_BUTTON_B);
|
||||||
|
|
||||||
|
// Mando - Otros
|
||||||
|
input->bindGameControllerButton(input_accept, SDL_CONTROLLER_BUTTON_B);
|
||||||
|
input->bindGameControllerButton(input_cancel, SDL_CONTROLLER_BUTTON_A);
|
||||||
|
#ifdef GAME_CONSOLE
|
||||||
|
input->bindGameControllerButton(input_pause, SDL_CONTROLLER_BUTTON_BACK);
|
||||||
|
input->bindGameControllerButton(input_exit, SDL_CONTROLLER_BUTTON_START);
|
||||||
|
#else
|
||||||
|
input->bindGameControllerButton(input_pause, SDL_CONTROLLER_BUTTON_START);
|
||||||
|
input->bindGameControllerButton(input_exit, SDL_CONTROLLER_BUTTON_BACK);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa JailAudio
|
// Inicializa JailAudio
|
||||||
@@ -591,7 +606,7 @@ void Director::setSection(section_t section)
|
|||||||
|
|
||||||
void Director::runLogo()
|
void Director::runLogo()
|
||||||
{
|
{
|
||||||
logo = new Logo(renderer, screen, asset);
|
logo = new Logo(renderer, screen, asset, input);
|
||||||
setSection(logo->run());
|
setSection(logo->run());
|
||||||
delete logo;
|
delete logo;
|
||||||
}
|
}
|
||||||
@@ -648,37 +663,34 @@ void Director::run()
|
|||||||
void Director::initOnline()
|
void Director::initOnline()
|
||||||
{
|
{
|
||||||
if (options->online.sessionEnabled)
|
if (options->online.sessionEnabled)
|
||||||
{ // Si ya ha iniciado la sesión, que no continue
|
{ // Si ya ha iniciado la sesión, que no continue
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options->online.jailerID == "")
|
if (options->online.jailerID == "")
|
||||||
{ // Jailer ID no definido
|
{ // Jailer ID no definido
|
||||||
|
|
||||||
options->online.enabled = false;
|
options->online.enabled = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // Jailer ID iniciado
|
{ // Jailer ID iniciado
|
||||||
|
|
||||||
options->online.enabled = options->online.sessionEnabled = true;
|
options->online.enabled = options->online.sessionEnabled = true;
|
||||||
jscore::init(options->online.server, options->online.port);
|
jscore::init(options->online.server, options->online.port);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
const std::string caption = options->online.jailerID + " IS LOGGED IN (DEBUG)";
|
const std::string caption = options->online.jailerID + " IS LOGGED IN (DEBUG)";
|
||||||
#else
|
#else
|
||||||
const std::string caption = options->online.jailerID + " IS LOGGED IN";
|
const std::string caption = options->online.jailerID + " IS LOGGED IN";
|
||||||
#endif
|
#endif
|
||||||
screen->showNotification(caption);
|
screen->showNotification(caption);
|
||||||
if (options->console)
|
if (options->console)
|
||||||
{
|
{
|
||||||
std::cout << caption << std::endl;
|
std::cout << caption << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OLD
|
||||||
|
|
||||||
|
|
||||||
// OLD
|
|
||||||
|
|
||||||
if (!options->online.enabled)
|
if (!options->online.enabled)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3018,33 +3018,34 @@ void Game::checkGameInput()
|
|||||||
const int index = 0;
|
const int index = 0;
|
||||||
if (demo.dataFile[demo.counter].left == 1)
|
if (demo.dataFile[demo.counter].left == 1)
|
||||||
{
|
{
|
||||||
players[index]->setInput(INPUT_LEFT);
|
players[index]->setInput(input_left);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (demo.dataFile[demo.counter].right == 1)
|
if (demo.dataFile[demo.counter].right == 1)
|
||||||
{
|
{
|
||||||
players[index]->setInput(INPUT_RIGHT);
|
players[index]->setInput(input_right);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (demo.dataFile[demo.counter].noInput == 1)
|
if (demo.dataFile[demo.counter].noInput == 1)
|
||||||
{
|
{
|
||||||
players[index]->setInput(INPUT_NULL);
|
players[index]->setInput(input_null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (demo.dataFile[demo.counter].fire == 1)
|
if (demo.dataFile[demo.counter].fire == 1)
|
||||||
{
|
{
|
||||||
if (players[index]->canFire())
|
if (players[index]->canFire())
|
||||||
{
|
{
|
||||||
players[index]->setInput(INPUT_BUTTON_2);
|
players[index]->setInput(input_fire_center);
|
||||||
createBullet(players[index]->getPosX() + (players[index]->getWidth() / 2) - 4, players[index]->getPosY() + (players[index]->getHeight() / 2), BULLET_UP, players[index]->isPowerUp(), index);
|
createBullet(players[index]->getPosX() + (players[index]->getWidth() / 2) - 4, players[index]->getPosY() + (players[index]->getHeight() / 2), BULLET_UP, players[index]->isPowerUp(), index);
|
||||||
players[index]->setFireCooldown(10);
|
players[index]->setFireCooldown(10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (demo.dataFile[demo.counter].fireLeft == 1)
|
if (demo.dataFile[demo.counter].fireLeft == 1)
|
||||||
{
|
{
|
||||||
if (players[index]->canFire())
|
if (players[index]->canFire())
|
||||||
{
|
{
|
||||||
players[index]->setInput(INPUT_BUTTON_1);
|
players[index]->setInput(input_fire_left);
|
||||||
createBullet(players[index]->getPosX() + (players[index]->getWidth() / 2) - 4, players[index]->getPosY() + (players[index]->getHeight() / 2), BULLET_UP, players[index]->isPowerUp(), index);
|
createBullet(players[index]->getPosX() + (players[index]->getWidth() / 2) - 4, players[index]->getPosY() + (players[index]->getHeight() / 2), BULLET_UP, players[index]->isPowerUp(), index);
|
||||||
players[index]->setFireCooldown(10);
|
players[index]->setFireCooldown(10);
|
||||||
}
|
}
|
||||||
@@ -3054,14 +3055,14 @@ void Game::checkGameInput()
|
|||||||
{
|
{
|
||||||
if (players[index]->canFire())
|
if (players[index]->canFire())
|
||||||
{
|
{
|
||||||
players[index]->setInput(INPUT_BUTTON_3);
|
players[index]->setInput(input_fire_right);
|
||||||
createBullet(players[index]->getPosX() + (players[index]->getWidth() / 2) - 4, players[index]->getPosY() + (players[index]->getHeight() / 2), BULLET_UP, players[index]->isPowerUp(), index);
|
createBullet(players[index]->getPosX() + (players[index]->getWidth() / 2) - 4, players[index]->getPosY() + (players[index]->getHeight() / 2), BULLET_UP, players[index]->isPowerUp(), index);
|
||||||
players[index]->setFireCooldown(10);
|
players[index]->setFireCooldown(10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba el input de pausa
|
// Comprueba el input de pausa
|
||||||
if (input->checkInput(INPUT_BUTTON_PAUSE, REPEAT_FALSE))
|
if (input->checkInput(input_pause, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
section.name = PROG_SECTION_TITLE;
|
section.name = PROG_SECTION_TITLE;
|
||||||
}
|
}
|
||||||
@@ -3085,32 +3086,32 @@ void Game::checkGameInput()
|
|||||||
if (player->isAlive())
|
if (player->isAlive())
|
||||||
{
|
{
|
||||||
// Input a la izquierda
|
// Input a la izquierda
|
||||||
if (input->checkInput(INPUT_LEFT, REPEAT_TRUE, options->input[i].deviceType, options->input[i].id))
|
if (input->checkInput(input_left, REPEAT_TRUE, options->input[i].deviceType, options->input[i].id))
|
||||||
{
|
{
|
||||||
player->setInput(INPUT_LEFT);
|
player->setInput(input_left);
|
||||||
demo.keys.left = 1;
|
demo.keys.left = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Input a la derecha
|
// Input a la derecha
|
||||||
if (input->checkInput(INPUT_RIGHT, REPEAT_TRUE, options->input[i].deviceType, options->input[i].id))
|
if (input->checkInput(input_right, REPEAT_TRUE, options->input[i].deviceType, options->input[i].id))
|
||||||
{
|
{
|
||||||
player->setInput(INPUT_RIGHT);
|
player->setInput(input_right);
|
||||||
demo.keys.right = 1;
|
demo.keys.right = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Ninguno de los dos inputs anteriores
|
// Ninguno de los dos inputs anteriores
|
||||||
player->setInput(INPUT_NULL);
|
player->setInput(input_null);
|
||||||
demo.keys.noInput = 1;
|
demo.keys.noInput = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Comprueba el input de disparar al centro
|
// Comprueba el input de disparar al centro
|
||||||
if (input->checkInput(INPUT_BUTTON_2, REPEAT_TRUE, options->input[i].deviceType, options->input[i].id))
|
if (input->checkInput(input_fire_center, REPEAT_TRUE, options->input[i].deviceType, options->input[i].id))
|
||||||
{
|
{
|
||||||
if (player->canFire())
|
if (player->canFire())
|
||||||
{
|
{
|
||||||
player->setInput(INPUT_BUTTON_2);
|
player->setInput(input_fire_center);
|
||||||
createBullet(player->getPosX() + (player->getWidth() / 2) - 4, player->getPosY() + (player->getHeight() / 2), BULLET_UP, player->isPowerUp(), i);
|
createBullet(player->getPosX() + (player->getWidth() / 2) - 4, player->getPosY() + (player->getHeight() / 2), BULLET_UP, player->isPowerUp(), i);
|
||||||
player->setFireCooldown(10);
|
player->setFireCooldown(10);
|
||||||
|
|
||||||
@@ -3122,11 +3123,11 @@ void Game::checkGameInput()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba el input de disparar a la izquierda
|
// Comprueba el input de disparar a la izquierda
|
||||||
if (input->checkInput(INPUT_BUTTON_1, REPEAT_TRUE, options->input[i].deviceType, options->input[i].id))
|
if (input->checkInput(input_fire_left, REPEAT_TRUE, options->input[i].deviceType, options->input[i].id))
|
||||||
{
|
{
|
||||||
if (player->canFire())
|
if (player->canFire())
|
||||||
{
|
{
|
||||||
player->setInput(INPUT_BUTTON_1);
|
player->setInput(input_fire_left);
|
||||||
createBullet(player->getPosX() + (player->getWidth() / 2) - 4, player->getPosY() + (player->getHeight() / 2), BULLET_LEFT, player->isPowerUp(), i);
|
createBullet(player->getPosX() + (player->getWidth() / 2) - 4, player->getPosY() + (player->getHeight() / 2), BULLET_LEFT, player->isPowerUp(), i);
|
||||||
player->setFireCooldown(10);
|
player->setFireCooldown(10);
|
||||||
|
|
||||||
@@ -3138,11 +3139,11 @@ void Game::checkGameInput()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba el input de disparar a la derecha
|
// Comprueba el input de disparar a la derecha
|
||||||
if (input->checkInput(INPUT_BUTTON_3, REPEAT_TRUE, options->input[i].deviceType, options->input[i].id))
|
if (input->checkInput(input_fire_right, REPEAT_TRUE, options->input[i].deviceType, options->input[i].id))
|
||||||
{
|
{
|
||||||
if (player->canFire())
|
if (player->canFire())
|
||||||
{
|
{
|
||||||
player->setInput(INPUT_BUTTON_3);
|
player->setInput(input_fire_right);
|
||||||
createBullet(player->getPosX() + (player->getWidth() / 2) - 4, player->getPosY() + (player->getHeight() / 2), BULLET_RIGHT, player->isPowerUp(), i);
|
createBullet(player->getPosX() + (player->getWidth() / 2) - 4, player->getPosY() + (player->getHeight() / 2), BULLET_RIGHT, player->isPowerUp(), i);
|
||||||
player->setFireCooldown(10);
|
player->setFireCooldown(10);
|
||||||
|
|
||||||
@@ -3154,7 +3155,7 @@ void Game::checkGameInput()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba el input de pausa
|
// Comprueba el input de pausa
|
||||||
if (input->checkInput(INPUT_CANCEL, REPEAT_FALSE, options->input[i].deviceType, options->input[i].id))
|
if (input->checkInput(input_cancel, REPEAT_FALSE, options->input[i].deviceType, options->input[i].id))
|
||||||
{
|
{
|
||||||
section.subsection = GAME_SECTION_PAUSE;
|
section.subsection = GAME_SECTION_PAUSE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,13 @@
|
|||||||
#define END_LOGO 200
|
#define END_LOGO 200
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Logo::Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset)
|
Logo::Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input)
|
||||||
{
|
{
|
||||||
// Copia la dirección de los objetos
|
// Copia la dirección de los objetos
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
|
this->input = input;
|
||||||
|
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
@@ -56,47 +57,36 @@ void Logo::checkEventHandler()
|
|||||||
section.name = PROG_SECTION_QUIT;
|
section.name = PROG_SECTION_QUIT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Cualquier tecla pulsada
|
// Comprueba las entradas
|
||||||
if ((eventHandler->type == SDL_KEYDOWN) || (eventHandler->type == SDL_JOYBUTTONDOWN))
|
void Logo::checkInput()
|
||||||
{
|
{
|
||||||
switch (eventHandler->key.keysym.scancode)
|
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
case SDL_SCANCODE_F:
|
section.name = PROG_SECTION_QUIT;
|
||||||
screen->switchVideoMode();
|
}
|
||||||
texture->reLoad();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_SCANCODE_F1:
|
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
|
||||||
screen->setWindowSize(1);
|
{
|
||||||
texture->reLoad();
|
screen->switchVideoMode();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F2:
|
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
|
||||||
screen->setWindowSize(2);
|
{
|
||||||
texture->reLoad();
|
screen->decWindowSize();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F3:
|
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
|
||||||
screen->setWindowSize(3);
|
{
|
||||||
texture->reLoad();
|
screen->incWindowSize();
|
||||||
break;
|
}
|
||||||
|
|
||||||
case SDL_SCANCODE_F4:
|
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))
|
||||||
screen->setWindowSize(4);
|
{
|
||||||
texture->reLoad();
|
section.name = PROG_SECTION_TITLE;
|
||||||
break;
|
section.subsection = TITLE_SECTION_1;
|
||||||
|
|
||||||
case SDL_SCANCODE_F5:
|
|
||||||
screen->showNotification("Conectado a Jailers.net");
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
section.name = PROG_SECTION_TITLE;
|
|
||||||
section.subsection = TITLE_SECTION_1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,6 +107,7 @@ void Logo::renderFade()
|
|||||||
void Logo::update()
|
void Logo::update()
|
||||||
{
|
{
|
||||||
checkEventHandler();
|
checkEventHandler();
|
||||||
|
checkInput();
|
||||||
|
|
||||||
if (SDL_GetTicks() - ticks > ticksSpeed)
|
if (SDL_GetTicks() - ticks > ticksSpeed)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "common/asset.h"
|
#include "common/asset.h"
|
||||||
|
#include "common/input.h"
|
||||||
#include "common/jail_audio.h"
|
#include "common/jail_audio.h"
|
||||||
#include "common/screen.h"
|
#include "common/screen.h"
|
||||||
#include "common/sprite.h"
|
#include "common/sprite.h"
|
||||||
@@ -19,15 +20,16 @@ private:
|
|||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
||||||
|
Input *input; // Objeto pata gestionar la entrada
|
||||||
Texture *texture; // Textura con los graficos
|
Texture *texture; // Textura con los graficos
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
Sprite *sprite; // Sprite con la textura del logo
|
Sprite *sprite; // Sprite con la textura del logo
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
section_t section; // Estado del bucle principal para saber si continua o se sale
|
section_t section; // Estado del bucle principal para saber si continua o se sale
|
||||||
int counter; // Contador
|
int counter; // Contador
|
||||||
|
|
||||||
// Actualiza las variables del objeto
|
// Actualiza las variables del objeto
|
||||||
void update();
|
void update();
|
||||||
@@ -41,12 +43,15 @@ private:
|
|||||||
// Comprueba los eventos
|
// Comprueba los eventos
|
||||||
void checkEventHandler();
|
void checkEventHandler();
|
||||||
|
|
||||||
|
// Comprueba las entradas
|
||||||
|
void checkInput();
|
||||||
|
|
||||||
// Dibuja el fade
|
// Dibuja el fade
|
||||||
void renderFade();
|
void renderFade();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Logo(SDL_Renderer *renderer, Screen *screen, Asset *mAsset);
|
Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Logo();
|
~Logo();
|
||||||
|
|||||||
@@ -95,25 +95,25 @@ void Player::setInput(Uint8 input)
|
|||||||
{
|
{
|
||||||
switch (input)
|
switch (input)
|
||||||
{
|
{
|
||||||
case INPUT_LEFT:
|
case input_left:
|
||||||
velX = -baseSpeed;
|
velX = -baseSpeed;
|
||||||
setWalkingStatus(PLAYER_STATUS_WALKING_LEFT);
|
setWalkingStatus(PLAYER_STATUS_WALKING_LEFT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case INPUT_RIGHT:
|
case input_right:
|
||||||
velX = baseSpeed;
|
velX = baseSpeed;
|
||||||
setWalkingStatus(PLAYER_STATUS_WALKING_RIGHT);
|
setWalkingStatus(PLAYER_STATUS_WALKING_RIGHT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case INPUT_BUTTON_2:
|
case input_fire_center:
|
||||||
setFiringStatus(PLAYER_STATUS_FIRING_UP);
|
setFiringStatus(PLAYER_STATUS_FIRING_UP);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case INPUT_BUTTON_1:
|
case input_fire_left:
|
||||||
setFiringStatus(PLAYER_STATUS_FIRING_LEFT);
|
setFiringStatus(PLAYER_STATUS_FIRING_LEFT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case INPUT_BUTTON_3:
|
case input_fire_right:
|
||||||
setFiringStatus(PLAYER_STATUS_FIRING_RIGHT);
|
setFiringStatus(PLAYER_STATUS_FIRING_RIGHT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user