From 464d8194d4936dc9f6eb59a209f0acbe0d17e856 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Tue, 13 Sep 2022 09:49:40 +0200 Subject: [PATCH] Cambio de color en el texto del marcador --- source/game.cpp | 14 ++++++++------ source/room.cpp | 6 ++++++ source/room.h | 3 +++ source/scoreboard.cpp | 14 +++++++------- source/scoreboard.h | 1 + todo.txt | 6 +++--- 6 files changed, 28 insertions(+), 16 deletions(-) diff --git a/source/game.cpp b/source/game.cpp index 3866f1e..f301458 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -8,17 +8,16 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, D currentRoom = "01.room"; spawnPoint = {16, 96, 0, 0, 0, s_standing, SDL_FLIP_NONE}; - // Copia los punteros this->renderer = renderer; this->asset = asset; this->screen = screen; this->input = input; this->debug = debug; - - //this->debug->setEnabled(true); - //currentRoom = "06.room"; - //spawnPoint = {240, 96, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL}; + + // this->debug->setEnabled(true); + // currentRoom = "06.room"; + // spawnPoint = {240, 96, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL}; // Crea los objetos scoreboard = new ScoreBoard(renderer, asset, &board); @@ -38,6 +37,7 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, D board.lives = 9; board.items = 0; board.rooms = 1; + board.color = room->getBorderColor(); roomTracker->addRoom(currentRoom); player->setInvincible(debug->getEnabled()); @@ -276,8 +276,10 @@ bool Game::changeRoom(std::string file) room = new Room(asset->get(file), renderer, screen, asset, itemTracker, &board.items, debug); // Actualiza el marcador + const color_t c = room->getBorderColor(); // Pon el color del marcador + board.color = (c.r + c.g + c.b == 0) ? stringToColor("white") : c; // Si el color es negrom cambialo a blanco if (roomTracker->addRoom(file)) - { + { // Incrementa el contador de habitaciones visitadas board.rooms++; } diff --git a/source/room.cpp b/source/room.cpp index 7a77d2a..bb93c4a 100644 --- a/source/room.cpp +++ b/source/room.cpp @@ -420,6 +420,12 @@ color_t Room::getBGColor() return bgColor; } +// Devuelve el color del borde +color_t Room::getBorderColor() +{ + return borderColor; +} + // Crea la textura con el mapeado de la habitación void Room::fillMapTexture() { diff --git a/source/room.h b/source/room.h index ba0c6d5..9df02cb 100644 --- a/source/room.h +++ b/source/room.h @@ -125,6 +125,9 @@ public: // Devuelve el color de la habitación color_t getBGColor(); + // Devuelve el color del borde + color_t getBorderColor(); + // Dibuja el mapa en pantalla void renderMap(); diff --git a/source/scoreboard.cpp b/source/scoreboard.cpp index 12cc56e..6a87d24 100644 --- a/source/scoreboard.cpp +++ b/source/scoreboard.cpp @@ -104,7 +104,7 @@ void ScoreBoard::render() // Muestra si suena la música if (board->music) { - const color_t c = stringToColor("bright_blue"); + const color_t c = board->color; SDL_Rect clip = {0, 8, 8, 8}; itemTexture->setColor(c.r, c.g, c.b); itemTexture->render(renderer, 20 * BLOCK, line2, &clip); @@ -113,14 +113,14 @@ void ScoreBoard::render() // Escribe los textos const std::string timeTxt = std::to_string((clock.minutes % 60) / 10) + std::to_string(clock.minutes % 10) + clock.separator + std::to_string((clock.seconds % 60) / 10) + std::to_string(clock.seconds % 10); const std::string itemsTxt = std::to_string(board->items / 100) + std::to_string((board->items % 100) / 10) + std::to_string(board->items % 10); - this->text->writeColored(BLOCK, line1, "Items collected ", stringToColor("yellow")); - this->text->writeColored(17 * BLOCK, line1, itemsTxt, stringToColor("bright_blue")); - this->text->writeColored(20 * BLOCK, line1, " Time ", stringToColor("yellow")); - this->text->writeColored(26 * BLOCK, line1, timeTxt, stringToColor("bright_blue")); + this->text->writeColored(BLOCK, line1, "Items collected ", board->color); + this->text->writeColored(17 * BLOCK, line1, itemsTxt, stringToColor("white")); + this->text->writeColored(20 * BLOCK, line1, " Time ", board->color); + this->text->writeColored(26 * BLOCK, line1, timeTxt, stringToColor("white")); const std::string roomsTxt = std::to_string(board->rooms / 100) + std::to_string((board->rooms % 100) / 10) + std::to_string(board->rooms % 10); - this->text->writeColored(22 * BLOCK, line2, "Rooms", stringToColor("yellow")); - this->text->writeColored(28 * BLOCK, line2, roomsTxt, stringToColor("bright_blue")); + this->text->writeColored(22 * BLOCK, line2, "Rooms", stringToColor("white")); + this->text->writeColored(28 * BLOCK, line2, roomsTxt, stringToColor("white")); } // Actualiza las variables del objeto diff --git a/source/scoreboard.h b/source/scoreboard.h index c0247cb..bf44333 100644 --- a/source/scoreboard.h +++ b/source/scoreboard.h @@ -17,6 +17,7 @@ struct board_t int lives; // Lleva la cuenta de ls vidas restantes del jugador int rooms; // Lleva la cuenta de las habitaciones visitadas bool music; // Indica si ha de sonar la musica durante el juego + color_t color; // Color para escribir el texto del marcador Uint32 iniClock; }; diff --git a/todo.txt b/todo.txt index 1654854..3710296 100644 --- a/todo.txt +++ b/todo.txt @@ -11,14 +11,14 @@ x (A) Modificar el salto para que coincida con el del JSW, no ha de colisionar l (A) Crear tiles que arrastren, tipo cinta transportadora (A) Tiles animados -(A) Crear ascensores +x (A) Crear ascensores (NO SE VA A HACER POR DISEÑO) x (A) Crear rampas x (A) Enemigos de diferente tamaño {cm:2022-08-30} (A) Color de los items al estilo jet set willy de amstrad, que brillan con dos colores x (A) Temporizador de inicio de los items, para poder hacer que brillen a distinto ritmo. Esto es incompatible con lo anterior {cm:2022-08-30} (A) Crear efecto de fade estilo spectrum, cambiando el color de las cosas a rojo, morado, azul, negro (A) Hacer que los enemigos tengan flip -(A) Cabiar los colores del texto del marcador segun la habitación +x (A) Cabiar los colores del texto del marcador segun la habitación x (A) Poner la info de debug con la tipografia adecuada {cm:2022-08-30} x (A) El modo debug debe pintar la rejilla {cm:2022-08-30} @@ -52,7 +52,7 @@ leaper reaper mini ascii mappy paco -chirping +x chirping abad y batman jail counter strike