JA VA! Nomes s'havia de fer les coses be i no ser un ansias
This commit is contained in:
@@ -16,9 +16,10 @@
|
||||
#include "text.h" // Para Text, TXT_STROKE
|
||||
#include "texture.h" // Para Texture
|
||||
#include "utils.h" // Para color_t, stringToColor, options_t
|
||||
#include "options.h"
|
||||
|
||||
// Constructor
|
||||
Ending::Ending(Resource *resource, options_t *options, section_t *section)
|
||||
Ending::Ending(Resource *resource)
|
||||
{
|
||||
// Copia los punteros
|
||||
this->screen = Screen::get();
|
||||
@@ -26,8 +27,6 @@ Ending::Ending(Resource *resource, options_t *options, section_t *section)
|
||||
this->resource = resource;
|
||||
this->asset = Asset::get();
|
||||
this->input = Input::get();
|
||||
this->options = options;
|
||||
this->section = section;
|
||||
|
||||
// Reserva memoria para los punteros a objetos
|
||||
eventHandler = new SDL_Event();
|
||||
@@ -38,8 +37,8 @@ Ending::Ending(Resource *resource, options_t *options, section_t *section)
|
||||
counter = -1;
|
||||
preCounter = 0;
|
||||
coverCounter = 0;
|
||||
section->name = SECTION_ENDING;
|
||||
section->subsection = 0;
|
||||
options.section.name = SECTION_ENDING;
|
||||
options.section.subsection = 0;
|
||||
ticks = 0;
|
||||
ticksSpeed = 15;
|
||||
scene = 0;
|
||||
@@ -54,13 +53,13 @@ Ending::Ending(Resource *resource, options_t *options, section_t *section)
|
||||
iniScenes();
|
||||
|
||||
// Cambia el color del borde
|
||||
screen->setBorderColor(stringToColor(options->palette, "black"));
|
||||
screen->setBorderColor(stringToColor(options.palette, "black"));
|
||||
|
||||
// Crea la textura para cubrir el rexto
|
||||
coverTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT + 8);
|
||||
if (coverTexture == nullptr)
|
||||
{
|
||||
if (options->console)
|
||||
if (options.console)
|
||||
{
|
||||
std::cout << "Error: canvasTexture could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
|
||||
}
|
||||
@@ -135,7 +134,7 @@ void Ending::render()
|
||||
screen->start();
|
||||
|
||||
// Limpia la pantalla
|
||||
screen->clean(stringToColor(options->palette, "black"));
|
||||
screen->clean(stringToColor(options.palette, "black"));
|
||||
|
||||
// Dibuja las imagenes de la escena
|
||||
spritePics[scene].sprite->render();
|
||||
@@ -169,7 +168,7 @@ void Ending::checkEvents()
|
||||
// Evento de salida de la aplicación
|
||||
if (eventHandler->type == SDL_QUIT)
|
||||
{
|
||||
section->name = SECTION_QUIT;
|
||||
options.section.name = SECTION_QUIT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -181,8 +180,8 @@ void Ending::checkInput()
|
||||
|
||||
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||
{
|
||||
section->name = SECTION_LOGO;
|
||||
section->subsection = SUBSECTION_LOGO_TO_INTRO;
|
||||
options.section.name = SECTION_LOGO;
|
||||
options.section.subsection = SUBSECTION_LOGO_TO_INTRO;
|
||||
}
|
||||
|
||||
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
|
||||
@@ -261,7 +260,7 @@ void Ending::iniTexts()
|
||||
endingTexture_t st;
|
||||
const int width = text->lenght(t.caption, 1) + 2 + 2;
|
||||
const int height = text->getCharacterSize() + 2 + 2;
|
||||
color_t c = stringToColor(options->palette, "black");
|
||||
color_t c = stringToColor(options.palette, "black");
|
||||
|
||||
// Crea la texture
|
||||
st.texture = new Texture(renderer);
|
||||
@@ -285,7 +284,7 @@ void Ending::iniTexts()
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
// Los primeros 8 pixels crea una malla
|
||||
c = stringToColor(options->palette, "black");
|
||||
c = stringToColor(options.palette, "black");
|
||||
SDL_SetRenderDrawColor(renderer, c.r, c.g, c.b, 0xFF);
|
||||
for (int i = 0; i < width; i += 2)
|
||||
{
|
||||
@@ -300,7 +299,7 @@ void Ending::iniTexts()
|
||||
|
||||
// El resto se rellena de color sólido
|
||||
SDL_Rect rect = {0, 8, width, height};
|
||||
c = stringToColor(options->palette, "black");
|
||||
c = stringToColor(options.palette, "black");
|
||||
SDL_SetRenderDrawColor(renderer, c.r, c.g, c.b, 0xFF);
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
|
||||
@@ -323,7 +322,7 @@ void Ending::iniPics()
|
||||
// Vector con las rutas y la posición
|
||||
std::vector<textAndPos_t> pics;
|
||||
|
||||
if (options->palette == p_zxspectrum)
|
||||
if (options.palette == p_zxspectrum)
|
||||
{
|
||||
pics.push_back({"ending1.png", 48});
|
||||
pics.push_back({"ending2.png", 26});
|
||||
@@ -373,7 +372,7 @@ void Ending::iniPics()
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
// Los primeros 8 pixels crea una malla
|
||||
color_t c = stringToColor(options->palette, "black");
|
||||
color_t c = stringToColor(options.palette, "black");
|
||||
SDL_SetRenderDrawColor(renderer, c.r, c.g, c.b, 0xFF);
|
||||
for (int i = 0; i < width; i += 2)
|
||||
{
|
||||
@@ -388,7 +387,7 @@ void Ending::iniPics()
|
||||
|
||||
// El resto se rellena de color sólido
|
||||
SDL_Rect rect = {0, 8, width, height};
|
||||
c = stringToColor(options->palette, "black");
|
||||
c = stringToColor(options.palette, "black");
|
||||
SDL_SetRenderDrawColor(renderer, c.r, c.g, c.b, 0xFF);
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
|
||||
@@ -493,7 +492,7 @@ void Ending::run()
|
||||
{
|
||||
JA_PlayMusic(music);
|
||||
|
||||
while (section->name == SECTION_ENDING)
|
||||
while (options.section.name == SECTION_ENDING)
|
||||
{
|
||||
update();
|
||||
checkEvents();
|
||||
@@ -577,7 +576,7 @@ void Ending::checkChangeScene()
|
||||
if (scene == 5)
|
||||
{
|
||||
// Termina el bucle
|
||||
section->name = SECTION_ENDING2;
|
||||
options.section.name = SECTION_ENDING2;
|
||||
|
||||
// Mantiene los valores anteriores
|
||||
scene = 4;
|
||||
@@ -595,7 +594,7 @@ void Ending::fillCoverTexture()
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
// Los primeros 8 pixels crea una malla
|
||||
const color_t c = stringToColor(options->palette, "brack");
|
||||
const color_t c = stringToColor(options.palette, "brack");
|
||||
SDL_SetRenderDrawColor(renderer, c.r, c.g, c.b, 0xFF);
|
||||
for (int i = 0; i < 256; i += 2)
|
||||
{
|
||||
@@ -641,9 +640,9 @@ void Ending::updateMusicVolume()
|
||||
// Cambia la paleta
|
||||
void Ending::switchPalette()
|
||||
{
|
||||
if (options->palette == p_zxspectrum)
|
||||
if (options.palette == p_zxspectrum)
|
||||
{
|
||||
options->palette = p_zxarne;
|
||||
options.palette = p_zxarne;
|
||||
|
||||
spritePics[0].sprite->setTexture(resource->getTexture("ending1_zxarne.png"));
|
||||
spritePics[1].sprite->setTexture(resource->getTexture("ending2_zxarne.png"));
|
||||
@@ -653,7 +652,7 @@ void Ending::switchPalette()
|
||||
}
|
||||
else
|
||||
{
|
||||
options->palette = p_zxspectrum;
|
||||
options.palette = p_zxspectrum;
|
||||
|
||||
spritePics[0].sprite->setTexture(resource->getTexture("ending1.png"));
|
||||
spritePics[1].sprite->setTexture(resource->getTexture("ending2.png"));
|
||||
|
||||
Reference in New Issue
Block a user