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

@@ -3,22 +3,22 @@
<tileset firstgid="1" source="standard.tsx"/>
<layer id="1" name="Capa de patrones 1" width="32" height="16">
<data encoding="csv">
133,133,133,133,133,133,133,131,131,133,133,133,132,132,133,133,133,132,132,133,133,133,131,131,133,133,0,0,0,0,505,133,
133,133,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,505,0,133,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,505,133,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,505,0,133,
133,133,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,505,0,0,133,
133,133,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,505,0,0,0,133,
133,133,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,505,0,0,0,0,133,
133,133,0,0,228,228,228,0,0,228,228,228,0,0,228,228,228,0,0,228,228,228,0,0,228,228,0,0,228,0,0,133,
133,133,0,0,234,234,234,0,0,234,234,234,0,0,234,234,234,0,0,234,234,234,0,0,234,234,0,0,234,0,0,133,
133,133,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,133,
133,133,228,228,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,228,230,133,
133,133,228,228,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,133,
133,133,234,234,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,234,231,133,
133,133,234,234,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,133,
133,133,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,133,
133,133,0,0,228,228,228,0,0,229,228,228,0,0,228,228,228,0,0,228,228,228,0,0,228,228,0,0,0,0,0,133,
133,133,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,228,228,133,
133,133,0,0,234,234,234,0,0,230,234,234,0,0,234,234,234,0,0,234,234,234,0,0,234,234,0,0,0,0,0,133,
133,133,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,234,234,133,
133,133,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,133,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,228,228,0,0,0,0,133,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,234,234,0,0,0,0,133,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,133,
133,133,133,133,133,133,133,131,131,133,133,133,132,132,133,133,133,132,132,133,133,133,131,131,133,133,133,133,133,133,133,133
133,133,133,133,133,133,133,129,129,133,133,133,130,130,133,133,133,130,130,133,133,133,129,129,133,133,133,133,133,133,133,133
</data>
</layer>
</map>

View File

@@ -1,5 +1,5 @@
name=QVOID IS A JAILGAME!
bgColor=bright_black
bgColor=blue
border=bright_black
tileMapFile=30.tmx
tileSetFile=standard.png
@@ -9,25 +9,57 @@ roomLeft=0
roomRight=29.room
[enemy]
tileSetFile=diskette.png
animation=diskette.ani
tileSetFile=qvoid.png
animation=qvoid.ani
width=16
height=16
x=2
y=2
vx=0
x=1
y=1
vx=0.7
vy=0
x1=2
y1=2
x2=2
y2=2
color=magenta
x1=1
y1=1
x2=29
y2=1
color=white
[/enemy]
[enemy]
tileSetFile=qvoid.png
animation=qvoid.ani
width=16
height=16
x=29
y=1
vx=-0.7
vy=0
x1=1
y1=1
x2=29
y2=1
color=red
[/enemy]
[enemy]
tileSetFile=qvoid.png
animation=qvoid.ani
width=16
height=16
x=6
y=7
vx=-0.5
vy=0
x1=1
y1=7
x2=27
y2=7
color=green
[/enemy]
[item]
tileSetFile=items.png
tile=1
tile=20
x=1
y=1
y=2
counter=1
[/item]

View File

@@ -3,22 +3,22 @@
<tileset firstgid="1" source="standard.tsx"/>
<layer id="1" name="Capa de patrones 1" width="32" height="16">
<data encoding="csv">
133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,0,0,0,0,0,0,0,0,0,0,0,0,133,
133,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,133,
133,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,133,
133,228,228,0,0,228,228,0,0,228,228,0,0,228,228,0,0,228,228,0,0,0,0,0,0,0,0,0,0,0,0,133,
133,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,133,
133,0,0,228,228,0,0,228,228,0,0,228,228,0,0,228,228,0,0,0,228,228,0,0,0,228,228,548,0,0,0,133,
133,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,548,0,0,133,
133,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,228,0,133,
133,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,133,
133,0,0,0,0,0,0,0,0,485,485,485,0,0,0,228,228,0,0,0,485,485,485,0,0,0,228,228,0,0,0,133,
133,0,0,0,228,228,228,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,133,
133,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,228,133,
133,228,228,548,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,133,
133,0,0,0,548,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
133,0,0,0,0,548,0,0,0,0,0,555,0,0,0,0,0,0,0,0,0,555,0,0,0,0,0,0,0,0,0,0,
133,555,555,555,555,555,485,485,485,485,485,485,485,485,485,485,485,485,485,485,485,485,485,485,485,485,485,485,485,133,133,133
127,128,129,130,131,132,133,127,128,129,130,131,132,133,127,128,129,130,131,132,133,127,128,129,130,131,132,133,127,128,129,130,
132,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,132,128,
131,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,129,
130,228,229,0,0,230,231,0,0,232,233,0,0,234,228,0,0,229,230,0,0,0,0,0,0,0,0,0,0,0,0,130,
129,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,131,
128,0,0,231,232,0,0,233,234,0,0,228,229,0,0,230,231,0,0,0,232,233,0,0,0,0,0,0,0,0,0,132,
127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,234,228,231,548,0,0,133,
127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,229,231,127,
128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,
128,0,0,0,0,0,0,0,0,232,233,228,0,0,0,485,485,0,0,0,230,231,232,0,0,0,485,485,0,0,0,129,
129,0,0,0,229,230,231,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,130,
130,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,131,
131,232,233,548,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,132,
132,0,0,0,548,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
132,0,0,0,0,548,0,0,0,0,0,555,0,0,0,0,0,0,0,0,0,555,0,0,0,0,0,0,0,0,0,0,
133,555,555,555,555,555,127,128,129,130,131,132,485,485,485,485,485,485,485,485,485,128,129,130,131,132,133,127,128,129,130,131
</data>
</layer>
</map>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

@@ -576,3 +576,13 @@ std::string boolToString(bool value)
return "false";
}
}
// Compara dos colores
bool colorAreEqual(color_t color1, color_t color2)
{
const bool r = color1.r == color2.r;
const bool g = color1.g == color2.g;
const bool b = color1.b == color2.b;
return (r && g && b);
}

View File

@@ -125,4 +125,7 @@ bool stringToBool(std::string str);
// Convierte un valor booleano en una cadena
std::string boolToString(bool value);
// Compara dos colores
bool colorAreEqual(color_t color1, color_t color2);
#endif

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
@@ -478,3 +477,18 @@ void Game::renderBlackScreen()
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;
}

View File

@@ -109,6 +109,9 @@ private:
// Dibuja la pantalla negra
void renderBlackScreen();
// Pone el color del marcador en función del color del borde de la habitación
void setScoreBoardColor();
public:
// Constructor
Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, Debug *debug);

View File

@@ -21,7 +21,6 @@ Player::Player(player_t player)
color = stringToColor(options->palette, "white");
onBorder = false;
border = BORDER_TOP;
invincible = false;
autoMovement = false;
alive = true;
maxFallHeight = BLOCK * 4;
@@ -433,6 +432,13 @@ void Player::move()
autoMovement = false;
}
// Si ha salido de una superficie automatica, detiene el movimiento automatico
if (state == s_standing && isOnFloor() && !isOnAutoSurface())
{
// Deja de estar enganchado a la superficie automatica
autoMovement = false;
}
// Se mueve hacia arriba
if (vy < 0.0f)
{
@@ -688,7 +694,7 @@ playerSpawn_t Player::getSpawnParams()
void Player::reLoadTexture()
{
sprite->getTexture()->reLoad();
//texture->reLoad();
// texture->reLoad();
}
// Recarga la paleta
@@ -729,18 +735,6 @@ void Player::updateFeet()
feet[1] = {p.x + 7, p.y + h - 1};
}
// Obtiene el valor de la variable
bool Player::getInvincible()
{
return invincible;
}
// Establece el valor de la variable
void Player::setInvincible(bool value)
{
invincible = value;
}
// Cambia el estado del jugador
void Player::setState(state_e value)
{

View File

@@ -76,7 +76,6 @@ public:
state_e prevState; // Estado previo en el que se encontraba el jugador
bool onBorder; // Indica si el jugador esta en uno de los cuatro bordes de la pantalla
int border; // Indica en cual de los cuatro bordes se encuentra
bool invincible; // Si es invencible, no puede morir
bool autoMovement; // Indica si esta siendo arrastrado por una superficie automatica
bool paused; // Indica si el jugador esta en modo pausa
SDL_Rect lastPosition; // Contiene la ultima posición del jugador, por si hay que deshacer algun movimiento
@@ -181,12 +180,6 @@ public:
// Establece el valor de la variable
void setRoom(Room *room);
// Obtiene el valor de la variable
bool getInvincible();
// Establece el valor de la variable
void setInvincible(bool value);
// Comprueba si el jugador esta vivo
bool isAlive();