Arreglado el color del marcador al cambiar de paleta

This commit is contained in:
2022-11-02 17:25:42 +01:00
parent c3a82b938f
commit 5302e16064
10 changed files with 130 additions and 81 deletions

View File

@@ -52,8 +52,8 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
blackScreen = false;
blackScreenCounter = 0;
this->player->setInvincible(debug->getEnabled());
board.music = !debug->getEnabled();
// this->player->setInvincible(debug->getEnabled());
// board.music = !debug->getEnabled();
section.name = SECTION_PROG_GAME;
section.subsection = 0;
@@ -100,7 +100,7 @@ void Game::checkEventHandler()
case SDL_SCANCODE_D:
debug->switchEnabled();
player->setInvincible(debug->getEnabled());
options->invincible = debug->getEnabled();
board.music = !debug->getEnabled();
board.music ? JA_ResumeMusic() : JA_PauseMusic();
break;
@@ -312,11 +312,9 @@ bool Game::changeRoom(std::string file)
// Crea un objeto habitación nuevo a partir del fichero
room = new Room(resource->getRoom(file), renderer, screen, asset, options, itemTracker, &board.items, debug);
// Actualiza el marcador
const color_t c = room->getBorderColor(); // Obtiene el color del vorde
const color_t cBlack = stringToColor(options->palette, "black");
board.color = (c.r == cBlack.r && c.g == cBlack.g && c.b == cBlack.b) ? stringToColor(options->palette, "white") : c; // Si el color es negro lo cambia a blanco
// board.color = (c.r + c.g + c.b == 0) ? stringToColor(options->palette, "white") : c; // Si el color es negro lo cambia a blanco
// Pone el color del marcador en función del color del borde de la habitación
setScoreBoardColor();
if (roomTracker->addRoom(file))
{ // Incrementa el contador de habitaciones visitadas
board.rooms++;
@@ -384,7 +382,7 @@ void Game::checkEndGame()
// Mata al jugador
void Game::killPlayer()
{
if (this->player->getInvincible() || options->invincible)
if (options->invincible)
{
return;
}
@@ -437,12 +435,13 @@ void Game::switchPalette()
// Modifica la variable
options->palette = (options->palette == p_zxspectrum) ? p_zxarne : p_zxspectrum;
// Recarga las paletas
room->reLoadPalette();
player->reLoadPalette();
scoreboard->reLoadPalette();
const color_t c = room->getBorderColor();
board.color = (c.r + c.g + c.b == 0) ? stringToColor(options->palette, "white") : c; // Si el color es negro lo cambia a blanco
// Pone el color del marcador en función del color del borde de la habitación
setScoreBoardColor();
}
// Establece la pantalla en negro
@@ -477,4 +476,19 @@ void Game::renderBlackScreen()
screen->clean();
screen->setBorderColor(stringToColor(options->palette, "black"));
}
}
// Pone el color del marcador en función del color del borde de la habitación
void Game::setScoreBoardColor()
{
// Obtiene el color del borde
const color_t c = room->getBorderColor();
// Si el color es negro lo cambia a blanco
const color_t cBlack = stringToColor(options->palette, "black");
board.color = colorAreEqual(c, cBlack) ? stringToColor(options->palette, "white") : c;
// Si el color es negro brillante lo cambia a blanco
const color_t cBrightBlack = stringToColor(options->palette, "bright_black");
board.color = colorAreEqual(c, cBrightBlack) ? stringToColor(options->palette, "white") : c;
}