forked from jaildesigner-jailgames/jaildoctors_dilemma
globalInputs implementat en totes les seccions excepte Title i Game
This commit is contained in:
@@ -44,24 +44,6 @@ constexpr int GAMECANVAS_CENTER_Y = GAMECANVAS_HEIGHT / 2;
|
||||
constexpr int GAMECANVAS_FIRST_QUARTER_Y = GAMECANVAS_HEIGHT / 4;
|
||||
constexpr int GAMECANVAS_THIRD_QUARTER_Y = (GAMECANVAS_HEIGHT / 4) * 3;
|
||||
|
||||
// Secciones del programa
|
||||
constexpr int SECTION_LOGO = 0;
|
||||
constexpr int SECTION_LOADING_SCREEN = 1;
|
||||
constexpr int SECTION_TITLE = 2;
|
||||
constexpr int SECTION_CREDITS = 3;
|
||||
constexpr int SECTION_GAME = 4;
|
||||
constexpr int SECTION_DEMO = 5;
|
||||
constexpr int SECTION_GAME_OVER = 6;
|
||||
constexpr int SECTION_ENDING = 7;
|
||||
constexpr int SECTION_ENDING2 = 8;
|
||||
constexpr int SECTION_QUIT = 9;
|
||||
|
||||
// Subsecciones
|
||||
constexpr int SUBSECTION_LOGO_TO_INTRO = 0;
|
||||
constexpr int SUBSECTION_LOGO_TO_TITLE = 1;
|
||||
constexpr int SUBSECTION_TITLE_WITH_LOADING_SCREEN = 2;
|
||||
constexpr int SUBSECTION_TITLE_WITHOUT_LOADING_SCREEN = 3;
|
||||
|
||||
// Colores
|
||||
const color_t borderColor = {0x27, 0x27, 0x36};
|
||||
const color_t black = {0xFF, 0xFF, 0xFF};
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "text.h" // Para Text, TXT_CENTER, TXT_COLOR
|
||||
#include "asset.h"
|
||||
#include "options.h"
|
||||
#include "global_inputs.h"
|
||||
class Asset;
|
||||
|
||||
// Constructor
|
||||
@@ -89,42 +90,7 @@ void Credits::checkEvents()
|
||||
// Comprueba las entradas
|
||||
void Credits::checkInput()
|
||||
{
|
||||
|
||||
if (input_->checkInput(input_exit, REPEAT_FALSE))
|
||||
{
|
||||
options.section.name = SECTION_QUIT;
|
||||
}
|
||||
|
||||
else if (input_->checkInput(input_toggle_border, REPEAT_FALSE))
|
||||
{
|
||||
screen_->toggleBorder();
|
||||
}
|
||||
|
||||
else if (input_->checkInput(input_toggle_videomode, REPEAT_FALSE))
|
||||
{
|
||||
screen_->toggleVideoMode();
|
||||
}
|
||||
|
||||
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_toggle_palette, REPEAT_FALSE))
|
||||
{
|
||||
switchPalette();
|
||||
}
|
||||
|
||||
else if (input_->checkInput(input_pause, REPEAT_FALSE) || input_->checkInput(input_accept, REPEAT_FALSE) || input_->checkInput(input_jump, REPEAT_FALSE))
|
||||
{
|
||||
options.section.name = SECTION_TITLE;
|
||||
options.section.subsection = 0;
|
||||
}
|
||||
globalInputs::check();
|
||||
}
|
||||
|
||||
// Inicializa los textos
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "utils.h" // Para color_t, stringToColor, options_t, secti...
|
||||
#include "options.h"
|
||||
#include "debug.h"
|
||||
#include "global_inputs.h"
|
||||
|
||||
// Constructor
|
||||
Demo::Demo()
|
||||
@@ -87,45 +88,7 @@ void Demo::checkEvents()
|
||||
// Comprueba las entradas
|
||||
void Demo::checkInput()
|
||||
{
|
||||
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||
{
|
||||
options.section.name = SECTION_QUIT;
|
||||
}
|
||||
|
||||
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
|
||||
{
|
||||
screen->toggleBorder();
|
||||
reLoadTextures();
|
||||
}
|
||||
|
||||
else if (input->checkInput(input_toggle_videomode, REPEAT_FALSE))
|
||||
{
|
||||
screen->toggleVideoMode();
|
||||
reLoadTextures();
|
||||
}
|
||||
|
||||
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
|
||||
{
|
||||
screen->decWindowSize();
|
||||
reLoadTextures();
|
||||
}
|
||||
|
||||
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
|
||||
{
|
||||
screen->incWindowSize();
|
||||
reLoadTextures();
|
||||
}
|
||||
|
||||
else if (input->checkInput(input_toggle_palette, REPEAT_FALSE))
|
||||
{
|
||||
switchPalette();
|
||||
}
|
||||
|
||||
else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_jump, REPEAT_FALSE))
|
||||
{
|
||||
options.section.name = SECTION_TITLE;
|
||||
options.section.subsection = 0;
|
||||
}
|
||||
globalInputs::check();
|
||||
}
|
||||
|
||||
// Bucle para el juego
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "texture.h" // Para Texture
|
||||
#include "utils.h" // Para color_t, stringToColor, options_t
|
||||
#include "options.h"
|
||||
#include "global_inputs.h"
|
||||
|
||||
// Constructor
|
||||
Ending::Ending()
|
||||
@@ -172,37 +173,7 @@ void Ending::checkEvents()
|
||||
// Comprueba las entradas
|
||||
void Ending::checkInput()
|
||||
{
|
||||
|
||||
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||
{
|
||||
options.section.name = SECTION_LOGO;
|
||||
options.section.subsection = SUBSECTION_LOGO_TO_INTRO;
|
||||
}
|
||||
|
||||
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
|
||||
{
|
||||
screen->toggleBorder();
|
||||
}
|
||||
|
||||
else if (input->checkInput(input_toggle_videomode, REPEAT_FALSE))
|
||||
{
|
||||
screen->toggleVideoMode();
|
||||
}
|
||||
|
||||
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_toggle_palette, REPEAT_FALSE))
|
||||
{
|
||||
switchPalette();
|
||||
}
|
||||
globalInputs::check();
|
||||
}
|
||||
|
||||
// Inicializa los textos
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "texture.h" // for Texture
|
||||
#include "utils.h" // for color_t, stringToColor, options_t
|
||||
#include "options.h"
|
||||
#include "global_inputs.h"
|
||||
|
||||
// Constructor
|
||||
Ending2::Ending2()
|
||||
@@ -202,37 +203,7 @@ void Ending2::checkEvents()
|
||||
// Comprueba las entradas
|
||||
void Ending2::checkInput()
|
||||
{
|
||||
|
||||
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||
{
|
||||
options.section.name = SECTION_LOGO;
|
||||
options.section.subsection = SUBSECTION_LOGO_TO_INTRO;
|
||||
}
|
||||
|
||||
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
|
||||
{
|
||||
screen->toggleBorder();
|
||||
}
|
||||
|
||||
else if (input->checkInput(input_toggle_videomode, REPEAT_FALSE))
|
||||
{
|
||||
screen->toggleVideoMode();
|
||||
}
|
||||
|
||||
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_toggle_palette, REPEAT_FALSE))
|
||||
{
|
||||
switchPalette();
|
||||
}
|
||||
globalInputs::check();
|
||||
}
|
||||
|
||||
// Bucle principal
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "utils.h" // for options_t, cheat_t, stringToColor
|
||||
#include "options.h"
|
||||
#include "notifier.h"
|
||||
#include "global_inputs.h"
|
||||
|
||||
// Constructor
|
||||
Game::Game()
|
||||
@@ -201,12 +202,7 @@ void Game::checkEvents()
|
||||
// Comprueba el teclado
|
||||
void Game::checkInput()
|
||||
{
|
||||
if (input_->checkInput(input_exit, REPEAT_FALSE))
|
||||
{
|
||||
options.section.name = SECTION_TITLE;
|
||||
}
|
||||
|
||||
else if (input_->checkInput(input_toggle_music, REPEAT_FALSE))
|
||||
if (input_->checkInput(input_toggle_music, REPEAT_FALSE))
|
||||
{
|
||||
board_.music = !board_.music;
|
||||
board_.music ? JA_ResumeMusic() : JA_PauseMusic();
|
||||
@@ -217,39 +213,7 @@ void Game::checkInput()
|
||||
switchPause();
|
||||
}
|
||||
|
||||
else if (input_->checkInput(input_toggle_border, REPEAT_FALSE))
|
||||
{
|
||||
screen_->toggleBorder();
|
||||
reLoadTextures();
|
||||
}
|
||||
|
||||
else if (input_->checkInput(input_toggle_videomode, REPEAT_FALSE))
|
||||
{
|
||||
screen_->toggleVideoMode();
|
||||
reLoadTextures();
|
||||
}
|
||||
|
||||
else if (input_->checkInput(input_toggle_shaders, REPEAT_FALSE))
|
||||
{
|
||||
screen_->toggleShaders();
|
||||
}
|
||||
|
||||
else if (input_->checkInput(input_window_dec_size, REPEAT_FALSE))
|
||||
{
|
||||
screen_->decWindowSize();
|
||||
reLoadTextures();
|
||||
}
|
||||
|
||||
else if (input_->checkInput(input_window_inc_size, REPEAT_FALSE))
|
||||
{
|
||||
screen_->incWindowSize();
|
||||
reLoadTextures();
|
||||
}
|
||||
|
||||
else if (input_->checkInput(input_toggle_palette, REPEAT_FALSE))
|
||||
{
|
||||
switchPalette();
|
||||
}
|
||||
globalInputs::check();
|
||||
}
|
||||
|
||||
// Bucle para el juego
|
||||
@@ -506,7 +470,7 @@ void Game::killPlayer()
|
||||
setBlackScreen();
|
||||
|
||||
// Crea la nueva habitación y el nuevo jugador
|
||||
room_ = new Room(resource_->getRoom(current_room_),item_tracker_, &board_.items, board_.jailEnabled);
|
||||
room_ = new Room(resource_->getRoom(current_room_), item_tracker_, &board_.items, board_.jailEnabled);
|
||||
const std::string playerPNG = options.cheat.altSkin ? "player2.png" : "player.png";
|
||||
const std::string playerANI = options.cheat.altSkin ? "player2.ani" : "player.ani";
|
||||
const player_t player = {spawn_point_, playerPNG, playerANI, room_};
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "text.h" // Para Text, TXT_CENTER, TXT_COLOR
|
||||
#include "texture.h" // Para Texture
|
||||
#include "options.h"
|
||||
#include "global_inputs.h"
|
||||
|
||||
// Constructor
|
||||
GameOver::GameOver()
|
||||
@@ -139,36 +140,7 @@ void GameOver::checkEvents()
|
||||
// Comprueba las entradas
|
||||
void GameOver::checkInput()
|
||||
{
|
||||
|
||||
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||
{
|
||||
options.section.name = SECTION_QUIT;
|
||||
}
|
||||
|
||||
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
|
||||
{
|
||||
screen->toggleBorder();
|
||||
}
|
||||
|
||||
else if (input->checkInput(input_toggle_videomode, REPEAT_FALSE))
|
||||
{
|
||||
screen->toggleVideoMode();
|
||||
}
|
||||
|
||||
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_toggle_palette, REPEAT_FALSE))
|
||||
{
|
||||
switchPalette();
|
||||
}
|
||||
globalInputs::check();
|
||||
}
|
||||
|
||||
// Bucle principal
|
||||
|
||||
79
source/global_inputs.cpp
Normal file
79
source/global_inputs.cpp
Normal file
@@ -0,0 +1,79 @@
|
||||
#include "global_inputs.h"
|
||||
#include "input.h" // Para Input, InputDeviceToUse, InputType, INPU...
|
||||
#include "notifier.h" // Para Notifier
|
||||
#include "options.h" // Para Options, options, OptionsGame, OptionsAudio
|
||||
#include "screen.h" // Para Screen, ScreenVideoMode
|
||||
|
||||
namespace globalInputs
|
||||
{
|
||||
// Cambia la paleta
|
||||
void switchPalette()
|
||||
{
|
||||
options.palette = options.palette == p_zxspectrum ? p_zxarne : p_zxspectrum;
|
||||
}
|
||||
|
||||
// Cambia de seccion
|
||||
void skip_section()
|
||||
{
|
||||
switch (options.section.name)
|
||||
{
|
||||
case SECTION_LOGO:
|
||||
case SECTION_LOADING_SCREEN:
|
||||
case SECTION_CREDITS:
|
||||
case SECTION_DEMO:
|
||||
case SECTION_GAME_OVER:
|
||||
case SECTION_ENDING:
|
||||
case SECTION_ENDING2:
|
||||
options.section.name = SECTION_TITLE;
|
||||
options.section.subsection = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
|
||||
void check()
|
||||
{
|
||||
if (Input::get()->checkInput(input_exit, REPEAT_FALSE))
|
||||
{
|
||||
options.section.name = SECTION_QUIT;
|
||||
}
|
||||
|
||||
else if (Input::get()->checkInput(input_accept, REPEAT_FALSE))
|
||||
{
|
||||
skip_section();
|
||||
}
|
||||
|
||||
else if (Input::get()->checkInput(input_toggle_border, REPEAT_FALSE))
|
||||
{
|
||||
Screen::get()->toggleBorder();
|
||||
}
|
||||
|
||||
else if (Input::get()->checkInput(input_toggle_videomode, REPEAT_FALSE))
|
||||
{
|
||||
Screen::get()->toggleVideoMode();
|
||||
}
|
||||
|
||||
else if (Input::get()->checkInput(input_window_dec_size, REPEAT_FALSE))
|
||||
{
|
||||
Screen::get()->decWindowSize();
|
||||
}
|
||||
|
||||
else if (Input::get()->checkInput(input_window_inc_size, REPEAT_FALSE))
|
||||
{
|
||||
Screen::get()->incWindowSize();
|
||||
}
|
||||
|
||||
else if (Input::get()->checkInput(input_toggle_shaders, REPEAT_FALSE))
|
||||
{
|
||||
Screen::get()->toggleShaders();
|
||||
}
|
||||
|
||||
else if (Input::get()->checkInput(input_toggle_palette, REPEAT_FALSE))
|
||||
{
|
||||
switchPalette();
|
||||
}
|
||||
}
|
||||
}
|
||||
5
source/global_inputs.h
Normal file
5
source/global_inputs.h
Normal file
@@ -0,0 +1,5 @@
|
||||
namespace globalInputs
|
||||
{
|
||||
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
|
||||
void check();
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "texture.h" // for Texture
|
||||
#include "utils.h" // for options_t, section_t, color_t, stringToC...
|
||||
#include "options.h"
|
||||
#include "global_inputs.h"
|
||||
|
||||
// Constructor
|
||||
LoadingScreen::LoadingScreen()
|
||||
@@ -92,42 +93,7 @@ void LoadingScreen::checkEvents()
|
||||
// Comprueba las entradas
|
||||
void LoadingScreen::checkInput()
|
||||
{
|
||||
|
||||
if (input_->checkInput(input_exit, REPEAT_FALSE))
|
||||
{
|
||||
options.section.name = SECTION_QUIT;
|
||||
}
|
||||
|
||||
else if (input_->checkInput(input_toggle_border, REPEAT_FALSE))
|
||||
{
|
||||
screen_->toggleBorder();
|
||||
}
|
||||
|
||||
else if (input_->checkInput(input_toggle_videomode, REPEAT_FALSE))
|
||||
{
|
||||
screen_->toggleVideoMode();
|
||||
}
|
||||
|
||||
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_toggle_palette, REPEAT_FALSE))
|
||||
{
|
||||
switchPalette();
|
||||
}
|
||||
|
||||
else if (input_->checkInput(input_pause, REPEAT_FALSE) || input_->checkInput(input_accept, REPEAT_FALSE) || input_->checkInput(input_jump, REPEAT_FALSE))
|
||||
{
|
||||
options.section.name = SECTION_TITLE;
|
||||
options.section.subsection = 0;
|
||||
}
|
||||
globalInputs::check();
|
||||
}
|
||||
|
||||
// Gestiona el contador de carga
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "utils.h" // for color_t, section_t, options_t, stringToC...
|
||||
#include "asset.h"
|
||||
#include "options.h"
|
||||
#include "global_inputs.h"
|
||||
class Asset; // lines 11-11
|
||||
|
||||
// Constructor
|
||||
@@ -87,41 +88,7 @@ void Logo::checkEvents()
|
||||
// Comprueba las entradas
|
||||
void Logo::checkInput()
|
||||
{
|
||||
if (input_->checkInput(input_exit, REPEAT_FALSE))
|
||||
{
|
||||
options.section.name = SECTION_TITLE;
|
||||
}
|
||||
|
||||
else if (input_->checkInput(input_toggle_border, REPEAT_FALSE))
|
||||
{
|
||||
screen_->toggleBorder();
|
||||
}
|
||||
|
||||
else if (input_->checkInput(input_toggle_videomode, REPEAT_FALSE))
|
||||
{
|
||||
screen_->toggleVideoMode();
|
||||
}
|
||||
|
||||
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_toggle_palette, REPEAT_FALSE))
|
||||
{
|
||||
switchPalette();
|
||||
}
|
||||
|
||||
else if (input_->checkInput(input_pause, REPEAT_FALSE) || input_->checkInput(input_accept, REPEAT_FALSE) || input_->checkInput(input_jump, REPEAT_FALSE))
|
||||
{
|
||||
options.section.subsection = SUBSECTION_LOGO_TO_TITLE;
|
||||
endSection();
|
||||
}
|
||||
globalInputs::check();
|
||||
}
|
||||
|
||||
// Gestiona el logo de JAILGAME
|
||||
@@ -310,12 +277,6 @@ void Logo::run()
|
||||
}
|
||||
}
|
||||
|
||||
// Cambia la paleta
|
||||
void Logo::switchPalette()
|
||||
{
|
||||
options.palette = options.palette == p_zxspectrum ? p_zxarne : p_zxspectrum;
|
||||
}
|
||||
|
||||
// Termina la sección
|
||||
void Logo::endSection()
|
||||
{
|
||||
|
||||
@@ -55,9 +55,6 @@ private:
|
||||
// Gestiona el color de las texturas
|
||||
void updateTextureColors();
|
||||
|
||||
// Cambia la paleta
|
||||
void switchPalette();
|
||||
|
||||
// Termina la sección
|
||||
void endSection();
|
||||
|
||||
|
||||
@@ -5,6 +5,24 @@
|
||||
#include <string> // Para string, basic_string
|
||||
#include "utils.h"
|
||||
|
||||
// Secciones del programa
|
||||
constexpr int SECTION_LOGO = 0;
|
||||
constexpr int SECTION_LOADING_SCREEN = 1;
|
||||
constexpr int SECTION_TITLE = 2;
|
||||
constexpr int SECTION_CREDITS = 3;
|
||||
constexpr int SECTION_GAME = 4;
|
||||
constexpr int SECTION_DEMO = 5;
|
||||
constexpr int SECTION_GAME_OVER = 6;
|
||||
constexpr int SECTION_ENDING = 7;
|
||||
constexpr int SECTION_ENDING2 = 8;
|
||||
constexpr int SECTION_QUIT = 9;
|
||||
|
||||
// Subsecciones
|
||||
constexpr int SUBSECTION_LOGO_TO_INTRO = 0;
|
||||
constexpr int SUBSECTION_LOGO_TO_TITLE = 1;
|
||||
constexpr int SUBSECTION_TITLE_WITH_LOADING_SCREEN = 2;
|
||||
constexpr int SUBSECTION_TITLE_WITHOUT_LOADING_SCREEN = 3;
|
||||
|
||||
// Posiciones de las notificaciones
|
||||
enum not_pos_e
|
||||
{
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "texture.h" // Para Texture
|
||||
#include "utils.h" // Para color_t, stringToColor, options_t
|
||||
#include "options.h"
|
||||
#include "global_inputs.h"
|
||||
|
||||
// Constructor
|
||||
Title::Title()
|
||||
|
||||
Reference in New Issue
Block a user