Implementado el cambio de paleta durante el juego

This commit is contained in:
2022-10-25 21:51:30 +02:00
parent bcb56e17f2
commit dc84ed79d6
31 changed files with 297 additions and 164 deletions

View File

@@ -1,12 +1,13 @@
#include "credits.h"
// Constructor
Credits::Credits(SDL_Renderer *renderer, Screen *screen, Asset *asset)
Credits::Credits(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options)
{
// Copia la dirección de los objetos
this->renderer = renderer;
this->screen = screen;
this->asset = asset;
this->options = options;
// Reserva memoria para los punteros
eventHandler = new SDL_Event();
@@ -25,36 +26,36 @@ Credits::Credits(SDL_Renderer *renderer, Screen *screen, Asset *asset)
sprite->setRect({194, 174, 8, 8});
// Cambia el color del borde
screen->setBorderColor(stringToColor("black"));
screen->setBorderColor(stringToColor(options->palette, "black"));
// Inicializa los textos
texts.push_back({"", stringToColor("white")});
texts.push_back({"INSTRUCTIONS:", stringToColor("yellow")});
texts.push_back({"", stringToColor("white")});
texts.push_back({"HELP JAILDOC TO GET BACK ALL HIS", stringToColor("white")});
texts.push_back({"PROJECTS AND GO TO THE JAIL TO", stringToColor("white")});
texts.push_back({"FINISH THEM", stringToColor("white")});
texts.push_back({"", stringToColor("white")});
texts.push_back({"", stringToColor("white")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"INSTRUCTIONS:", stringToColor(options->palette, "yellow")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"HELP JAILDOC TO GET BACK ALL HIS", stringToColor(options->palette, "white")});
texts.push_back({"PROJECTS AND GO TO THE JAIL TO", stringToColor(options->palette, "white")});
texts.push_back({"FINISH THEM", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"KEYS:", stringToColor("yellow")});
texts.push_back({"", stringToColor("white")});
texts.push_back({"USE CURSORS TO MOVE AND JUMP", stringToColor("white")});
texts.push_back({"F1-F4 TO CHANGE WINDOWS SIZE", stringToColor("white")});
texts.push_back({"F TO SWITCH TO FULLSCREEN", stringToColor("white")});
texts.push_back({"B TO DE/ACTIVATE THE BORDER SC.", stringToColor("white")});
texts.push_back({"M TO TURN ON/OFF THE MUSIC", stringToColor("white")});
texts.push_back({"ESC TO EXIT GAME", stringToColor("white")});
texts.push_back({"", stringToColor("white")});
texts.push_back({"", stringToColor("white")});
texts.push_back({"KEYS:", stringToColor(options->palette, "yellow")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"USE CURSORS TO MOVE AND JUMP", stringToColor(options->palette, "white")});
texts.push_back({"F1-F4 TO CHANGE WINDOWS SIZE", stringToColor(options->palette, "white")});
texts.push_back({"F TO SWITCH TO FULLSCREEN", stringToColor(options->palette, "white")});
texts.push_back({"B TO DE/ACTIVATE THE BORDER SC.", stringToColor(options->palette, "white")});
texts.push_back({"M TO TURN ON/OFF THE MUSIC", stringToColor(options->palette, "white")});
texts.push_back({"ESC TO EXIT GAME", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"A GAME BY JAILDESIGNER", stringToColor("yellow")});
texts.push_back({"MADE ON SUMMER/FALL 2022", stringToColor("yellow")});
texts.push_back({"", stringToColor("white")});
texts.push_back({"", stringToColor("white")});
texts.push_back({"A GAME BY JAILDESIGNER", stringToColor(options->palette, "yellow")});
texts.push_back({"MADE ON SUMMER/FALL 2022", stringToColor(options->palette, "yellow")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
texts.push_back({"I LOVE JAILGAMES!}", stringToColor("white")});
texts.push_back({"", stringToColor("white")});
texts.push_back({"I LOVE JAILGAMES!", stringToColor(options->palette, "white")});
texts.push_back({"", stringToColor(options->palette, "white")});
// Crea la textura para el texto que se escribe en pantalla
textTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
@@ -124,7 +125,7 @@ void Credits::fillTexture()
{
// Rellena la textura de texto
SDL_SetRenderTarget(renderer, textTexture);
const color_t c = stringToColor("black");
const color_t c = stringToColor(options->palette, "black");
SDL_SetRenderDrawColor(renderer, c.r, c.g, c.b, 0x00);
SDL_RenderClear(renderer);
@@ -138,6 +139,9 @@ void Credits::fillTexture()
i++;
}
// Escribe el corazón
text->writeColored(194, 176, "}", stringToColor(options->palette, "bright_red"));
SDL_SetRenderTarget(renderer, nullptr);
// Rellena la textura que cubre el texto