Arreglos en la estructura i format del codi
This commit is contained in:
@@ -16,7 +16,7 @@ class Text; // lines 15-15
|
||||
class Credits
|
||||
{
|
||||
private:
|
||||
struct captions_t
|
||||
struct Captions
|
||||
{
|
||||
std::string label; // Texto a escribir
|
||||
Color color; // Color del texto
|
||||
@@ -38,7 +38,7 @@ private:
|
||||
bool counter_enabled_ = true; // Indica si esta activo el contador
|
||||
int sub_counter_ = 0; // Contador secundario
|
||||
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
|
||||
void update();
|
||||
|
||||
@@ -217,60 +217,60 @@ void Director::initInput()
|
||||
// Teclado - Movimiento
|
||||
if (options.keys == ControlScheme::CURSOR)
|
||||
{
|
||||
Input::get()->bindKey(input_jump, SDL_SCANCODE_UP);
|
||||
Input::get()->bindKey(input_left, SDL_SCANCODE_LEFT);
|
||||
Input::get()->bindKey(input_right, SDL_SCANCODE_RIGHT);
|
||||
Input::get()->bindKey(input_up, SDL_SCANCODE_UP);
|
||||
Input::get()->bindKey(input_down, SDL_SCANCODE_DOWN);
|
||||
Input::get()->bindKey(InputAction::JUMP, SDL_SCANCODE_UP);
|
||||
Input::get()->bindKey(InputAction::LEFT, SDL_SCANCODE_LEFT);
|
||||
Input::get()->bindKey(InputAction::RIGHT, SDL_SCANCODE_RIGHT);
|
||||
Input::get()->bindKey(InputAction::UP, SDL_SCANCODE_UP);
|
||||
Input::get()->bindKey(InputAction::DOWN, SDL_SCANCODE_DOWN);
|
||||
}
|
||||
else if (options.keys == ControlScheme::OPQA)
|
||||
{
|
||||
Input::get()->bindKey(input_jump, SDL_SCANCODE_Q);
|
||||
Input::get()->bindKey(input_left, SDL_SCANCODE_O);
|
||||
Input::get()->bindKey(input_right, SDL_SCANCODE_P);
|
||||
Input::get()->bindKey(input_up, SDL_SCANCODE_Q);
|
||||
Input::get()->bindKey(input_down, SDL_SCANCODE_A);
|
||||
Input::get()->bindKey(InputAction::JUMP, SDL_SCANCODE_Q);
|
||||
Input::get()->bindKey(InputAction::LEFT, SDL_SCANCODE_O);
|
||||
Input::get()->bindKey(InputAction::RIGHT, SDL_SCANCODE_P);
|
||||
Input::get()->bindKey(InputAction::UP, SDL_SCANCODE_Q);
|
||||
Input::get()->bindKey(InputAction::DOWN, SDL_SCANCODE_A);
|
||||
}
|
||||
else if (options.keys == ControlScheme::WASD)
|
||||
{
|
||||
Input::get()->bindKey(input_jump, SDL_SCANCODE_W);
|
||||
Input::get()->bindKey(input_left, SDL_SCANCODE_A);
|
||||
Input::get()->bindKey(input_right, SDL_SCANCODE_D);
|
||||
Input::get()->bindKey(input_up, SDL_SCANCODE_W);
|
||||
Input::get()->bindKey(input_down, SDL_SCANCODE_S);
|
||||
Input::get()->bindKey(InputAction::JUMP, SDL_SCANCODE_W);
|
||||
Input::get()->bindKey(InputAction::LEFT, SDL_SCANCODE_A);
|
||||
Input::get()->bindKey(InputAction::RIGHT, SDL_SCANCODE_D);
|
||||
Input::get()->bindKey(InputAction::UP, SDL_SCANCODE_W);
|
||||
Input::get()->bindKey(InputAction::DOWN, SDL_SCANCODE_S);
|
||||
}
|
||||
|
||||
// Teclado - Otros
|
||||
Input::get()->bindKey(input_accept, SDL_SCANCODE_RETURN);
|
||||
Input::get()->bindKey(input_cancel, SDL_SCANCODE_ESCAPE);
|
||||
Input::get()->bindKey(input_pause, SDL_SCANCODE_H);
|
||||
Input::get()->bindKey(input_exit, SDL_SCANCODE_ESCAPE);
|
||||
Input::get()->bindKey(input_window_dec_size, SDL_SCANCODE_F1);
|
||||
Input::get()->bindKey(input_window_inc_size, SDL_SCANCODE_F2);
|
||||
Input::get()->bindKey(input_toggle_videomode, SDL_SCANCODE_F3);
|
||||
Input::get()->bindKey(input_toggle_shaders, SDL_SCANCODE_F4);
|
||||
Input::get()->bindKey(input_toggle_palette, SDL_SCANCODE_F5);
|
||||
Input::get()->bindKey(input_toggle_music, SDL_SCANCODE_M);
|
||||
Input::get()->bindKey(input_toggle_border, SDL_SCANCODE_B);
|
||||
Input::get()->bindKey(InputAction::ACCEPT, SDL_SCANCODE_RETURN);
|
||||
Input::get()->bindKey(InputAction::CANCEL, SDL_SCANCODE_ESCAPE);
|
||||
Input::get()->bindKey(InputAction::PAUSE, SDL_SCANCODE_H);
|
||||
Input::get()->bindKey(InputAction::EXIT, SDL_SCANCODE_ESCAPE);
|
||||
Input::get()->bindKey(InputAction::WINDOW_DEC_ZOOM, SDL_SCANCODE_F1);
|
||||
Input::get()->bindKey(InputAction::WINDOW_INC_ZOOM, SDL_SCANCODE_F2);
|
||||
Input::get()->bindKey(InputAction::TOGGLE_VIDEOMODE, SDL_SCANCODE_F3);
|
||||
Input::get()->bindKey(InputAction::TOGGLE_SHADERS, SDL_SCANCODE_F4);
|
||||
Input::get()->bindKey(InputAction::TOGGLE_PALETTE, SDL_SCANCODE_F5);
|
||||
Input::get()->bindKey(InputAction::TOGGLE_MUSIC, SDL_SCANCODE_M);
|
||||
Input::get()->bindKey(InputAction::TOGGLE_BORDER, SDL_SCANCODE_B);
|
||||
|
||||
// Mando - Movimiento
|
||||
Input::get()->bindGameControllerButton(input_jump, SDL_CONTROLLER_BUTTON_B);
|
||||
Input::get()->bindGameControllerButton(input_left, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
|
||||
Input::get()->bindGameControllerButton(input_right, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
|
||||
Input::get()->bindGameControllerButton(InputAction::JUMP, SDL_CONTROLLER_BUTTON_B);
|
||||
Input::get()->bindGameControllerButton(InputAction::LEFT, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
|
||||
Input::get()->bindGameControllerButton(InputAction::RIGHT, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
|
||||
|
||||
// Mando - Otros
|
||||
Input::get()->bindGameControllerButton(input_accept, SDL_CONTROLLER_BUTTON_B);
|
||||
Input::get()->bindGameControllerButton(input_cancel, SDL_CONTROLLER_BUTTON_A);
|
||||
Input::get()->bindGameControllerButton(InputAction::ACCEPT, SDL_CONTROLLER_BUTTON_B);
|
||||
Input::get()->bindGameControllerButton(InputAction::CANCEL, SDL_CONTROLLER_BUTTON_A);
|
||||
#ifdef GAME_CONSOLE
|
||||
Input::get()->bindGameControllerButton(input_pause, SDL_CONTROLLER_BUTTON_BACK);
|
||||
Input::get()->bindGameControllerButton(input_exit, SDL_CONTROLLER_BUTTON_START);
|
||||
Input::get()->bindGameControllerButton(InputAction::input_pause, SDL_CONTROLLER_BUTTON_BACK);
|
||||
Input::get()->bindGameControllerButton(InputAction::input_exit, SDL_CONTROLLER_BUTTON_START);
|
||||
#else
|
||||
Input::get()->bindGameControllerButton(input_pause, SDL_CONTROLLER_BUTTON_START);
|
||||
Input::get()->bindGameControllerButton(input_exit, SDL_CONTROLLER_BUTTON_BACK);
|
||||
Input::get()->bindGameControllerButton(InputAction::PAUSE, SDL_CONTROLLER_BUTTON_START);
|
||||
Input::get()->bindGameControllerButton(InputAction::EXIT, SDL_CONTROLLER_BUTTON_BACK);
|
||||
#endif
|
||||
Input::get()->bindGameControllerButton(input_toggle_palette, SDL_CONTROLLER_BUTTON_LEFTSHOULDER);
|
||||
Input::get()->bindGameControllerButton(input_toggle_music, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);
|
||||
Input::get()->bindGameControllerButton(input_toggle_border, SDL_CONTROLLER_BUTTON_X);
|
||||
Input::get()->bindGameControllerButton(InputAction::TOGGLE_PALETTE, SDL_CONTROLLER_BUTTON_LEFTSHOULDER);
|
||||
Input::get()->bindGameControllerButton(InputAction::TOGGLE_MUSIC, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);
|
||||
Input::get()->bindGameControllerButton(InputAction::TOGGLE_BORDER, SDL_CONTROLLER_BUTTON_X);
|
||||
}
|
||||
|
||||
// Inicializa JailAudio
|
||||
@@ -405,7 +405,7 @@ bool Director::setFileList()
|
||||
|
||||
// Datos
|
||||
Asset::get()->add(prefix + "/data/input/gamecontrollerdb.txt", AssetType::DATA);
|
||||
|
||||
|
||||
// Test
|
||||
Asset::get()->add(prefix + "/data/test.gif", AssetType::DATA);
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ private:
|
||||
int pos; // Posición
|
||||
};
|
||||
|
||||
struct asdhk
|
||||
struct TextIndex
|
||||
{
|
||||
int index;
|
||||
int trigger;
|
||||
@@ -42,7 +42,7 @@ private:
|
||||
|
||||
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 counter_end; // Valor del contador en el que finaliza la escena
|
||||
};
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "notifier.h"
|
||||
#include "global_inputs.h"
|
||||
#include "global_events.h"
|
||||
//#include "surface.h"
|
||||
// #include "surface.h"
|
||||
|
||||
// Constructor
|
||||
Game::Game()
|
||||
@@ -37,7 +37,7 @@ Game::Game()
|
||||
cheevos_(Cheevos::get())
|
||||
{
|
||||
// Inicia algunas variables
|
||||
//test_surface_ = std::make_shared<Surface>(Screen::get()->getSurface(), "test.gif");
|
||||
// test_surface_ = std::make_shared<Surface>(Screen::get()->getSurface(), "test.gif");
|
||||
board_ = std::make_shared<ScoreboardData>();
|
||||
board_->ini_clock = SDL_GetTicks();
|
||||
#ifdef DEBUG
|
||||
@@ -182,14 +182,14 @@ void Game::checkEvents()
|
||||
// Comprueba el teclado
|
||||
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 ? JA_ResumeMusic() : JA_PauseMusic();
|
||||
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();
|
||||
Notifier::get()->show({std::string(paused_ ? "GAME PAUSED" : "GAME RUNNING")}, NotificationText::CENTER);
|
||||
@@ -262,7 +262,7 @@ void Game::render()
|
||||
{
|
||||
// Prepara para dibujar el frame
|
||||
screen_->start();
|
||||
//test_surface_->render(0, 0, 10, 10, 64, 64);
|
||||
// test_surface_->render(0, 0, 10, 10, 64, 64);
|
||||
|
||||
// Dibuja los elementos del juego en orden
|
||||
room_->renderMap();
|
||||
|
||||
@@ -54,29 +54,29 @@ namespace globalInputs
|
||||
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
|
||||
void check()
|
||||
{
|
||||
if (Input::get()->checkInput(input_exit, REPEAT_FALSE))
|
||||
if (Input::get()->checkInput(InputAction::EXIT, REPEAT_FALSE))
|
||||
{
|
||||
quit();
|
||||
}
|
||||
|
||||
else if (Input::get()->checkInput(input_accept, REPEAT_FALSE))
|
||||
else if (Input::get()->checkInput(InputAction::ACCEPT, REPEAT_FALSE))
|
||||
{
|
||||
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();
|
||||
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();
|
||||
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())
|
||||
{
|
||||
@@ -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())
|
||||
{
|
||||
@@ -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();
|
||||
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();
|
||||
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;
|
||||
kb.scancode = 0;
|
||||
kb.active = false;
|
||||
key_bindings_.resize(input_number_of_inputs, kb);
|
||||
key_bindings_.resize(static_cast<int>(InputAction::SIZE), kb);
|
||||
|
||||
GameControllerBindings_t gcb;
|
||||
gcb.button = SDL_CONTROLLER_BUTTON_INVALID;
|
||||
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
|
||||
@@ -53,19 +53,19 @@ void Input::update()
|
||||
}
|
||||
|
||||
// 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
|
||||
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
|
||||
bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
||||
bool Input::checkInput(InputAction input, bool repeat, int device, int index)
|
||||
{
|
||||
if (!enabled_)
|
||||
{
|
||||
@@ -86,7 +86,7 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
||||
|
||||
if (repeat)
|
||||
{
|
||||
if (keyStates[key_bindings_[input].scancode] != 0)
|
||||
if (keyStates[key_bindings_.at(static_cast<int>(input)).scancode] != 0)
|
||||
{
|
||||
successKeyboard = true;
|
||||
}
|
||||
@@ -97,11 +97,11 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
||||
}
|
||||
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;
|
||||
}
|
||||
else
|
||||
@@ -111,9 +111,9 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
||||
}
|
||||
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;
|
||||
}
|
||||
else
|
||||
@@ -129,7 +129,7 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
||||
{
|
||||
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;
|
||||
}
|
||||
@@ -140,11 +140,11 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
||||
}
|
||||
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;
|
||||
}
|
||||
else
|
||||
@@ -154,9 +154,9 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
||||
}
|
||||
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;
|
||||
}
|
||||
else
|
||||
@@ -197,7 +197,7 @@ bool Input::checkAnyInput(int device, int index)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -15,31 +15,31 @@ constexpr int INPUT_USE_KEYBOARD = 0;
|
||||
constexpr int INPUT_USE_GAMECONTROLLER = 1;
|
||||
constexpr int INPUT_USE_ANY = 2;
|
||||
|
||||
enum inputs_e
|
||||
enum class InputAction
|
||||
{
|
||||
// Inputs obligatorios
|
||||
input_null,
|
||||
input_up,
|
||||
input_down,
|
||||
input_left,
|
||||
input_right,
|
||||
input_pause,
|
||||
input_exit,
|
||||
input_accept,
|
||||
input_cancel,
|
||||
NONE,
|
||||
UP,
|
||||
DOWN,
|
||||
LEFT,
|
||||
RIGHT,
|
||||
PAUSE,
|
||||
EXIT,
|
||||
ACCEPT,
|
||||
CANCEL,
|
||||
|
||||
// Inputs personalizados
|
||||
input_jump,
|
||||
input_window_inc_size,
|
||||
input_window_dec_size,
|
||||
input_toggle_videomode,
|
||||
input_toggle_border,
|
||||
input_toggle_music,
|
||||
input_toggle_palette,
|
||||
input_toggle_shaders,
|
||||
JUMP,
|
||||
WINDOW_INC_ZOOM,
|
||||
WINDOW_DEC_ZOOM,
|
||||
TOGGLE_VIDEOMODE,
|
||||
TOGGLE_BORDER,
|
||||
TOGGLE_MUSIC,
|
||||
TOGGLE_PALETTE,
|
||||
TOGGLE_SHADERS,
|
||||
|
||||
// Input obligatorio
|
||||
input_number_of_inputs
|
||||
SIZE
|
||||
};
|
||||
|
||||
enum i_disable_e
|
||||
@@ -100,13 +100,13 @@ public:
|
||||
void update();
|
||||
|
||||
// Asigna inputs a teclas
|
||||
void bindKey(Uint8 input, SDL_Scancode code);
|
||||
void bindKey(InputAction input, SDL_Scancode code);
|
||||
|
||||
// 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
|
||||
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
|
||||
bool checkAnyInput(int device = INPUT_USE_ANY, int index = 0);
|
||||
|
||||
@@ -82,13 +82,13 @@ void Player::checkInput()
|
||||
if (!auto_movement_)
|
||||
{
|
||||
// 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;
|
||||
sprite_->setFlip(SDL_FLIP_HORIZONTAL);
|
||||
}
|
||||
|
||||
else if (input_->checkInput(input_right))
|
||||
else if (input_->checkInput(InputAction::RIGHT))
|
||||
{
|
||||
vx_ = 0.6f;
|
||||
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)
|
||||
// Esta sobre el suelo, rampa o suelo que se mueve
|
||||
|
||||
@@ -59,7 +59,7 @@ Title::Title()
|
||||
pSetSource(loading_screen_);
|
||||
|
||||
// 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.subsection = Subsection::NONE;
|
||||
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?";
|
||||
for (int i = 0; i < (int)long_text_.length(); ++i)
|
||||
{
|
||||
letter_t l;
|
||||
TitleLetter l;
|
||||
l.letter = long_text_.substr(i, 1);
|
||||
l.x = 256;
|
||||
l.enabled = false;
|
||||
@@ -137,26 +137,26 @@ void Title::checkInput()
|
||||
{
|
||||
if (show_cheevos_)
|
||||
{
|
||||
if (input_->checkInput(input_down, REPEAT_TRUE))
|
||||
if (input_->checkInput(InputAction::DOWN, REPEAT_TRUE))
|
||||
{
|
||||
moveCheevosList(1);
|
||||
}
|
||||
else if (input_->checkInput(input_up, REPEAT_TRUE))
|
||||
else if (input_->checkInput(InputAction::UP, REPEAT_TRUE))
|
||||
{
|
||||
moveCheevosList(0);
|
||||
}
|
||||
else if (input_->checkInput(input_accept, REPEAT_FALSE))
|
||||
else if (input_->checkInput(InputAction::ACCEPT, REPEAT_FALSE))
|
||||
{
|
||||
hideCheevosList();
|
||||
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_)
|
||||
{
|
||||
case show_loading_screen:
|
||||
case TitleState::SHOW_LOADING_SCREEN:
|
||||
if (counter_ == 500)
|
||||
{
|
||||
counter_ = 0;
|
||||
state_ = fade_loading_screen;
|
||||
state_ = TitleState::FADE_LOADING_SCREEN;
|
||||
}
|
||||
break;
|
||||
|
||||
case fade_loading_screen:
|
||||
case TitleState::FADE_LOADING_SCREEN:
|
||||
if (counter_ % 4 == 0)
|
||||
{
|
||||
if (pFadePal())
|
||||
{
|
||||
counter_ = 0;
|
||||
state_ = show_menu;
|
||||
state_ = TitleState::SHOW_MENU;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case show_menu:
|
||||
case TitleState::SHOW_MENU:
|
||||
// Actualiza la marquesina
|
||||
updateMarquee();
|
||||
|
||||
@@ -277,7 +279,7 @@ void Title::render()
|
||||
screen_->start();
|
||||
screen_->clean(stringToColor(options.video.palette, "black"));
|
||||
|
||||
if (state_ == show_menu)
|
||||
if (state_ == TitleState::SHOW_MENU)
|
||||
{
|
||||
// Dibuja la textura de fondo
|
||||
SDL_RenderCopy(renderer_, bg_texture_, nullptr, nullptr);
|
||||
@@ -389,7 +391,7 @@ void Title::fillTexture()
|
||||
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, 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);
|
||||
|
||||
// Devuelve el puntero del renderizador a su sitio
|
||||
|
||||
@@ -17,18 +17,18 @@ class Texture; // lines 18-18
|
||||
class Title
|
||||
{
|
||||
private:
|
||||
struct letter_t
|
||||
struct TitleLetter
|
||||
{
|
||||
std::string letter; // Letra a escribir
|
||||
int x; // Posición en el eje x
|
||||
bool enabled; // Solo se escriben y mueven si estan habilitadas
|
||||
};
|
||||
|
||||
enum states_e
|
||||
enum class TitleState
|
||||
{
|
||||
show_loading_screen,
|
||||
fade_loading_screen,
|
||||
show_menu
|
||||
SHOW_LOADING_SCREEN,
|
||||
FADE_LOADING_SCREEN,
|
||||
SHOW_MENU
|
||||
};
|
||||
|
||||
// Objetos y punteros
|
||||
@@ -45,15 +45,15 @@ private:
|
||||
std::shared_ptr<Sprite> cheevos_sprite_; // Sprite para manejar la textura con la lista de logros
|
||||
|
||||
// Variables
|
||||
int counter_ = 0; // Contador
|
||||
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
|
||||
std::vector<letter_t> letters_; // Vector con las letras 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
|
||||
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
|
||||
jSurface loading_screen_; // Surface con los gráficos de la pantalla de carga
|
||||
int counter_ = 0; // Contador
|
||||
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
|
||||
std::vector<TitleLetter> letters_; // Vector con las letras 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
|
||||
SDL_Rect cheevos_texture_view_; // Zona visible de la textura con el listado de logros
|
||||
TitleState state_; // Estado en el que se encuentra el bucle principal
|
||||
jSurface loading_screen_; // Surface con los gráficos de la pantalla de carga
|
||||
|
||||
// Actualiza las variables
|
||||
void update();
|
||||
|
||||
Reference in New Issue
Block a user