JA VA! Nomes s'havia de fer les coses be i no ser un ansias
This commit is contained in:
@@ -13,18 +13,16 @@
|
||||
#include "screen.h" // Para Screen
|
||||
#include "text.h" // Para Text, TXT_CENTER, TXT_COLOR
|
||||
#include "asset.h"
|
||||
#include "options.h"
|
||||
class Asset;
|
||||
|
||||
// Constructor
|
||||
Credits::Credits(Resource *resource, options_t *options, section_t *section)
|
||||
Credits::Credits(Resource *resource)
|
||||
: screen_(Screen::get()),
|
||||
renderer_(Screen::get()->getRenderer()),
|
||||
resource_(resource),
|
||||
asset_(Asset::get()),
|
||||
input_(Input::get()),
|
||||
options_(options),
|
||||
section_(section)
|
||||
|
||||
input_(Input::get())
|
||||
{
|
||||
// Reserva memoria para los punteros
|
||||
event_handler_ = new SDL_Event();
|
||||
@@ -32,18 +30,18 @@ Credits::Credits(Resource *resource, options_t *options, section_t *section)
|
||||
sprite_ = new AnimatedSprite(renderer_, resource_->getAnimation("shine.ani"));
|
||||
|
||||
// Inicializa variables
|
||||
section->name = SECTION_CREDITS;
|
||||
section->subsection = 0;
|
||||
options.section.name = SECTION_CREDITS;
|
||||
options.section.subsection = 0;
|
||||
sprite_->setRect({194, 174, 8, 8});
|
||||
|
||||
// Cambia el color del borde
|
||||
screen_->setBorderColor(stringToColor(options->palette, "black"));
|
||||
screen_->setBorderColor(stringToColor(options.palette, "black"));
|
||||
|
||||
// Crea la textura para el texto que se escribe en pantalla
|
||||
text_texture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
|
||||
if (text_texture_ == nullptr)
|
||||
{
|
||||
if (options->console)
|
||||
if (options.console)
|
||||
{
|
||||
std::cout << "Error: textTexture could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
|
||||
}
|
||||
@@ -54,7 +52,7 @@ Credits::Credits(Resource *resource, options_t *options, section_t *section)
|
||||
cover_texture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
|
||||
if (cover_texture_ == nullptr)
|
||||
{
|
||||
if (options->console)
|
||||
if (options.console)
|
||||
{
|
||||
std::cout << "Error: textTexture could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
|
||||
}
|
||||
@@ -84,7 +82,7 @@ void Credits::checkEvents()
|
||||
// Evento de salida de la aplicación
|
||||
if (event_handler_->type == SDL_QUIT)
|
||||
{
|
||||
section_->name = SECTION_QUIT;
|
||||
options.section.name = SECTION_QUIT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -96,7 +94,7 @@ void Credits::checkInput()
|
||||
|
||||
if (input_->checkInput(input_exit, REPEAT_FALSE))
|
||||
{
|
||||
section_->name = SECTION_QUIT;
|
||||
options.section.name = SECTION_QUIT;
|
||||
}
|
||||
|
||||
else if (input_->checkInput(input_toggle_border, REPEAT_FALSE))
|
||||
@@ -126,8 +124,8 @@ void Credits::checkInput()
|
||||
|
||||
else if (input_->checkInput(input_pause, REPEAT_FALSE) || input_->checkInput(input_accept, REPEAT_FALSE) || input_->checkInput(input_jump, REPEAT_FALSE))
|
||||
{
|
||||
section_->name = SECTION_TITLE;
|
||||
section_->subsection = 0;
|
||||
options.section.name = SECTION_TITLE;
|
||||
options.section.subsection = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,11 +133,11 @@ void Credits::checkInput()
|
||||
void Credits::iniTexts()
|
||||
{
|
||||
std::string keys = "";
|
||||
if (options_->keys == ctrl_cursor)
|
||||
if (options.keys == ctrl_cursor)
|
||||
{
|
||||
keys = "CURSORS";
|
||||
}
|
||||
else if (options_->keys == ctrl_opqa)
|
||||
else if (options.keys == ctrl_opqa)
|
||||
{
|
||||
keys = "O,P AND Q";
|
||||
}
|
||||
@@ -150,62 +148,62 @@ void Credits::iniTexts()
|
||||
|
||||
#ifndef GAME_CONSOLE
|
||||
texts_.clear();
|
||||
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", stringToColor(options_->palette, "white")});
|
||||
texts_.push_back({"HIS PROJECTS AND GO TO THE", stringToColor(options_->palette, "white")});
|
||||
texts_.push_back({"JAIL TO FINISH THEM", stringToColor(options_->palette, "white")});
|
||||
texts_.push_back({"", stringToColor(options_->palette, "white")});
|
||||
texts_.push_back({"", stringToColor(options_->palette, "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", stringToColor(options.palette, "white")});
|
||||
texts_.push_back({"HIS PROJECTS AND GO TO THE", stringToColor(options.palette, "white")});
|
||||
texts_.push_back({"JAIL TO 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(options_->palette, "yellow")});
|
||||
texts_.push_back({"", stringToColor(options_->palette, "white")});
|
||||
texts_.push_back({keys + " TO MOVE AND JUMP", stringToColor(options_->palette, "white")});
|
||||
texts_.push_back({"M TO SWITCH THE MUSIC", stringToColor(options_->palette, "white")});
|
||||
texts_.push_back({"H TO PAUSE THE GAME", stringToColor(options_->palette, "white")});
|
||||
texts_.push_back({"F1-F2 TO CHANGE WINDOWS SIZE", stringToColor(options_->palette, "white")});
|
||||
texts_.push_back({"F3 TO SWITCH TO FULLSCREEN", stringToColor(options_->palette, "white")});
|
||||
texts_.push_back({"B TO TOOGLE THE BORDER SCREEN", stringToColor(options_->palette, "white")});
|
||||
texts_.push_back({"", stringToColor(options_->palette, "white")});
|
||||
texts_.push_back({"", stringToColor(options_->palette, "white")});
|
||||
texts_.push_back({"KEYS:", stringToColor(options.palette, "yellow")});
|
||||
texts_.push_back({"", stringToColor(options.palette, "white")});
|
||||
texts_.push_back({keys + " TO MOVE AND JUMP", stringToColor(options.palette, "white")});
|
||||
texts_.push_back({"M TO SWITCH THE MUSIC", stringToColor(options.palette, "white")});
|
||||
texts_.push_back({"H TO PAUSE THE GAME", stringToColor(options.palette, "white")});
|
||||
texts_.push_back({"F1-F2 TO CHANGE WINDOWS SIZE", stringToColor(options.palette, "white")});
|
||||
texts_.push_back({"F3 TO SWITCH TO FULLSCREEN", stringToColor(options.palette, "white")});
|
||||
texts_.push_back({"B TO TOOGLE THE BORDER SCREEN", 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(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({"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(options_->palette, "white")});
|
||||
texts_.push_back({"", stringToColor(options_->palette, "white")});
|
||||
texts_.push_back({"I LOVE JAILGAMES! ", stringToColor(options.palette, "white")});
|
||||
texts_.push_back({"", stringToColor(options.palette, "white")});
|
||||
#else
|
||||
texts.clear();
|
||||
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", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"HIS PROJECTS AND GO TO THE", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"JAIL TO FINISH THEM", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "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", stringToColor(options.palette, "white")});
|
||||
texts.push_back({"HIS PROJECTS AND GO TO THE", stringToColor(options.palette, "white")});
|
||||
texts.push_back({"JAIL TO 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(options->palette, "yellow")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"B TO JUMP", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"R TO SWITCH THE MUSIC", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"L TO SWAP THE COLOR PALETTE", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"START TO PAUSE", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"SELECT TO EXIT", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"KEYS:", stringToColor(options.palette, "yellow")});
|
||||
texts.push_back({"", stringToColor(options.palette, "white")});
|
||||
texts.push_back({"B TO JUMP", stringToColor(options.palette, "white")});
|
||||
texts.push_back({"R TO SWITCH THE MUSIC", stringToColor(options.palette, "white")});
|
||||
texts.push_back({"L TO SWAP THE COLOR PALETTE", stringToColor(options.palette, "white")});
|
||||
texts.push_back({"START TO PAUSE", stringToColor(options.palette, "white")});
|
||||
texts.push_back({"SELECT TO EXIT", stringToColor(options.palette, "white")});
|
||||
texts.push_back({"", 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(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({"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(options->palette, "white")});
|
||||
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||
texts.push_back({"I LOVE JAILGAMES! ", stringToColor(options.palette, "white")});
|
||||
texts.push_back({"", stringToColor(options.palette, "white")});
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -217,7 +215,7 @@ void Credits::fillTexture()
|
||||
|
||||
// Rellena la textura de texto
|
||||
SDL_SetRenderTarget(renderer_, text_texture_);
|
||||
color_t c = stringToColor(options_->palette, "black");
|
||||
color_t c = stringToColor(options.palette, "black");
|
||||
SDL_SetRenderDrawColor(renderer_, c.r, c.g, c.b, 0xFF);
|
||||
SDL_RenderClear(renderer_);
|
||||
|
||||
@@ -234,7 +232,7 @@ void Credits::fillTexture()
|
||||
// Escribe el corazón
|
||||
const int textLenght = text_->lenght(texts_[22].label, 1) - text_->lenght(" ", 1); // Se resta el ultimo caracter que es un espacio
|
||||
const int posX = ((PLAY_AREA_WIDTH - textLenght) / 2) + textLenght;
|
||||
text_->writeColored(posX, 176, "}", stringToColor(options_->palette, "bright_red"));
|
||||
text_->writeColored(posX, 176, "}", stringToColor(options.palette, "bright_red"));
|
||||
|
||||
// Recoloca el sprite del brillo
|
||||
sprite_->setPosX(posX + 2);
|
||||
@@ -291,7 +289,7 @@ void Credits::updateCounter()
|
||||
// Comprueba si ha terminado la sección
|
||||
if (counter_ > 1200)
|
||||
{
|
||||
section_->name = SECTION_DEMO;
|
||||
options.section.name = SECTION_DEMO;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,7 +350,7 @@ void Credits::render()
|
||||
// Bucle para el logo del juego
|
||||
void Credits::run()
|
||||
{
|
||||
while (section_->name == SECTION_CREDITS)
|
||||
while (options.section.name == SECTION_CREDITS)
|
||||
{
|
||||
update();
|
||||
checkEvents();
|
||||
@@ -363,6 +361,6 @@ void Credits::run()
|
||||
// Cambia la paleta
|
||||
void Credits::switchPalette()
|
||||
{
|
||||
options_->palette = options_->palette == p_zxspectrum ? p_zxarne : p_zxspectrum;
|
||||
options.palette = options.palette == p_zxspectrum ? p_zxarne : p_zxspectrum;
|
||||
fillTexture();
|
||||
}
|
||||
Reference in New Issue
Block a user