forked from jaildesigner-jailgames/jaildoctors_dilemma
Nuevo: deshabilita input por un periodo de tiempo
This commit is contained in:
@@ -22,6 +22,7 @@ y1=1
|
||||
x2=29
|
||||
y2=1
|
||||
color=white
|
||||
flip=true
|
||||
[/enemy]
|
||||
|
||||
[enemy]
|
||||
@@ -38,6 +39,7 @@ y1=1
|
||||
x2=29
|
||||
y2=1
|
||||
color=red
|
||||
flip=true
|
||||
[/enemy]
|
||||
|
||||
[enemy]
|
||||
@@ -54,6 +56,7 @@ y1=7
|
||||
x2=27
|
||||
y2=7
|
||||
color=green
|
||||
flip=true
|
||||
[/enemy]
|
||||
|
||||
[item]
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 7.5 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 9.0 KiB After Width: | Height: | Size: 9.1 KiB |
@@ -21,6 +21,15 @@ Input::Input(std::string file)
|
||||
verbose = true;
|
||||
}
|
||||
|
||||
// Actualiza el estado del objeto
|
||||
void Input::update()
|
||||
{
|
||||
if (disabledUntil == d_keyPressed && !checkAnyInput())
|
||||
{
|
||||
enable();
|
||||
}
|
||||
}
|
||||
|
||||
// Asigna inputs a teclas
|
||||
void Input::bindKey(Uint8 input, SDL_Scancode code)
|
||||
{
|
||||
@@ -36,6 +45,11 @@ void Input::bindGameControllerButton(Uint8 input, SDL_GameControllerButton butto
|
||||
// Comprueba si un input esta activo
|
||||
bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
||||
{
|
||||
if (!enabled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool successKeyboard = false;
|
||||
bool successGameController = false;
|
||||
|
||||
@@ -280,4 +294,18 @@ int Input::getNumControllers()
|
||||
void Input::setVerbose(bool value)
|
||||
{
|
||||
verbose = value;
|
||||
}
|
||||
|
||||
// Deshabilita las entradas durante un periodo de tiempo
|
||||
void Input::disableUntil(i_disable_e value)
|
||||
{
|
||||
disabledUntil = value;
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
// Hablita las entradas
|
||||
void Input::enable()
|
||||
{
|
||||
enabled = true;
|
||||
disabledUntil = d_notDisabled;
|
||||
}
|
||||
@@ -32,7 +32,13 @@
|
||||
#define INPUT_USE_GAMECONTROLLER 1
|
||||
#define INPUT_USE_ANY 2
|
||||
|
||||
// Clase Input
|
||||
enum i_disable_e
|
||||
{
|
||||
d_notDisabled,
|
||||
d_forever,
|
||||
d_keyPressed
|
||||
};
|
||||
|
||||
class Input
|
||||
{
|
||||
private:
|
||||
@@ -58,11 +64,16 @@ private:
|
||||
int numGamepads; // Numero de mandos conectados
|
||||
std::string dbPath; // Ruta al archivo gamecontrollerdb.txt
|
||||
bool verbose; // Indica si ha de mostrar mensajes
|
||||
i_disable_e disabledUntil; // Tiempo que esta deshabilitado
|
||||
bool enabled; // Indica si está habilitado
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Input(std::string file);
|
||||
|
||||
// Actualiza el estado del objeto
|
||||
void update();
|
||||
|
||||
// Asigna inputs a teclas
|
||||
void bindKey(Uint8 input, SDL_Scancode code);
|
||||
|
||||
@@ -73,7 +84,7 @@ public:
|
||||
bool checkInput(Uint8 input, bool repeat, int device = INPUT_USE_ANY, int index = 0);
|
||||
|
||||
// Comprueba si hay almenos un input activo
|
||||
bool checkAnyInput(int device, int index);
|
||||
bool checkAnyInput(int device = INPUT_USE_ANY, int index = 0);
|
||||
|
||||
// Busca si hay un mando conectado
|
||||
bool discoverGameController();
|
||||
@@ -89,6 +100,12 @@ public:
|
||||
|
||||
// Establece si ha de mostrar mensajes
|
||||
void setVerbose(bool value);
|
||||
|
||||
// Deshabilita las entradas durante un periodo de tiempo
|
||||
void disableUntil(i_disable_e value);
|
||||
|
||||
// Hablita las entradas
|
||||
void enable();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -214,6 +214,7 @@ void Game::update()
|
||||
checkIfPlayerIsAlive();
|
||||
checkEndGame();
|
||||
scoreboard->update();
|
||||
input->update();
|
||||
|
||||
updateDebugInfo();
|
||||
updateBlackScreen();
|
||||
@@ -400,6 +401,7 @@ void Game::killPlayer()
|
||||
// Sonido
|
||||
JA_PlaySound(deathSound);
|
||||
|
||||
// Pone la pantalla en negro un tiempo
|
||||
setBlackScreen();
|
||||
|
||||
// Crea la nueva habitación y el nuevo jugador
|
||||
@@ -407,8 +409,12 @@ void Game::killPlayer()
|
||||
const player_t player = {spawnPoint, "player.png", "player.ani", renderer, resource, asset, options, input, room, debug};
|
||||
this->player = new Player(player);
|
||||
|
||||
// Pone los objetos en pausa mientras esta la habitación en negro
|
||||
room->pause();
|
||||
this->player->pause();
|
||||
|
||||
// Deshabilita las entradas hasta que no haya ninguna activa
|
||||
input->disableUntil(d_keyPressed);
|
||||
}
|
||||
|
||||
// Recarga todas las texturas
|
||||
|
||||
5
todo.txt
5
todo.txt
@@ -54,8 +54,9 @@ x (B) Así como no necesitar lo de frames per row
|
||||
x (C) Que no cree la ventana y luego añada el borde
|
||||
x (A) Las vidas del marcador no estan animadas. No cambian de frame
|
||||
(A) Mejorar las cintas. no permitir saltar hacia atras
|
||||
(A) Cambio de paleta en caliente
|
||||
(A) Precargar todos los recursos del juego
|
||||
x (A) Cambio de paleta en caliente
|
||||
x (A) Precargar todos los recursos del juego
|
||||
(A) Deshabilitar el input hasta que se suelten todas las teclas
|
||||
|
||||
|
||||
## TEMAS
|
||||
|
||||
Reference in New Issue
Block a user