Implementado el cambio de paleta durante el juego
This commit is contained in:
@@ -3,12 +3,13 @@
|
||||
#include <sstream>
|
||||
|
||||
// Constructor
|
||||
ScoreBoard::ScoreBoard(SDL_Renderer *renderer, Asset *asset, board_t *board)
|
||||
ScoreBoard::ScoreBoard(SDL_Renderer *renderer, Asset *asset, options_t *options, board_t *board)
|
||||
{
|
||||
// Obten punteros a objetos
|
||||
this->asset = asset;
|
||||
this->renderer = renderer;
|
||||
this->board = board;
|
||||
this->options = options;
|
||||
|
||||
// Reserva memoria para los objetos
|
||||
playerTexture = new Texture(renderer, asset->get("player.png"));
|
||||
@@ -28,7 +29,7 @@ ScoreBoard::ScoreBoard(SDL_Renderer *renderer, Asset *asset, board_t *board)
|
||||
const std::vector<std::string> vColors = {"blue", "magenta", "green", "cyan", "yellow", "white", "bright_blue", "bright_magenta", "bright_green", "bright_cyan", "bright_yellow", "bright_white"};
|
||||
for (auto v : vColors)
|
||||
{
|
||||
color.push_back(stringToColor(v));
|
||||
color.push_back(stringToColor(options->palette, v));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +54,6 @@ void ScoreBoard::render()
|
||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
|
||||
|
||||
// Dibuja las vidas
|
||||
const int desp = (counter / 40) % 8;
|
||||
const int frame = desp % 4;
|
||||
@@ -80,13 +80,13 @@ void ScoreBoard::render()
|
||||
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 ", board->color);
|
||||
this->text->writeColored(17 * BLOCK, line1, itemsTxt, stringToColor("white"));
|
||||
this->text->writeColored(17 * BLOCK, line1, itemsTxt, stringToColor(options->palette, "white"));
|
||||
this->text->writeColored(20 * BLOCK, line1, " Time ", board->color);
|
||||
this->text->writeColored(26 * BLOCK, line1, timeTxt, stringToColor("white"));
|
||||
this->text->writeColored(26 * BLOCK, line1, timeTxt, stringToColor(options->palette, "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("white"));
|
||||
this->text->writeColored(28 * BLOCK, line2, roomsTxt, stringToColor("white"));
|
||||
this->text->writeColored(22 * BLOCK, line2, "Rooms", stringToColor(options->palette, "white"));
|
||||
this->text->writeColored(28 * BLOCK, line2, roomsTxt, stringToColor(options->palette, "white"));
|
||||
}
|
||||
|
||||
// Actualiza las variables del objeto
|
||||
@@ -121,6 +121,14 @@ void ScoreBoard::reLoadTexture()
|
||||
playerTexture->reLoad();
|
||||
itemTexture->reLoad();
|
||||
text->reLoadTexture();
|
||||
|
||||
// Reinicia el vector de colores
|
||||
const std::vector<std::string> vColors = {"blue", "magenta", "green", "cyan", "yellow", "white", "bright_blue", "bright_magenta", "bright_green", "bright_cyan", "bright_yellow", "bright_white"};
|
||||
color.clear();
|
||||
for (auto v : vColors)
|
||||
{
|
||||
color.push_back(stringToColor(options->palette, v));
|
||||
}
|
||||
}
|
||||
|
||||
// Pone el marcador en modo pausa
|
||||
|
||||
Reference in New Issue
Block a user