forked from jaildesigner-jailgames/jaildoctors_dilemma
Arreglos en la estructura i format del codi
This commit is contained in:
@@ -16,7 +16,7 @@ class Text; // lines 15-15
|
|||||||
class Credits
|
class Credits
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
struct captions_t
|
struct Captions
|
||||||
{
|
{
|
||||||
std::string label; // Texto a escribir
|
std::string label; // Texto a escribir
|
||||||
Color color; // Color del texto
|
Color color; // Color del texto
|
||||||
@@ -38,7 +38,7 @@ private:
|
|||||||
bool counter_enabled_ = true; // Indica si esta activo el contador
|
bool counter_enabled_ = true; // Indica si esta activo el contador
|
||||||
int sub_counter_ = 0; // Contador secundario
|
int sub_counter_ = 0; // Contador secundario
|
||||||
Uint32 ticks_ = 0; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks_ = 0; // Contador de ticks para ajustar la velocidad del programa
|
||||||
std::vector<captions_t> texts_; // Vector con los textos
|
std::vector<Captions> texts_; // Vector con los textos
|
||||||
|
|
||||||
// Actualiza las variables
|
// Actualiza las variables
|
||||||
void update();
|
void update();
|
||||||
|
|||||||
@@ -217,60 +217,60 @@ void Director::initInput()
|
|||||||
// Teclado - Movimiento
|
// Teclado - Movimiento
|
||||||
if (options.keys == ControlScheme::CURSOR)
|
if (options.keys == ControlScheme::CURSOR)
|
||||||
{
|
{
|
||||||
Input::get()->bindKey(input_jump, SDL_SCANCODE_UP);
|
Input::get()->bindKey(InputAction::JUMP, SDL_SCANCODE_UP);
|
||||||
Input::get()->bindKey(input_left, SDL_SCANCODE_LEFT);
|
Input::get()->bindKey(InputAction::LEFT, SDL_SCANCODE_LEFT);
|
||||||
Input::get()->bindKey(input_right, SDL_SCANCODE_RIGHT);
|
Input::get()->bindKey(InputAction::RIGHT, SDL_SCANCODE_RIGHT);
|
||||||
Input::get()->bindKey(input_up, SDL_SCANCODE_UP);
|
Input::get()->bindKey(InputAction::UP, SDL_SCANCODE_UP);
|
||||||
Input::get()->bindKey(input_down, SDL_SCANCODE_DOWN);
|
Input::get()->bindKey(InputAction::DOWN, SDL_SCANCODE_DOWN);
|
||||||
}
|
}
|
||||||
else if (options.keys == ControlScheme::OPQA)
|
else if (options.keys == ControlScheme::OPQA)
|
||||||
{
|
{
|
||||||
Input::get()->bindKey(input_jump, SDL_SCANCODE_Q);
|
Input::get()->bindKey(InputAction::JUMP, SDL_SCANCODE_Q);
|
||||||
Input::get()->bindKey(input_left, SDL_SCANCODE_O);
|
Input::get()->bindKey(InputAction::LEFT, SDL_SCANCODE_O);
|
||||||
Input::get()->bindKey(input_right, SDL_SCANCODE_P);
|
Input::get()->bindKey(InputAction::RIGHT, SDL_SCANCODE_P);
|
||||||
Input::get()->bindKey(input_up, SDL_SCANCODE_Q);
|
Input::get()->bindKey(InputAction::UP, SDL_SCANCODE_Q);
|
||||||
Input::get()->bindKey(input_down, SDL_SCANCODE_A);
|
Input::get()->bindKey(InputAction::DOWN, SDL_SCANCODE_A);
|
||||||
}
|
}
|
||||||
else if (options.keys == ControlScheme::WASD)
|
else if (options.keys == ControlScheme::WASD)
|
||||||
{
|
{
|
||||||
Input::get()->bindKey(input_jump, SDL_SCANCODE_W);
|
Input::get()->bindKey(InputAction::JUMP, SDL_SCANCODE_W);
|
||||||
Input::get()->bindKey(input_left, SDL_SCANCODE_A);
|
Input::get()->bindKey(InputAction::LEFT, SDL_SCANCODE_A);
|
||||||
Input::get()->bindKey(input_right, SDL_SCANCODE_D);
|
Input::get()->bindKey(InputAction::RIGHT, SDL_SCANCODE_D);
|
||||||
Input::get()->bindKey(input_up, SDL_SCANCODE_W);
|
Input::get()->bindKey(InputAction::UP, SDL_SCANCODE_W);
|
||||||
Input::get()->bindKey(input_down, SDL_SCANCODE_S);
|
Input::get()->bindKey(InputAction::DOWN, SDL_SCANCODE_S);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Teclado - Otros
|
// Teclado - Otros
|
||||||
Input::get()->bindKey(input_accept, SDL_SCANCODE_RETURN);
|
Input::get()->bindKey(InputAction::ACCEPT, SDL_SCANCODE_RETURN);
|
||||||
Input::get()->bindKey(input_cancel, SDL_SCANCODE_ESCAPE);
|
Input::get()->bindKey(InputAction::CANCEL, SDL_SCANCODE_ESCAPE);
|
||||||
Input::get()->bindKey(input_pause, SDL_SCANCODE_H);
|
Input::get()->bindKey(InputAction::PAUSE, SDL_SCANCODE_H);
|
||||||
Input::get()->bindKey(input_exit, SDL_SCANCODE_ESCAPE);
|
Input::get()->bindKey(InputAction::EXIT, SDL_SCANCODE_ESCAPE);
|
||||||
Input::get()->bindKey(input_window_dec_size, SDL_SCANCODE_F1);
|
Input::get()->bindKey(InputAction::WINDOW_DEC_ZOOM, SDL_SCANCODE_F1);
|
||||||
Input::get()->bindKey(input_window_inc_size, SDL_SCANCODE_F2);
|
Input::get()->bindKey(InputAction::WINDOW_INC_ZOOM, SDL_SCANCODE_F2);
|
||||||
Input::get()->bindKey(input_toggle_videomode, SDL_SCANCODE_F3);
|
Input::get()->bindKey(InputAction::TOGGLE_VIDEOMODE, SDL_SCANCODE_F3);
|
||||||
Input::get()->bindKey(input_toggle_shaders, SDL_SCANCODE_F4);
|
Input::get()->bindKey(InputAction::TOGGLE_SHADERS, SDL_SCANCODE_F4);
|
||||||
Input::get()->bindKey(input_toggle_palette, SDL_SCANCODE_F5);
|
Input::get()->bindKey(InputAction::TOGGLE_PALETTE, SDL_SCANCODE_F5);
|
||||||
Input::get()->bindKey(input_toggle_music, SDL_SCANCODE_M);
|
Input::get()->bindKey(InputAction::TOGGLE_MUSIC, SDL_SCANCODE_M);
|
||||||
Input::get()->bindKey(input_toggle_border, SDL_SCANCODE_B);
|
Input::get()->bindKey(InputAction::TOGGLE_BORDER, SDL_SCANCODE_B);
|
||||||
|
|
||||||
// Mando - Movimiento
|
// Mando - Movimiento
|
||||||
Input::get()->bindGameControllerButton(input_jump, SDL_CONTROLLER_BUTTON_B);
|
Input::get()->bindGameControllerButton(InputAction::JUMP, SDL_CONTROLLER_BUTTON_B);
|
||||||
Input::get()->bindGameControllerButton(input_left, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
|
Input::get()->bindGameControllerButton(InputAction::LEFT, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
|
||||||
Input::get()->bindGameControllerButton(input_right, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
|
Input::get()->bindGameControllerButton(InputAction::RIGHT, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
|
||||||
|
|
||||||
// Mando - Otros
|
// Mando - Otros
|
||||||
Input::get()->bindGameControllerButton(input_accept, SDL_CONTROLLER_BUTTON_B);
|
Input::get()->bindGameControllerButton(InputAction::ACCEPT, SDL_CONTROLLER_BUTTON_B);
|
||||||
Input::get()->bindGameControllerButton(input_cancel, SDL_CONTROLLER_BUTTON_A);
|
Input::get()->bindGameControllerButton(InputAction::CANCEL, SDL_CONTROLLER_BUTTON_A);
|
||||||
#ifdef GAME_CONSOLE
|
#ifdef GAME_CONSOLE
|
||||||
Input::get()->bindGameControllerButton(input_pause, SDL_CONTROLLER_BUTTON_BACK);
|
Input::get()->bindGameControllerButton(InputAction::input_pause, SDL_CONTROLLER_BUTTON_BACK);
|
||||||
Input::get()->bindGameControllerButton(input_exit, SDL_CONTROLLER_BUTTON_START);
|
Input::get()->bindGameControllerButton(InputAction::input_exit, SDL_CONTROLLER_BUTTON_START);
|
||||||
#else
|
#else
|
||||||
Input::get()->bindGameControllerButton(input_pause, SDL_CONTROLLER_BUTTON_START);
|
Input::get()->bindGameControllerButton(InputAction::PAUSE, SDL_CONTROLLER_BUTTON_START);
|
||||||
Input::get()->bindGameControllerButton(input_exit, SDL_CONTROLLER_BUTTON_BACK);
|
Input::get()->bindGameControllerButton(InputAction::EXIT, SDL_CONTROLLER_BUTTON_BACK);
|
||||||
#endif
|
#endif
|
||||||
Input::get()->bindGameControllerButton(input_toggle_palette, SDL_CONTROLLER_BUTTON_LEFTSHOULDER);
|
Input::get()->bindGameControllerButton(InputAction::TOGGLE_PALETTE, SDL_CONTROLLER_BUTTON_LEFTSHOULDER);
|
||||||
Input::get()->bindGameControllerButton(input_toggle_music, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);
|
Input::get()->bindGameControllerButton(InputAction::TOGGLE_MUSIC, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);
|
||||||
Input::get()->bindGameControllerButton(input_toggle_border, SDL_CONTROLLER_BUTTON_X);
|
Input::get()->bindGameControllerButton(InputAction::TOGGLE_BORDER, SDL_CONTROLLER_BUTTON_X);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa JailAudio
|
// Inicializa JailAudio
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ private:
|
|||||||
int pos; // Posición
|
int pos; // Posición
|
||||||
};
|
};
|
||||||
|
|
||||||
struct asdhk
|
struct TextIndex
|
||||||
{
|
{
|
||||||
int index;
|
int index;
|
||||||
int trigger;
|
int trigger;
|
||||||
@@ -42,7 +42,7 @@ private:
|
|||||||
|
|
||||||
struct SceneData // Estructura para crear cada una de las escenas del final
|
struct SceneData // Estructura para crear cada una de las escenas del final
|
||||||
{
|
{
|
||||||
std::vector<asdhk> text_index; // Indices del vector de textos a mostrar y su disparador
|
std::vector<TextIndex> text_index; // Indices del vector de textos a mostrar y su disparador
|
||||||
int picture_index; // Indice del vector de imagenes a mostrar
|
int picture_index; // Indice del vector de imagenes a mostrar
|
||||||
int counter_end; // Valor del contador en el que finaliza la escena
|
int counter_end; // Valor del contador en el que finaliza la escena
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -182,14 +182,14 @@ void Game::checkEvents()
|
|||||||
// Comprueba el teclado
|
// Comprueba el teclado
|
||||||
void Game::checkInput()
|
void Game::checkInput()
|
||||||
{
|
{
|
||||||
if (input_->checkInput(input_toggle_music, REPEAT_FALSE))
|
if (input_->checkInput(InputAction::TOGGLE_MUSIC, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
board_->music = !board_->music;
|
board_->music = !board_->music;
|
||||||
board_->music ? JA_ResumeMusic() : JA_PauseMusic();
|
board_->music ? JA_ResumeMusic() : JA_PauseMusic();
|
||||||
Notifier::get()->show({"MUSIC " + std::string(board_->music ? "ENABLED" : "DISABLED")}, NotificationText::CENTER);
|
Notifier::get()->show({"MUSIC " + std::string(board_->music ? "ENABLED" : "DISABLED")}, NotificationText::CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (input_->checkInput(input_pause, REPEAT_FALSE))
|
else if (input_->checkInput(InputAction::PAUSE, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
switchPause();
|
switchPause();
|
||||||
Notifier::get()->show({std::string(paused_ ? "GAME PAUSED" : "GAME RUNNING")}, NotificationText::CENTER);
|
Notifier::get()->show({std::string(paused_ ? "GAME PAUSED" : "GAME RUNNING")}, NotificationText::CENTER);
|
||||||
|
|||||||
@@ -54,29 +54,29 @@ namespace globalInputs
|
|||||||
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
|
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
|
||||||
void check()
|
void check()
|
||||||
{
|
{
|
||||||
if (Input::get()->checkInput(input_exit, REPEAT_FALSE))
|
if (Input::get()->checkInput(InputAction::EXIT, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
quit();
|
quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (Input::get()->checkInput(input_accept, REPEAT_FALSE))
|
else if (Input::get()->checkInput(InputAction::ACCEPT, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
skip_section();
|
skip_section();
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (Input::get()->checkInput(input_toggle_border, REPEAT_FALSE))
|
else if (Input::get()->checkInput(InputAction::TOGGLE_BORDER, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
Screen::get()->toggleBorder();
|
Screen::get()->toggleBorder();
|
||||||
Notifier::get()->show({"BORDER " + std::string(options.video.border.enabled ? "ENABLED" : "DISABLED")}, NotificationText::CENTER);
|
Notifier::get()->show({"BORDER " + std::string(options.video.border.enabled ? "ENABLED" : "DISABLED")}, NotificationText::CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (Input::get()->checkInput(input_toggle_videomode, REPEAT_FALSE))
|
else if (Input::get()->checkInput(InputAction::TOGGLE_VIDEOMODE, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
Screen::get()->toggleVideoMode();
|
Screen::get()->toggleVideoMode();
|
||||||
Notifier::get()->show({"FULLSCREEN " + std::string(options.video.mode == 0 ? "DISABLED" : "ENABLED")}, NotificationText::CENTER);
|
Notifier::get()->show({"FULLSCREEN " + std::string(options.video.mode == 0 ? "DISABLED" : "ENABLED")}, NotificationText::CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (Input::get()->checkInput(input_window_dec_size, REPEAT_FALSE))
|
else if (Input::get()->checkInput(InputAction::WINDOW_DEC_ZOOM, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
if (Screen::get()->decWindowZoom())
|
if (Screen::get()->decWindowZoom())
|
||||||
{
|
{
|
||||||
@@ -84,7 +84,7 @@ namespace globalInputs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (Input::get()->checkInput(input_window_inc_size, REPEAT_FALSE))
|
else if (Input::get()->checkInput(InputAction::WINDOW_INC_ZOOM, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
if (Screen::get()->incWindowZoom())
|
if (Screen::get()->incWindowZoom())
|
||||||
{
|
{
|
||||||
@@ -92,13 +92,13 @@ namespace globalInputs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (Input::get()->checkInput(input_toggle_shaders, REPEAT_FALSE))
|
else if (Input::get()->checkInput(InputAction::TOGGLE_SHADERS, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
Screen::get()->toggleShaders();
|
Screen::get()->toggleShaders();
|
||||||
Notifier::get()->show({"SHADERS " + std::string(options.video.shaders ? "ENABLED" : "DISABLED")}, NotificationText::CENTER);
|
Notifier::get()->show({"SHADERS " + std::string(options.video.shaders ? "ENABLED" : "DISABLED")}, NotificationText::CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (Input::get()->checkInput(input_toggle_palette, REPEAT_FALSE))
|
else if (Input::get()->checkInput(InputAction::TOGGLE_PALETTE, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
switchPalette();
|
switchPalette();
|
||||||
Notifier::get()->show({"PALETTE " + std::string(options.video.palette == Palette::ZXSPECTRUM ? "ZX SPECTRUM" : "ZX ARNE")}, NotificationText::CENTER);
|
Notifier::get()->show({"PALETTE " + std::string(options.video.palette == Palette::ZXSPECTRUM ? "ZX SPECTRUM" : "ZX ARNE")}, NotificationText::CENTER);
|
||||||
|
|||||||
@@ -35,12 +35,12 @@ Input::Input(const std::string &game_controller_db_path)
|
|||||||
keyBindings_t kb;
|
keyBindings_t kb;
|
||||||
kb.scancode = 0;
|
kb.scancode = 0;
|
||||||
kb.active = false;
|
kb.active = false;
|
||||||
key_bindings_.resize(input_number_of_inputs, kb);
|
key_bindings_.resize(static_cast<int>(InputAction::SIZE), 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;
|
||||||
game_controller_bindings_.resize(input_number_of_inputs, gcb);
|
game_controller_bindings_.resize(static_cast<int>(InputAction::SIZE), gcb);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el estado del objeto
|
// Actualiza el estado del objeto
|
||||||
@@ -53,19 +53,19 @@ void Input::update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Asigna inputs a teclas
|
// Asigna inputs a teclas
|
||||||
void Input::bindKey(Uint8 input, SDL_Scancode code)
|
void Input::bindKey(InputAction input, SDL_Scancode code)
|
||||||
{
|
{
|
||||||
key_bindings_[input].scancode = code;
|
key_bindings_.at(static_cast<int>(input)).scancode = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Asigna inputs a botones del mando
|
// Asigna inputs a botones del mando
|
||||||
void Input::bindGameControllerButton(Uint8 input, SDL_GameControllerButton button)
|
void Input::bindGameControllerButton(InputAction input, SDL_GameControllerButton button)
|
||||||
{
|
{
|
||||||
game_controller_bindings_[input].button = button;
|
game_controller_bindings_.at(static_cast<int>(input)).button = button;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si un input esta activo
|
// Comprueba si un input esta activo
|
||||||
bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
bool Input::checkInput(InputAction input, bool repeat, int device, int index)
|
||||||
{
|
{
|
||||||
if (!enabled_)
|
if (!enabled_)
|
||||||
{
|
{
|
||||||
@@ -86,7 +86,7 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
|||||||
|
|
||||||
if (repeat)
|
if (repeat)
|
||||||
{
|
{
|
||||||
if (keyStates[key_bindings_[input].scancode] != 0)
|
if (keyStates[key_bindings_.at(static_cast<int>(input)).scancode] != 0)
|
||||||
{
|
{
|
||||||
successKeyboard = true;
|
successKeyboard = true;
|
||||||
}
|
}
|
||||||
@@ -97,11 +97,11 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!key_bindings_[input].active)
|
if (!key_bindings_.at(static_cast<int>(input)).active)
|
||||||
{
|
{
|
||||||
if (keyStates[key_bindings_[input].scancode] != 0)
|
if (keyStates[key_bindings_.at(static_cast<int>(input)).scancode] != 0)
|
||||||
{
|
{
|
||||||
key_bindings_[input].active = true;
|
key_bindings_.at(static_cast<int>(input)).active = true;
|
||||||
successKeyboard = true;
|
successKeyboard = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -111,9 +111,9 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (keyStates[key_bindings_[input].scancode] == 0)
|
if (keyStates[key_bindings_.at(static_cast<int>(input)).scancode] == 0)
|
||||||
{
|
{
|
||||||
key_bindings_[input].active = false;
|
key_bindings_.at(static_cast<int>(input)).active = false;
|
||||||
successKeyboard = false;
|
successKeyboard = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -129,7 +129,7 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
|||||||
{
|
{
|
||||||
if (repeat)
|
if (repeat)
|
||||||
{
|
{
|
||||||
if (SDL_GameControllerGetButton(connected_controllers_[index], game_controller_bindings_[input].button) != 0)
|
if (SDL_GameControllerGetButton(connected_controllers_.at(index), game_controller_bindings_.at(static_cast<int>(input)).button) != 0)
|
||||||
{
|
{
|
||||||
successGameController = true;
|
successGameController = true;
|
||||||
}
|
}
|
||||||
@@ -140,11 +140,11 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!game_controller_bindings_[input].active)
|
if (!game_controller_bindings_.at(static_cast<int>(input)).active)
|
||||||
{
|
{
|
||||||
if (SDL_GameControllerGetButton(connected_controllers_[index], game_controller_bindings_[input].button) != 0)
|
if (SDL_GameControllerGetButton(connected_controllers_.at(index), game_controller_bindings_.at(static_cast<int>(input)).button) != 0)
|
||||||
{
|
{
|
||||||
game_controller_bindings_[input].active = true;
|
game_controller_bindings_.at(static_cast<int>(input)).active = true;
|
||||||
successGameController = true;
|
successGameController = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -154,9 +154,9 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (SDL_GameControllerGetButton(connected_controllers_[index], game_controller_bindings_[input].button) == 0)
|
if (SDL_GameControllerGetButton(connected_controllers_.at(index), game_controller_bindings_.at(static_cast<int>(input)).button) == 0)
|
||||||
{
|
{
|
||||||
game_controller_bindings_[input].active = false;
|
game_controller_bindings_.at(static_cast<int>(input)).active = false;
|
||||||
successGameController = false;
|
successGameController = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -197,7 +197,7 @@ bool Input::checkAnyInput(int device, int index)
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < (int)game_controller_bindings_.size(); ++i)
|
for (int i = 0; i < (int)game_controller_bindings_.size(); ++i)
|
||||||
{
|
{
|
||||||
if (SDL_GameControllerGetButton(connected_controllers_[index], game_controller_bindings_[i].button) != 0)
|
if (SDL_GameControllerGetButton(connected_controllers_.at(index), game_controller_bindings_[i].button) != 0)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,31 +15,31 @@ constexpr int INPUT_USE_KEYBOARD = 0;
|
|||||||
constexpr int INPUT_USE_GAMECONTROLLER = 1;
|
constexpr int INPUT_USE_GAMECONTROLLER = 1;
|
||||||
constexpr int INPUT_USE_ANY = 2;
|
constexpr int INPUT_USE_ANY = 2;
|
||||||
|
|
||||||
enum inputs_e
|
enum class InputAction
|
||||||
{
|
{
|
||||||
// Inputs obligatorios
|
// Inputs obligatorios
|
||||||
input_null,
|
NONE,
|
||||||
input_up,
|
UP,
|
||||||
input_down,
|
DOWN,
|
||||||
input_left,
|
LEFT,
|
||||||
input_right,
|
RIGHT,
|
||||||
input_pause,
|
PAUSE,
|
||||||
input_exit,
|
EXIT,
|
||||||
input_accept,
|
ACCEPT,
|
||||||
input_cancel,
|
CANCEL,
|
||||||
|
|
||||||
// Inputs personalizados
|
// Inputs personalizados
|
||||||
input_jump,
|
JUMP,
|
||||||
input_window_inc_size,
|
WINDOW_INC_ZOOM,
|
||||||
input_window_dec_size,
|
WINDOW_DEC_ZOOM,
|
||||||
input_toggle_videomode,
|
TOGGLE_VIDEOMODE,
|
||||||
input_toggle_border,
|
TOGGLE_BORDER,
|
||||||
input_toggle_music,
|
TOGGLE_MUSIC,
|
||||||
input_toggle_palette,
|
TOGGLE_PALETTE,
|
||||||
input_toggle_shaders,
|
TOGGLE_SHADERS,
|
||||||
|
|
||||||
// Input obligatorio
|
// Input obligatorio
|
||||||
input_number_of_inputs
|
SIZE
|
||||||
};
|
};
|
||||||
|
|
||||||
enum i_disable_e
|
enum i_disable_e
|
||||||
@@ -100,13 +100,13 @@ public:
|
|||||||
void update();
|
void update();
|
||||||
|
|
||||||
// Asigna inputs a teclas
|
// Asigna inputs a teclas
|
||||||
void bindKey(Uint8 input, SDL_Scancode code);
|
void bindKey(InputAction input, SDL_Scancode code);
|
||||||
|
|
||||||
// Asigna inputs a botones del mando
|
// Asigna inputs a botones del mando
|
||||||
void bindGameControllerButton(Uint8 input, SDL_GameControllerButton button);
|
void bindGameControllerButton(InputAction input, SDL_GameControllerButton button);
|
||||||
|
|
||||||
// Comprueba si un input esta activo
|
// Comprueba si un input esta activo
|
||||||
bool checkInput(Uint8 input, bool repeat = true, int device = INPUT_USE_ANY, int index = 0);
|
bool checkInput(InputAction 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);
|
||||||
|
|||||||
@@ -82,13 +82,13 @@ void Player::checkInput()
|
|||||||
if (!auto_movement_)
|
if (!auto_movement_)
|
||||||
{
|
{
|
||||||
// Comprueba las entradas de desplazamiento lateral solo en el caso de no estar enganchado a una superficie automatica
|
// Comprueba las entradas de desplazamiento lateral solo en el caso de no estar enganchado a una superficie automatica
|
||||||
if (input_->checkInput(input_left))
|
if (input_->checkInput(InputAction::LEFT))
|
||||||
{
|
{
|
||||||
vx_ = -0.6f;
|
vx_ = -0.6f;
|
||||||
sprite_->setFlip(SDL_FLIP_HORIZONTAL);
|
sprite_->setFlip(SDL_FLIP_HORIZONTAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (input_->checkInput(input_right))
|
else if (input_->checkInput(InputAction::RIGHT))
|
||||||
{
|
{
|
||||||
vx_ = 0.6f;
|
vx_ = 0.6f;
|
||||||
sprite_->setFlip(SDL_FLIP_NONE);
|
sprite_->setFlip(SDL_FLIP_NONE);
|
||||||
@@ -119,7 +119,7 @@ void Player::checkInput()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input_->checkInput(input_jump))
|
if (input_->checkInput(InputAction::JUMP))
|
||||||
{
|
{
|
||||||
// Solo puede saltar si ademas de estar (state == s_standing)
|
// Solo puede saltar si ademas de estar (state == s_standing)
|
||||||
// Esta sobre el suelo, rampa o suelo que se mueve
|
// Esta sobre el suelo, rampa o suelo que se mueve
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ Title::Title()
|
|||||||
pSetSource(loading_screen_);
|
pSetSource(loading_screen_);
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
state_ = options.section.subsection == Subsection::TITLE_WITH_LOADING_SCREEN ? show_loading_screen : show_menu;
|
state_ = options.section.subsection == Subsection::TITLE_WITH_LOADING_SCREEN ? TitleState::SHOW_LOADING_SCREEN : TitleState::SHOW_MENU;
|
||||||
options.section.section = Section::TITLE;
|
options.section.section = Section::TITLE;
|
||||||
options.section.subsection = Subsection::NONE;
|
options.section.subsection = Subsection::NONE;
|
||||||
initMarquee();
|
initMarquee();
|
||||||
@@ -91,7 +91,7 @@ void Title::initMarquee()
|
|||||||
long_text_ = "HEY JAILERS!! IT'S 2022 AND WE'RE STILL ROCKING LIKE IT'S 1998!!! HAVE YOU HEARD IT? JAILGAMES ARE BACK!! YEEESSS BACK!! MORE THAN 10 TITLES ON JAILDOC'S KITCHEN!! THATS A LOOOOOOT OF JAILGAMES, BUT WHICH ONE WILL STRIKE FIRST? THERE IS ALSO A NEW DEVICE TO COME THAT WILL BLOW YOUR MIND WITH JAILGAMES ON THE GO: P.A.C.O. BUT WAIT! WHAT'S THAT BEAUTY I'M SEEING RIGHT OVER THERE?? OOOH THAT TINY MINIASCII IS PURE LOVE!! I WANT TO LICK EVERY BYTE OF IT!! OH SHIT! AND DON'T FORGET TO BRING BACK THOSE OLD AND FAT MS-DOS JAILGAMES TO GITHUB TO KEEP THEM ALIVE!! WHAT WILL BE THE NEXT JAILDOC RELEASE? WHAT WILL BE THE NEXT PROJECT TO COME ALIVE?? OH BABY WE DON'T KNOW BUT HERE YOU CAN FIND THE ANSWER, YOU JUST HAVE TO COMPLETE JAILDOCTOR'S DILEMMA ... COULD YOU?";
|
long_text_ = "HEY JAILERS!! IT'S 2022 AND WE'RE STILL ROCKING LIKE IT'S 1998!!! HAVE YOU HEARD IT? JAILGAMES ARE BACK!! YEEESSS BACK!! MORE THAN 10 TITLES ON JAILDOC'S KITCHEN!! THATS A LOOOOOOT OF JAILGAMES, BUT WHICH ONE WILL STRIKE FIRST? THERE IS ALSO A NEW DEVICE TO COME THAT WILL BLOW YOUR MIND WITH JAILGAMES ON THE GO: P.A.C.O. BUT WAIT! WHAT'S THAT BEAUTY I'M SEEING RIGHT OVER THERE?? OOOH THAT TINY MINIASCII IS PURE LOVE!! I WANT TO LICK EVERY BYTE OF IT!! OH SHIT! AND DON'T FORGET TO BRING BACK THOSE OLD AND FAT MS-DOS JAILGAMES TO GITHUB TO KEEP THEM ALIVE!! WHAT WILL BE THE NEXT JAILDOC RELEASE? WHAT WILL BE THE NEXT PROJECT TO COME ALIVE?? OH BABY WE DON'T KNOW BUT HERE YOU CAN FIND THE ANSWER, YOU JUST HAVE TO COMPLETE JAILDOCTOR'S DILEMMA ... COULD YOU?";
|
||||||
for (int i = 0; i < (int)long_text_.length(); ++i)
|
for (int i = 0; i < (int)long_text_.length(); ++i)
|
||||||
{
|
{
|
||||||
letter_t l;
|
TitleLetter l;
|
||||||
l.letter = long_text_.substr(i, 1);
|
l.letter = long_text_.substr(i, 1);
|
||||||
l.x = 256;
|
l.x = 256;
|
||||||
l.enabled = false;
|
l.enabled = false;
|
||||||
@@ -137,26 +137,26 @@ void Title::checkInput()
|
|||||||
{
|
{
|
||||||
if (show_cheevos_)
|
if (show_cheevos_)
|
||||||
{
|
{
|
||||||
if (input_->checkInput(input_down, REPEAT_TRUE))
|
if (input_->checkInput(InputAction::DOWN, REPEAT_TRUE))
|
||||||
{
|
{
|
||||||
moveCheevosList(1);
|
moveCheevosList(1);
|
||||||
}
|
}
|
||||||
else if (input_->checkInput(input_up, REPEAT_TRUE))
|
else if (input_->checkInput(InputAction::UP, REPEAT_TRUE))
|
||||||
{
|
{
|
||||||
moveCheevosList(0);
|
moveCheevosList(0);
|
||||||
}
|
}
|
||||||
else if (input_->checkInput(input_accept, REPEAT_FALSE))
|
else if (input_->checkInput(InputAction::ACCEPT, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
hideCheevosList();
|
hideCheevosList();
|
||||||
counter_ = 0;
|
counter_ = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input_->checkInput(input_accept, REPEAT_FALSE))
|
if (input_->checkInput(InputAction::ACCEPT, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
if (state_ == show_loading_screen)
|
if (state_ == TitleState::SHOW_LOADING_SCREEN)
|
||||||
{
|
{
|
||||||
state_ = fade_loading_screen;
|
state_ = TitleState::FADE_LOADING_SCREEN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,24 +232,26 @@ void Title::update()
|
|||||||
|
|
||||||
switch (state_)
|
switch (state_)
|
||||||
{
|
{
|
||||||
case show_loading_screen:
|
case TitleState::SHOW_LOADING_SCREEN:
|
||||||
if (counter_ == 500)
|
if (counter_ == 500)
|
||||||
{
|
{
|
||||||
counter_ = 0;
|
counter_ = 0;
|
||||||
state_ = fade_loading_screen;
|
state_ = TitleState::FADE_LOADING_SCREEN;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case fade_loading_screen:
|
case TitleState::FADE_LOADING_SCREEN:
|
||||||
if (counter_ % 4 == 0)
|
if (counter_ % 4 == 0)
|
||||||
|
{
|
||||||
if (pFadePal())
|
if (pFadePal())
|
||||||
{
|
{
|
||||||
counter_ = 0;
|
counter_ = 0;
|
||||||
state_ = show_menu;
|
state_ = TitleState::SHOW_MENU;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case show_menu:
|
case TitleState::SHOW_MENU:
|
||||||
// Actualiza la marquesina
|
// Actualiza la marquesina
|
||||||
updateMarquee();
|
updateMarquee();
|
||||||
|
|
||||||
@@ -277,7 +279,7 @@ void Title::render()
|
|||||||
screen_->start();
|
screen_->start();
|
||||||
screen_->clean(stringToColor(options.video.palette, "black"));
|
screen_->clean(stringToColor(options.video.palette, "black"));
|
||||||
|
|
||||||
if (state_ == show_menu)
|
if (state_ == TitleState::SHOW_MENU)
|
||||||
{
|
{
|
||||||
// Dibuja la textura de fondo
|
// Dibuja la textura de fondo
|
||||||
SDL_RenderCopy(renderer_, bg_texture_, nullptr, nullptr);
|
SDL_RenderCopy(renderer_, bg_texture_, nullptr, nullptr);
|
||||||
@@ -389,7 +391,7 @@ void Title::fillTexture()
|
|||||||
const int textSize = text_->getCharacterSize();
|
const int textSize = text_->getCharacterSize();
|
||||||
text_->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 11 * textSize, "1.PLAY", 1, textColor);
|
text_->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 11 * textSize, "1.PLAY", 1, textColor);
|
||||||
text_->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 13 * textSize, "2.ACHIEVEMENTS", 1, textColor);
|
text_->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 13 * textSize, "2.ACHIEVEMENTS", 1, textColor);
|
||||||
// text_->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 15 * textSize, "3.REDEFINE KEYS", 1, textColor);
|
text_->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 15 * textSize, "3.REDEFINE KEYS", 1, textColor);
|
||||||
text_->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 20 * textSize, "ESC.EXIT GAME", 1, textColor);
|
text_->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 20 * textSize, "ESC.EXIT GAME", 1, textColor);
|
||||||
|
|
||||||
// Devuelve el puntero del renderizador a su sitio
|
// Devuelve el puntero del renderizador a su sitio
|
||||||
|
|||||||
@@ -17,18 +17,18 @@ class Texture; // lines 18-18
|
|||||||
class Title
|
class Title
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
struct letter_t
|
struct TitleLetter
|
||||||
{
|
{
|
||||||
std::string letter; // Letra a escribir
|
std::string letter; // Letra a escribir
|
||||||
int x; // Posición en el eje x
|
int x; // Posición en el eje x
|
||||||
bool enabled; // Solo se escriben y mueven si estan habilitadas
|
bool enabled; // Solo se escriben y mueven si estan habilitadas
|
||||||
};
|
};
|
||||||
|
|
||||||
enum states_e
|
enum class TitleState
|
||||||
{
|
{
|
||||||
show_loading_screen,
|
SHOW_LOADING_SCREEN,
|
||||||
fade_loading_screen,
|
FADE_LOADING_SCREEN,
|
||||||
show_menu
|
SHOW_MENU
|
||||||
};
|
};
|
||||||
|
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
@@ -48,11 +48,11 @@ private:
|
|||||||
int counter_ = 0; // Contador
|
int counter_ = 0; // Contador
|
||||||
std::string long_text_; // Texto que aparece en la parte inferior del titulo
|
std::string long_text_; // Texto que aparece en la parte inferior del titulo
|
||||||
Uint32 ticks_ = 0; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks_ = 0; // Contador de ticks para ajustar la velocidad del programa
|
||||||
std::vector<letter_t> letters_; // Vector con las letras de la marquesina
|
std::vector<TitleLetter> letters_; // Vector con las letras de la marquesina
|
||||||
int marquee_speed_ = 3; // Velocidad de desplazamiento de la marquesina
|
int marquee_speed_ = 3; // Velocidad de desplazamiento de la marquesina
|
||||||
bool show_cheevos_ = false; // Indica si se muestra por pantalla el listado de logros
|
bool show_cheevos_ = false; // Indica si se muestra por pantalla el listado de logros
|
||||||
SDL_Rect cheevos_texture_view_; // Zona visible de la textura con el listado de logros
|
SDL_Rect cheevos_texture_view_; // Zona visible de la textura con el listado de logros
|
||||||
states_e state_; // Estado en el que se encuentra el bucle principal
|
TitleState state_; // Estado en el que se encuentra el bucle principal
|
||||||
jSurface loading_screen_; // Surface con los gráficos de la pantalla de carga
|
jSurface loading_screen_; // Surface con los gráficos de la pantalla de carga
|
||||||
|
|
||||||
// Actualiza las variables
|
// Actualiza las variables
|
||||||
|
|||||||
Reference in New Issue
Block a user