forked from jaildesigner-jailgames/jaildoctors_dilemma
Terminada la marquesina del titulo
This commit is contained in:
@@ -21,6 +21,16 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Asset *asset)
|
||||
section.subsection = 0;
|
||||
ticks = 0;
|
||||
ticksSpeed = 15;
|
||||
longText = "HEY HAVE YOU HEARD IT? JAILGAMES ARE BACK!! MORE THAN 10 TITLES ON JAILDOC'S KITCHEN! THATS A LOOOOOOT OF JAILGAMES, BUT WHICH ONE WILL STRIKE FIRST? OH BABY, WE DON'T KNOW. THERE IS ALSO A NEW DEVICE TO COME P.A.C.O. WILL BLOW YOUR MIND WITH JAILGAMES ON THE GO. BUT WAIT! WHAT'S THAT BEAUTY I'M SEEING RIGHT OVER THERE?? MINIASCII IS PURE LOVE!! OH! AND DON'T FORGET TO BRING BACK THOSE OLD AND FAT MS-DOS JAILGAMES";
|
||||
for (int i = 0; i < longText.length(); i++)
|
||||
{
|
||||
letter_t l;
|
||||
l.letter = longText.substr(i, 1);
|
||||
l.x = 256;
|
||||
l.enabled = false;
|
||||
letters.push_back(l);
|
||||
}
|
||||
letters[0].enabled = true;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
@@ -67,6 +77,42 @@ void Title::checkEventHandler()
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza la marquesina
|
||||
void Title::updateMarquee()
|
||||
{
|
||||
for (int i = 0; i < letters.size(); i++)
|
||||
{
|
||||
if (letters[i].enabled)
|
||||
{
|
||||
letters[i].x -= 2;
|
||||
if (letters[i].x < -10)
|
||||
{
|
||||
letters[i].enabled = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i > 0 && letters[i - 1].x < 250)
|
||||
{
|
||||
letters[i].enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Dibuja la marquesina
|
||||
void Title::renderMarquee()
|
||||
{
|
||||
for (auto l : letters)
|
||||
{
|
||||
if (l.enabled)
|
||||
{
|
||||
// text->writeColored(l.x, 176, l.letter, {0, 0, 0});
|
||||
text->write(l.x, 176, l.letter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza las variables
|
||||
void Title::update()
|
||||
{
|
||||
@@ -82,8 +128,14 @@ void Title::update()
|
||||
// Incrementa el contador
|
||||
counter++;
|
||||
|
||||
// Actualiza la marquesina
|
||||
updateMarquee();
|
||||
|
||||
// Comprueba si ha pasado mucho tiempo y acaba el titulo
|
||||
if (counter == 1000)
|
||||
// if (counter == 1000)
|
||||
|
||||
// Comprueba si ha terminado la marquesina y acaba con el titulo
|
||||
if (letters[letters.size() - 1].x < -10)
|
||||
{
|
||||
section.name = SECTION_PROG_LOGO;
|
||||
section.subsection = 0;
|
||||
@@ -100,15 +152,18 @@ void Title::render()
|
||||
// Limpia la pantalla
|
||||
screen->clean();
|
||||
|
||||
// Dibuja los objetos
|
||||
// Dibuja el fondo del titulo
|
||||
sprite->render();
|
||||
|
||||
// Dibuja el texto de PRESS ENTER TO PLAY
|
||||
SDL_SetRenderDrawColor(renderer, 0, 0, 255, 255);
|
||||
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");
|
||||
|
||||
//text->write(0, 0, std::to_string(counter));
|
||||
// Dibuja la marquesina
|
||||
renderMarquee();
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
screen->blit();
|
||||
|
||||
Reference in New Issue
Block a user