Preparando el juego para ser compatble con consolas
This commit is contained in:
@@ -129,6 +129,10 @@ void Director::initOptions()
|
|||||||
options->borderHeight = 24;
|
options->borderHeight = 24;
|
||||||
options->palette = p_zxspectrum;
|
options->palette = p_zxspectrum;
|
||||||
|
|
||||||
|
#ifdef GAME_CONSOLE
|
||||||
|
options->windowSize = 2;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Estos valores no se guardan en el fichero de configuraci´ón
|
// Estos valores no se guardan en el fichero de configuraci´ón
|
||||||
options->console = false;
|
options->console = false;
|
||||||
options->cheat.infiniteLives = false;
|
options->cheat.infiniteLives = false;
|
||||||
@@ -1230,14 +1234,14 @@ void Director::initInput()
|
|||||||
input->bindKey(INPUT_BUTTON_PAUSE, SDL_SCANCODE_ESCAPE);
|
input->bindKey(INPUT_BUTTON_PAUSE, SDL_SCANCODE_ESCAPE);
|
||||||
input->bindKey(INPUT_BUTTON_ESCAPE, SDL_SCANCODE_ESCAPE);
|
input->bindKey(INPUT_BUTTON_ESCAPE, SDL_SCANCODE_ESCAPE);
|
||||||
|
|
||||||
input->bindGameControllerButton(INPUT_UP, SDL_CONTROLLER_BUTTON_DPAD_UP);
|
input->bindGameControllerButton(INPUT_UP, SDL_CONTROLLER_BUTTON_B);
|
||||||
input->bindGameControllerButton(INPUT_DOWN, SDL_CONTROLLER_BUTTON_DPAD_DOWN);
|
input->bindGameControllerButton(INPUT_DOWN, SDL_CONTROLLER_BUTTON_DPAD_DOWN);
|
||||||
input->bindGameControllerButton(INPUT_LEFT, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
|
input->bindGameControllerButton(INPUT_LEFT, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
|
||||||
input->bindGameControllerButton(INPUT_RIGHT, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
|
input->bindGameControllerButton(INPUT_RIGHT, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
|
||||||
input->bindGameControllerButton(INPUT_ACCEPT, SDL_CONTROLLER_BUTTON_B);
|
input->bindGameControllerButton(INPUT_ACCEPT, SDL_CONTROLLER_BUTTON_B);
|
||||||
input->bindGameControllerButton(INPUT_CANCEL, SDL_CONTROLLER_BUTTON_A);
|
input->bindGameControllerButton(INPUT_CANCEL, SDL_CONTROLLER_BUTTON_A);
|
||||||
input->bindGameControllerButton(INPUT_BUTTON_1, SDL_CONTROLLER_BUTTON_B);
|
input->bindGameControllerButton(INPUT_BUTTON_1, SDL_CONTROLLER_BUTTON_B);
|
||||||
input->bindGameControllerButton(INPUT_BUTTON_PAUSE, SDL_CONTROLLER_BUTTON_GUIDE);
|
input->bindGameControllerButton(INPUT_BUTTON_PAUSE, SDL_CONTROLLER_BUTTON_START);
|
||||||
input->bindGameControllerButton(INPUT_BUTTON_ESCAPE, SDL_CONTROLLER_BUTTON_GUIDE);
|
input->bindGameControllerButton(INPUT_BUTTON_ESCAPE, SDL_CONTROLLER_BUTTON_GUIDE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *
|
|||||||
l.enabled = false;
|
l.enabled = false;
|
||||||
letters.push_back(l);
|
letters.push_back(l);
|
||||||
}
|
}
|
||||||
letters.at(0).enabled = true;
|
letters[0].enabled = true;
|
||||||
marqueeSpeed = 3;
|
marqueeSpeed = 3;
|
||||||
|
|
||||||
// Cambia el color del borde
|
// Cambia el color del borde
|
||||||
@@ -70,6 +70,12 @@ void Title::checkEventHandler()
|
|||||||
// Comprueba las teclas que se han pulsado
|
// Comprueba las teclas que se han pulsado
|
||||||
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN))
|
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN))
|
||||||
{
|
{
|
||||||
|
if (eventHandler->type == SDL_JOYBUTTONDOWN)
|
||||||
|
{
|
||||||
|
section.name = SECTION_PROG_GAME;
|
||||||
|
section.subsection = 0;
|
||||||
|
}
|
||||||
|
|
||||||
switch (eventHandler->key.keysym.scancode)
|
switch (eventHandler->key.keysym.scancode)
|
||||||
{
|
{
|
||||||
case SDL_SCANCODE_ESCAPE:
|
case SDL_SCANCODE_ESCAPE:
|
||||||
@@ -133,20 +139,20 @@ void Title::updateMarquee()
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < (int)letters.size(); ++i)
|
for (int i = 0; i < (int)letters.size(); ++i)
|
||||||
{
|
{
|
||||||
if (letters.at(i).enabled)
|
if (letters[i].enabled)
|
||||||
{
|
{
|
||||||
letters.at(i).x -= marqueeSpeed;
|
letters[i].x -= marqueeSpeed;
|
||||||
if (letters.at(i).x < -10)
|
if (letters[i].x < -10)
|
||||||
{
|
{
|
||||||
letters.at(i).enabled = false;
|
letters[i].enabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (i > 0 && letters.at(i - 1).x < 256 && letters.at(i - 1).enabled)
|
if (i > 0 && letters[i - 1].x < 256 && letters[i - 1].enabled)
|
||||||
{
|
{
|
||||||
letters.at(i).enabled = true;
|
letters[i].enabled = true;
|
||||||
letters.at(i).x = letters.at(i - 1).x + text->lenght(letters.at(i - 1).letter) + 1;
|
letters[i].x = letters[i - 1].x + text->lenght(letters[i - 1].letter) + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -186,7 +192,7 @@ void Title::update()
|
|||||||
screen->updateNotifier();
|
screen->updateNotifier();
|
||||||
|
|
||||||
// Comprueba si ha terminado la marquesina y acaba con el titulo
|
// Comprueba si ha terminado la marquesina y acaba con el titulo
|
||||||
if (letters.at(letters.size() - 1).x < -10)
|
if (letters[letters.size() - 1].x < -10)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_CREDITS;
|
section.name = SECTION_PROG_CREDITS;
|
||||||
section.subsection = 0;
|
section.subsection = 0;
|
||||||
@@ -206,15 +212,6 @@ void Title::render()
|
|||||||
// Dibuja el fondo del titulo
|
// Dibuja el fondo del titulo
|
||||||
sprite->render();
|
sprite->render();
|
||||||
|
|
||||||
// Dibuja el texto de PRESS ENTER TO PLAY
|
|
||||||
// SDL_SetRenderDrawColor(renderer, 0, 0, 255, 255);
|
|
||||||
// const SDL_Rect rect = {0, 192 / 5 * 4, 256, 8};
|
|
||||||
// SDL_RenderFillRect(renderer, &rect);
|
|
||||||
// if (counter % 80 < 60)
|
|
||||||
//{
|
|
||||||
// text->writeCentered(256 / 2, 192 / 5 * 4, "PRESS ENTER TO PLAY");
|
|
||||||
//}
|
|
||||||
|
|
||||||
// Dibuja el texto de PRESS ENTER TO PLAY
|
// Dibuja el texto de PRESS ENTER TO PLAY
|
||||||
if (counter % 80 < 60)
|
if (counter % 80 < 60)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,15 +25,17 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
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
|
||||||
Resource *resource; // Objeto con los recursos
|
Resource *resource; // Objeto con los recursos
|
||||||
Asset *asset; // Objeto con los ficheros de recursos
|
Asset *asset; // Objeto con los ficheros de recursos
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
Texture *texture; // Textura con los graficos
|
Texture *texture; // Textura con los graficos
|
||||||
Sprite *sprite; // Sprite para manejar la textura
|
Sprite *sprite; // Sprite para manejar la textura
|
||||||
Text *text; // Objeto para escribir texto en pantalla
|
Text *text; // Objeto para escribir texto en pantalla
|
||||||
options_t *options; // Puntero a las opciones del juego
|
options_t *options; // Puntero a las opciones del juego
|
||||||
|
//Texture *pressEnterTexture; // Textura con los graficos de PRESS ENTER
|
||||||
|
//Sprite *pressEnterSprite; // Sprite para manejar la textura de PRESS ENTER
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int counter; // Contador
|
int counter; // Contador
|
||||||
|
|||||||
Reference in New Issue
Block a user