Añadida pantalla de game over funcional
This commit is contained in:
@@ -443,10 +443,15 @@ void Director::loadResources(section_t section)
|
|||||||
else if (section.name == SECTION_PROG_GAME_OVER)
|
else if (section.name == SECTION_PROG_GAME_OVER)
|
||||||
{
|
{
|
||||||
std::vector<std::string> textureList;
|
std::vector<std::string> textureList;
|
||||||
textureList.push_back("jailgames.png");
|
textureList.push_back("smb2.png");
|
||||||
textureList.push_back("since_1998.png");
|
|
||||||
|
|
||||||
resource->loadTextures(textureList);
|
resource->loadTextures(textureList);
|
||||||
|
|
||||||
|
// Offsets
|
||||||
|
std::vector<std::string> offsetsList;
|
||||||
|
offsetsList.push_back("smb2.txt");
|
||||||
|
|
||||||
|
resource->loadOffsets(offsetsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (section.name == SECTION_PROG_GAME || section.name == SECTION_PROG_DEMO)
|
else if (section.name == SECTION_PROG_GAME || section.name == SECTION_PROG_DEMO)
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
|
|||||||
// Inicializa el resto de variables
|
// Inicializa el resto de variables
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
board.lives = 9;
|
board.lives = 2;
|
||||||
board.items = 0;
|
board.items = 0;
|
||||||
board.rooms = 1;
|
board.rooms = 1;
|
||||||
board.music = true;
|
board.music = true;
|
||||||
@@ -372,7 +372,7 @@ void Game::checkGameOver()
|
|||||||
{
|
{
|
||||||
if (board.lives < 0)
|
if (board.lives < 0)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_TITLE;
|
section.name = SECTION_PROG_GAME_OVER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,7 +410,7 @@ void Game::killPlayer()
|
|||||||
this->player->pause();
|
this->player->pause();
|
||||||
|
|
||||||
// Deshabilita las entradas hasta que no haya ninguna activa
|
// Deshabilita las entradas hasta que no haya ninguna activa
|
||||||
input->disableUntil(d_keyPressed);
|
//input->disableUntil(d_keyPressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recarga todas las texturas
|
// Recarga todas las texturas
|
||||||
@@ -458,7 +458,7 @@ void Game::updateBlackScreen()
|
|||||||
if (blackScreen)
|
if (blackScreen)
|
||||||
{
|
{
|
||||||
blackScreenCounter++;
|
blackScreenCounter++;
|
||||||
if (blackScreenCounter > 10)
|
if (blackScreenCounter > 20)
|
||||||
{
|
{
|
||||||
blackScreen = false;
|
blackScreen = false;
|
||||||
blackScreenCounter = 0;
|
blackScreenCounter = 0;
|
||||||
@@ -498,10 +498,9 @@ void Game::setScoreBoardColor()
|
|||||||
// Comprueba si ha finalizado el juego
|
// Comprueba si ha finalizado el juego
|
||||||
bool Game::checkEndGame()
|
bool Game::checkEndGame()
|
||||||
{
|
{
|
||||||
|
const bool a = room->getName() == "THE JAIL"; // Estar en la habitación que toca
|
||||||
const bool a = room->getName() == "THE JAIL"; // Estar en la habitación que toca
|
const bool b = board.items >= int(totalItems * 0.9f); // Con mas del 90% de los items recogidos
|
||||||
const bool b = board.items >= totalItems * 0.9f; // Con mas del 90% de los items recogidos
|
const bool c = player->getRect().x <= 128; // Y en la ubicación que toca (En la puerta)
|
||||||
const bool c = player->getRect().x <= 128; // Estar en la ubicación que toca (En la puerta)
|
|
||||||
|
|
||||||
if (b)
|
if (b)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ GameOver::GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, A
|
|||||||
|
|
||||||
// Reserva memoria para los punteros a objetos
|
// Reserva memoria para los punteros a objetos
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
|
text = new Text(resource->getOffset("smb2.txt"), resource->getTexture("smb2.png"), renderer);
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
counter = 0;
|
counter = 0;
|
||||||
@@ -26,6 +27,7 @@ GameOver::~GameOver()
|
|||||||
{
|
{
|
||||||
// Libera la memoria de los objetos
|
// Libera la memoria de los objetos
|
||||||
delete eventHandler;
|
delete eventHandler;
|
||||||
|
delete text;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el objeto
|
// Actualiza el objeto
|
||||||
@@ -39,6 +41,13 @@ void GameOver::update()
|
|||||||
|
|
||||||
// Comprueba el manejador de eventos
|
// Comprueba el manejador de eventos
|
||||||
checkEventHandler();
|
checkEventHandler();
|
||||||
|
|
||||||
|
counter++;
|
||||||
|
|
||||||
|
if (counter == 400)
|
||||||
|
{
|
||||||
|
section.name = SECTION_PROG_TITLE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,6 +60,8 @@ void GameOver::render()
|
|||||||
// Limpia la pantalla
|
// Limpia la pantalla
|
||||||
screen->clean();
|
screen->clean();
|
||||||
|
|
||||||
|
text->writeCentered(GAMECANVAS_CENTER_X, GAMECANVAS_CENTER_Y, "G A M E O V E R");
|
||||||
|
|
||||||
// Vuelca el contenido del renderizador en pantalla
|
// Vuelca el contenido del renderizador en pantalla
|
||||||
screen->blit();
|
screen->blit();
|
||||||
}
|
}
|
||||||
@@ -65,6 +76,7 @@ void GameOver::checkEventHandler()
|
|||||||
if (eventHandler->type == SDL_QUIT)
|
if (eventHandler->type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_QUIT;
|
section.name = SECTION_PROG_QUIT;
|
||||||
|
section.subsection = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,8 +124,8 @@ void GameOver::checkEventHandler()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// section.name = SECTION_PROG_TITLE;
|
//section.name = SECTION_PROG_TITLE;
|
||||||
// section.subsection = 0;
|
//section.subsection = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,9 +26,6 @@ private:
|
|||||||
options_t *options; // Puntero a las opciones del juego
|
options_t *options; // Puntero a las opciones del juego
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
Text *text; // Objeto para escribir texto en pantalla
|
Text *text; // Objeto para escribir texto en pantalla
|
||||||
SDL_Texture *textTexture; // Textura para dibujar el texto
|
|
||||||
SDL_Texture *coverTexture; // Textura para cubrir el texto
|
|
||||||
AnimatedSprite *sprite; // Sprite para el brillo del corazón
|
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int counter; // Contador
|
int counter; // Contador
|
||||||
|
|||||||
Reference in New Issue
Block a user