forked from jaildesigner-jailgames/jaildoctors_dilemma
Añadido el cambio de borde, tamaño de ventana y paleta a todas las secciones del juego
This commit is contained in:
@@ -29,35 +29,6 @@ Credits::Credits(SDL_Renderer *renderer, Screen *screen, Resource *resource, Ass
|
||||
// Cambia el color del borde
|
||||
screen->setBorderColor(stringToColor(options->palette, "black"));
|
||||
|
||||
// Inicializa los textos
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"INSTRUCTIONS:", stringToColor(options->palette, "yellow")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"HELP JAILDOC TO GET BACK ALL HIS", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"PROJECTS AND GO TO THE JAIL TO", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"FINISH THEM", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
|
||||
texts.push_back({"KEYS:", stringToColor(options->palette, "yellow")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"USE 'CURSORS' TO MOVE AND JUMP", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"'F1-F4' TO CHANGE WINDOWS SIZE", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"'F' TO SWITCH TO FULLSCREEN", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"'B' TO SWITCH THE BORDER SCREEN", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"'M' TO TURN ON/OFF THE MUSIC", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"'ESC' TO LEAVE THE GAME", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
|
||||
texts.push_back({"A GAME BY JAILDESIGNER", stringToColor(options->palette, "yellow")});
|
||||
texts.push_back({"MADE ON SUMMER/FALL 2022", stringToColor(options->palette, "yellow")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
|
||||
texts.push_back({"I LOVE JAILGAMES! ", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
|
||||
// Crea la textura para el texto que se escribe en pantalla
|
||||
textTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
|
||||
if (textTexture == nullptr)
|
||||
@@ -101,8 +72,8 @@ void Credits::checkEventHandler()
|
||||
break;
|
||||
}
|
||||
|
||||
// Comprueba si se ha pulsado alguna tecla
|
||||
else if ((eventHandler->type == SDL_KEYDOWN) and (eventHandler->key.repeat == 0))
|
||||
// Comprueba las teclas que se han pulsado
|
||||
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN))
|
||||
{
|
||||
switch (eventHandler->key.keysym.scancode)
|
||||
{
|
||||
@@ -110,6 +81,40 @@ void Credits::checkEventHandler()
|
||||
section.name = SECTION_PROG_QUIT;
|
||||
break;
|
||||
|
||||
case SDL_SCANCODE_B:
|
||||
screen->switchBorder();
|
||||
resource->reLoadTextures();
|
||||
break;
|
||||
|
||||
case SDL_SCANCODE_F:
|
||||
screen->switchVideoMode();
|
||||
resource->reLoadTextures();
|
||||
break;
|
||||
|
||||
case SDL_SCANCODE_F1:
|
||||
screen->setWindowSize(1);
|
||||
resource->reLoadTextures();
|
||||
break;
|
||||
|
||||
case SDL_SCANCODE_F2:
|
||||
screen->setWindowSize(2);
|
||||
resource->reLoadTextures();
|
||||
break;
|
||||
|
||||
case SDL_SCANCODE_F3:
|
||||
screen->setWindowSize(3);
|
||||
resource->reLoadTextures();
|
||||
break;
|
||||
|
||||
case SDL_SCANCODE_F4:
|
||||
screen->setWindowSize(4);
|
||||
resource->reLoadTextures();
|
||||
break;
|
||||
|
||||
case SDL_SCANCODE_F5:
|
||||
switchPalette();
|
||||
break;
|
||||
|
||||
default:
|
||||
section.name = SECTION_PROG_TITLE;
|
||||
section.subsection = 0;
|
||||
@@ -122,6 +127,36 @@ void Credits::checkEventHandler()
|
||||
// Escribe el texto en la textura
|
||||
void Credits::fillTexture()
|
||||
{
|
||||
// Inicializa los textos
|
||||
texts.clear();
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"INSTRUCTIONS:", stringToColor(options->palette, "yellow")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"HELP JAILDOC TO GET BACK ALL HIS", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"PROJECTS AND GO TO THE JAIL TO", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"FINISH THEM", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
|
||||
texts.push_back({"KEYS:", stringToColor(options->palette, "yellow")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"USE 'CURSORS' TO MOVE AND JUMP", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"'F1-F4' TO CHANGE WINDOWS SIZE", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"'F' TO SWITCH TO FULLSCREEN", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"'B' TO SWITCH THE BORDER SCREEN", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"'M' TO TURN ON/OFF THE MUSIC", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"'ESC' TO LEAVE THE GAME", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
|
||||
texts.push_back({"A GAME BY JAILDESIGNER", stringToColor(options->palette, "yellow")});
|
||||
texts.push_back({"MADE ON SUMMER/FALL 2022", stringToColor(options->palette, "yellow")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
|
||||
texts.push_back({"I LOVE JAILGAMES! ", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
|
||||
// Rellena la textura de texto
|
||||
SDL_SetRenderTarget(renderer, textTexture);
|
||||
const color_t c = stringToColor(options->palette, "black");
|
||||
@@ -266,4 +301,19 @@ section_t Credits::run()
|
||||
}
|
||||
|
||||
return section;
|
||||
}
|
||||
|
||||
// Cambia la paleta
|
||||
void Credits::switchPalette()
|
||||
{
|
||||
if (options->palette == p_zxspectrum)
|
||||
{
|
||||
options->palette = p_zxarne;
|
||||
}
|
||||
else
|
||||
{
|
||||
options->palette = p_zxspectrum;
|
||||
}
|
||||
|
||||
fillTexture();
|
||||
}
|
||||
Reference in New Issue
Block a user