From 7af0dda1a0c78664a5d1a686a4207e627a145e22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Valor=20Mart=C3=ADnez?= Date: Thu, 17 Nov 2022 16:33:37 +0100 Subject: [PATCH] En la pantalla de Game Over se muestran las habitaciones y los items conseguidos --- .../Contents/Info.plist | 20 +++++++++++++++++++ source/common/utils.h | 2 ++ source/director.cpp | 2 ++ source/game.cpp | 1 + source/game_over.cpp | 15 +++++++++----- source/room.cpp | 1 + 6 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 jaildoctors_dilemma_debug.dSYM/Contents/Info.plist diff --git a/jaildoctors_dilemma_debug.dSYM/Contents/Info.plist b/jaildoctors_dilemma_debug.dSYM/Contents/Info.plist new file mode 100644 index 0000000..a15c338 --- /dev/null +++ b/jaildoctors_dilemma_debug.dSYM/Contents/Info.plist @@ -0,0 +1,20 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleIdentifier + com.apple.xcode.dsym.jaildoctors_dilemma_debug + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + dSYM + CFBundleSignature + ???? + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/source/common/utils.h b/source/common/utils.h index 436acfd..be3c927 100644 --- a/source/common/utils.h +++ b/source/common/utils.h @@ -86,6 +86,8 @@ struct options_t palette_e palette; // Paleta de colores a usar en el juego bool console; // Indica si ha de mostrar información por la consola de texto cheat_t cheat; // Contiene trucos y ventajas para el juego + int rooms; // Cantidad de habitaciones visitadas + int items; // Cantidad de items obtenidos }; // Calcula el cuadrado de la distancia entre dos puntos diff --git a/source/director.cpp b/source/director.cpp index 2c98f55..09886a7 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -91,6 +91,8 @@ void Director::iniOptions() options->cheat.invincible = false; options->cheat.jailEnabled = false; options->cheat.altSkin = false; + options->rooms = 0; + options->items = 0; } // Comprueba los parametros del programa diff --git a/source/game.cpp b/source/game.cpp index 06e2a8d..cbd9494 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -340,6 +340,7 @@ bool Game::changeRoom(std::string file) { // Incrementa el contador de habitaciones visitadas board.rooms++; + options->rooms = board.rooms; // Actualiza las estadisticas stats->addVisit(room->getName()); diff --git a/source/game_over.cpp b/source/game_over.cpp index 36d2ee8..ebd9afd 100644 --- a/source/game_over.cpp +++ b/source/game_over.cpp @@ -28,9 +28,9 @@ GameOver::GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, A iniFade = 310; fadeLenght = 20; playerSprite->setPosX(GAMECANVAS_CENTER_X + 10); - playerSprite->setPosY(GAMECANVAS_CENTER_Y + 10); + playerSprite->setPosY(GAMECANVAS_CENTER_Y - 10); tvSprite->setPosX(GAMECANVAS_CENTER_X - tvSprite->getAnimationClip(0, 0).w - 10); - tvSprite->setPosY(GAMECANVAS_CENTER_Y + 10); + tvSprite->setPosY(GAMECANVAS_CENTER_Y - 10); // Inicializa el vector de colores const std::vector colorList = {"white", "yellow", "cyan", "green", "magenta", "red", "blue", "black"}; @@ -86,12 +86,17 @@ void GameOver::render() screen->clean(); // Escribe el texto de GAME OVER - text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, GAMECANVAS_CENTER_Y - 20, "G A M E O V E R", 1, color); + text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, GAMECANVAS_CENTER_Y - 40, "G A M E O V E R", 1, color); // Dibuja los sprites renderSprites(); - // text->write(0, 0, std::to_string(counter)); + // Escribe el texto con las habitaciones y los items + const std::string itemsTxt = std::to_string(options->items / 100) + std::to_string((options->items % 100) / 10) + std::to_string(options->items % 10); + const std::string roomsTxt = std::to_string(options->rooms / 100) + std::to_string((options->rooms % 100) / 10) + std::to_string(options->rooms % 10); + text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, GAMECANVAS_CENTER_Y + 40, "ITEMS: " + itemsTxt, 1, color); + text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, GAMECANVAS_CENTER_Y + 55, "ROOMS: " + roomsTxt, 1, color); + // Vuelca el contenido del renderizador en pantalla screen->blit(); @@ -180,7 +185,7 @@ void GameOver::updateColor() if (counter < half) { - //const float step = std::min(std::max(counter, iniFade) - iniFade, fadeLenght) / (float)fadeLenght; + // const float step = std::min(std::max(counter, iniFade) - iniFade, fadeLenght) / (float)fadeLenght; const float step = std::min(counter, fadeLenght) / (float)fadeLenght; const int index = (colors.size() - 1) - int((colors.size() - 1) * step); color = colors.at(index); diff --git a/source/room.cpp b/source/room.cpp index 2bdb4e9..99ecb49 100644 --- a/source/room.cpp +++ b/source/room.cpp @@ -824,6 +824,7 @@ bool Room::itemCollision(SDL_Rect &rect) items.erase(items.begin() + i); JA_PlaySound(itemSound); *itemsPicked = *itemsPicked + 1; + options->items = *itemsPicked; return true; } }