Implementado el cambio de paleta durante el juego

This commit is contained in:
2022-10-25 21:51:30 +02:00
parent bcb56e17f2
commit dc84ed79d6
31 changed files with 297 additions and 164 deletions

View File

@@ -1,16 +1,24 @@
#include "title.h"
// Constructor
Title::Title(SDL_Renderer *renderer, Screen *screen, Asset *asset)
Title::Title(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options)
{
// Copia la dirección de los objetos
this->renderer = renderer;
this->screen = screen;
this->asset = asset;
this->options = options;
// Reserva memoria para los punteros
eventHandler = new SDL_Event();
texture = new Texture(renderer, asset->get("loading_screen_color.png"));
if (options->palette == p_zxspectrum)
{
texture = new Texture(renderer, asset->get("loading_screen_color.png"));
}
else if (options->palette == p_zxarne)
{
texture = new Texture(renderer, asset->get("loading_screen_color_zxarne.png"));
}
sprite = new Sprite(0, 0, texture->getWidth(), texture->getHeight(), texture, renderer);
text = new Text(asset->get("smb2.png"), asset->get("smb2.txt"), renderer);
@@ -21,7 +29,7 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Asset *asset)
ticks = 0;
ticksSpeed = 15;
longText = "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 P.A.C.O. THAT WILL BLOW YOUR MIND WITH JAILGAMES ON THE GO. 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?";
//longText = "HEY JAILERS!! IT'S 2022 AND WE'RE STILL ROCKING LIKE IT'S 1998!!!";
// longText = "HEY JAILERS!! IT'S 2022 AND WE'RE STILL ROCKING LIKE IT'S 1998!!!";
for (int i = 0; i < (int)longText.length(); ++i)
{
letter_t l;
@@ -33,7 +41,7 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Asset *asset)
letters[0].enabled = true;
// Cambia el color del borde
screen->setBorderColor(stringToColor("bright_blue"));
screen->setBorderColor(stringToColor(options->palette, "bright_blue"));
}
// Destructor
@@ -134,8 +142,7 @@ void Title::renderMarquee()
{
if (l.enabled)
{
// text->writeColored(l.x, 176, l.letter, {0, 0, 0});
text->write(l.x, 184, l.letter);
text->writeColored(l.x, 184, l.letter, stringToColor(options->palette, "white"));
}
}
}
@@ -188,11 +195,12 @@ void Title::render()
// text->writeCentered(256 / 2, 192 / 5 * 4, "PRESS ENTER TO PLAY");
//}
// Dibuja el texto de PRESS ENTER TO PLAY
if (counter % 80 < 60)
{
const color_t textColor = stringToColor("white");
const color_t strokeColor = stringToColor("bright_blue");
text->writeDX(TXT_CENTER | TXT_COLOR| TXT_STROKE, 256 / 2, 192 / 5 * 4, "PRESS ENTER TO PLAY", 1, textColor, 1, strokeColor);
const color_t textColor = stringToColor(options->palette, "white");
const color_t strokeColor = stringToColor(options->palette, "bright_blue");
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_STROKE, 256 / 2, 192 / 5 * 4, "PRESS ENTER TO PLAY", 1, textColor, 1, strokeColor);
}
// Dibuja la marquesina