Añadidas las escenas del final
This commit is contained in:
@@ -181,15 +181,16 @@ void Text::writeDX(Uint8 flags, int x, int y, std::string text, int kerning, col
|
||||
|
||||
if (stroked)
|
||||
{
|
||||
writeColored(x + shadowDistance, y + shadowDistance, text, shadowColor, kerning, lenght);
|
||||
writeColored(x - shadowDistance, y + shadowDistance, text, shadowColor, kerning, lenght);
|
||||
writeColored(x + shadowDistance, y - shadowDistance, text, shadowColor, kerning, lenght);
|
||||
writeColored(x - shadowDistance, y - shadowDistance, text, shadowColor, kerning, lenght);
|
||||
|
||||
writeColored(x, y + shadowDistance, text, shadowColor, kerning, lenght);
|
||||
writeColored(x, y - shadowDistance, text, shadowColor, kerning, lenght);
|
||||
writeColored(x + shadowDistance, y, text, shadowColor, kerning, lenght);
|
||||
writeColored(x - shadowDistance, y, text, shadowColor, kerning, lenght);
|
||||
for (int dist = 1; dist <= shadowDistance; ++dist)
|
||||
{
|
||||
for (int dy = -dist; dy <= dist; ++dy)
|
||||
{
|
||||
for (int dx = -dist; dx <= dist; ++dx)
|
||||
{
|
||||
writeColored(x + dx, y + dy, text, shadowColor, kerning, lenght);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (colored)
|
||||
|
||||
@@ -1277,6 +1277,14 @@ void Director::run()
|
||||
case SECTION_PROG_GAME:
|
||||
runGame();
|
||||
break;
|
||||
|
||||
case SECTION_PROG_GAME_OVER:
|
||||
runGameOver();
|
||||
break;
|
||||
|
||||
case SECTION_PROG_ENDING:
|
||||
runEnding();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ Ending::Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset
|
||||
section.subsection = 0;
|
||||
ticks = 0;
|
||||
ticksSpeed = 15;
|
||||
scene = 1;
|
||||
scene = 0;
|
||||
sceneLenght.insert(sceneLenght.end(), {0, 100, 100, 100});
|
||||
|
||||
// Inicializa los textos
|
||||
@@ -52,6 +52,9 @@ Ending::Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset
|
||||
}
|
||||
}
|
||||
SDL_SetTextureBlendMode(coverTexture, SDL_BLENDMODE_BLEND);
|
||||
|
||||
// Rellena la textura segun la escena
|
||||
fillTexture();
|
||||
}
|
||||
|
||||
// Destructor
|
||||
@@ -114,7 +117,7 @@ void Ending::checkEventHandler()
|
||||
switch (eventHandler->key.keysym.scancode)
|
||||
{
|
||||
case SDL_SCANCODE_ESCAPE:
|
||||
section.name = SECTION_PROG_QUIT;
|
||||
// section.name = SECTION_PROG_QUIT;
|
||||
break;
|
||||
|
||||
case SDL_SCANCODE_B:
|
||||
@@ -151,6 +154,16 @@ void Ending::checkEventHandler()
|
||||
// switchPalette();
|
||||
break;
|
||||
|
||||
case SDL_SCANCODE_RIGHT:
|
||||
++scene %= 5;
|
||||
fillTexture();
|
||||
break;
|
||||
|
||||
case SDL_SCANCODE_LEFT:
|
||||
--scene %= 5;
|
||||
fillTexture();
|
||||
break;
|
||||
|
||||
default:
|
||||
// section.name = SECTION_PROG_TITLE;
|
||||
// section.subsection = 0;
|
||||
@@ -166,29 +179,33 @@ void Ending::iniTexts()
|
||||
// Reinicia el vector
|
||||
texts.clear();
|
||||
|
||||
// Escena #1
|
||||
texts.push_back("HE FINALLY MANAGED TO GET");
|
||||
texts.push_back("TO THE JAIL WITH ALL HIS");
|
||||
texts.push_back("PROJECTS READY TO BE RELEASED");
|
||||
// Escena #0
|
||||
texts.push_back("HE FINALLY MANAGED");
|
||||
texts.push_back("TO GET TO THE JAIL");
|
||||
texts.push_back("WITH ALL HIS PROJECTS");
|
||||
texts.push_back("READY TO BE RELEASED");
|
||||
|
||||
// Escena #2
|
||||
// Escena #1
|
||||
texts.push_back("ALL THE JAILERS WERE THERE");
|
||||
texts.push_back("WAITING FOR THE JAILGAMES");
|
||||
texts.push_back("TO BE RELEASED");
|
||||
|
||||
// Escena #3
|
||||
texts.push_back("THERE WERE EVEN BARRULLS AND");
|
||||
texts.push_back("BEGINNERS AMONG THE CROWD");
|
||||
|
||||
texts.push_back("BRY WAS CRYING...");
|
||||
|
||||
// Escena #4
|
||||
// Escena #2
|
||||
texts.push_back("BUT SUDDENLY SOMETHING");
|
||||
texts.push_back("CAUGHT HIS ATTENTION");
|
||||
|
||||
// Escena #5
|
||||
// Escena #3
|
||||
texts.push_back("A PILE OF JUNK!");
|
||||
texts.push_back("FULL OF NON WORKING THINGS!!");
|
||||
texts.push_back("AND THEN, FOURTY NEW PROJECTS");
|
||||
|
||||
// Escena #4
|
||||
texts.push_back("AND THEN,");
|
||||
texts.push_back("FOURTY NEW PROJECTS");
|
||||
texts.push_back("WERE BORN...");
|
||||
}
|
||||
|
||||
@@ -204,19 +221,103 @@ void Ending::fillTexture()
|
||||
SDL_SetRenderDrawColor(renderer, c.r, c.g, c.b, 0x00);
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
// Escribe el texto en la textura
|
||||
const int size = text->getCharacterSize();
|
||||
int y = 20;
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
text->writeDX(TXT_CENTER | TXT_STROKE, PLAY_AREA_CENTER_X, y, texts.at(i), 1, c);
|
||||
y += size;
|
||||
if (scene == 0)
|
||||
{ // Compone la escena #0
|
||||
|
||||
// Dibuja el sprite
|
||||
texture = resource->getTexture("ending1.png");
|
||||
sprite->setTexture(texture);
|
||||
sprite->setSpriteClip({0, 0, texture->getWidth(), texture->getHeight()});
|
||||
const int x = (PLAY_AREA_WIDTH - texture->getWidth()) / 2;
|
||||
sprite->setRect({x, 48, texture->getWidth(), texture->getHeight()});
|
||||
sprite->render();
|
||||
|
||||
// Dos lineas de texto
|
||||
text->writeDX(TXT_CENTER | TXT_STROKE, PLAY_AREA_CENTER_X, 34, texts.at(0), 1, c, 2, c);
|
||||
text->writeDX(TXT_CENTER | TXT_STROKE, PLAY_AREA_CENTER_X, 45, texts.at(1), 1, c, 2, c);
|
||||
|
||||
// Dos lineas más de texto
|
||||
text->writeDX(TXT_CENTER | TXT_STROKE, PLAY_AREA_CENTER_X, 143, texts.at(2), 1, c, 2, c);
|
||||
text->writeDX(TXT_CENTER | TXT_STROKE, PLAY_AREA_CENTER_X, 154, texts.at(3), 1, c, 2, c);
|
||||
}
|
||||
|
||||
// Dibuja el sprite
|
||||
const int x = (PLAY_AREA_WIDTH - texture->getWidth()) / 2;
|
||||
sprite->setPos({x, y + 10});
|
||||
if (scene == 1)
|
||||
{ // Compone la escena #1
|
||||
|
||||
// Dibuja el sprite
|
||||
texture = resource->getTexture("ending2.png");
|
||||
sprite->setTexture(texture);
|
||||
sprite->setSpriteClip({0, 0, texture->getWidth(), texture->getHeight()});
|
||||
const int x = (GAMECANVAS_WIDTH - texture->getWidth()) / 2;
|
||||
const int y = (GAMECANVAS_HEIGHT - texture->getHeight()) / 2;
|
||||
sprite->setRect({x, y, texture->getWidth(), texture->getHeight()});
|
||||
sprite->render();
|
||||
|
||||
// Tres lineas de texto
|
||||
text->writeDX(TXT_CENTER | TXT_STROKE, PLAY_AREA_CENTER_X, 3, texts.at(4), 1, c, 2, c);
|
||||
text->writeDX(TXT_CENTER | TXT_STROKE, PLAY_AREA_CENTER_X, 13, texts.at(5), 1, c, 2, c);
|
||||
text->writeDX(TXT_CENTER | TXT_STROKE, PLAY_AREA_CENTER_X, 23, texts.at(6), 1, c, 2, c);
|
||||
|
||||
// Dos lineas más de texto
|
||||
text->writeDX(TXT_CENTER | TXT_STROKE, PLAY_AREA_CENTER_X, 163, texts.at(7), 1, c, 2, c);
|
||||
text->writeDX(TXT_CENTER | TXT_STROKE, PLAY_AREA_CENTER_X, 173, texts.at(8), 1, c, 2, c);
|
||||
|
||||
// Una linea mas
|
||||
text->writeDX(TXT_CENTER | TXT_STROKE, PLAY_AREA_CENTER_X, 183, texts.at(9), 1, c, 2, c);
|
||||
}
|
||||
|
||||
if (scene == 2)
|
||||
{ // Compone la escena #2
|
||||
|
||||
// Dibuja el sprite
|
||||
texture = resource->getTexture("ending3.png");
|
||||
sprite->setTexture(texture);
|
||||
sprite->setSpriteClip({0, 0, texture->getWidth(), texture->getHeight()});
|
||||
const int x = (GAMECANVAS_WIDTH - texture->getWidth()) / 2;
|
||||
sprite->setRect({x, 29, texture->getWidth(), texture->getHeight()});
|
||||
sprite->render();
|
||||
|
||||
// Dos lineas de texto
|
||||
text->writeDX(TXT_CENTER | TXT_STROKE, PLAY_AREA_CENTER_X, 21, texts.at(10), 1, c, 2, c);
|
||||
text->writeDX(TXT_CENTER | TXT_STROKE, PLAY_AREA_CENTER_X, 33, texts.at(11), 1, c, 2, c);
|
||||
}
|
||||
|
||||
if (scene == 3)
|
||||
{ // Compone la escena #3
|
||||
|
||||
// Dibuja el sprite
|
||||
texture = resource->getTexture("ending4.png");
|
||||
sprite->setTexture(texture);
|
||||
sprite->setSpriteClip({0, 0, texture->getWidth(), texture->getHeight()});
|
||||
const int x = (GAMECANVAS_WIDTH - texture->getWidth()) / 2;
|
||||
sprite->setRect({x, 63, texture->getWidth(), texture->getHeight()});
|
||||
sprite->render();
|
||||
|
||||
// Dos lineas de texto
|
||||
text->writeDX(TXT_CENTER | TXT_STROKE, PLAY_AREA_CENTER_X, 38, texts.at(12), 1, c, 2, c);
|
||||
text->writeDX(TXT_CENTER | TXT_STROKE, PLAY_AREA_CENTER_X, 51, texts.at(13), 1, c, 2, c);
|
||||
}
|
||||
|
||||
if (scene == 4)
|
||||
{ // Compone la escena #4
|
||||
|
||||
// Dibuja el sprite
|
||||
texture = resource->getTexture("ending5.png");
|
||||
sprite->setTexture(texture);
|
||||
sprite->setSpriteClip({0, 0, texture->getWidth(), texture->getHeight()});
|
||||
const int x = (GAMECANVAS_WIDTH - texture->getWidth()) / 2;
|
||||
sprite->setRect({x, 53, texture->getWidth(), texture->getHeight()});
|
||||
sprite->render();
|
||||
|
||||
// Dos lineas de texto
|
||||
text->writeDX(TXT_CENTER | TXT_STROKE, PLAY_AREA_CENTER_X, 28, texts.at(14), 1, c, 2, c);
|
||||
text->writeDX(TXT_CENTER | TXT_STROKE, PLAY_AREA_CENTER_X, 38, texts.at(15), 1, c, 2, c);
|
||||
|
||||
// Una linea mas
|
||||
text->writeDX(TXT_CENTER | TXT_STROKE, PLAY_AREA_CENTER_X, 160, texts.at(16), 1, c, 2, c);
|
||||
}
|
||||
|
||||
SDL_SetRenderTarget(renderer, nullptr);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user