Cambio de color en el texto del marcador

This commit is contained in:
2022-09-13 09:49:40 +02:00
parent b8fe11fb63
commit 464d8194d4
6 changed files with 28 additions and 16 deletions

View File

@@ -8,7 +8,6 @@ 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;
@@ -16,9 +15,9 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, D
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++;
}

View File

@@ -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()
{

View File

@@ -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();

View File

@@ -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

View File

@@ -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;
};

View File

@@ -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