forked from jaildesigner-jailgames/jaildoctors_dilemma
Reestructurant la classe Options
This commit is contained in:
@@ -36,8 +36,8 @@ Ending::Ending()
|
||||
counter = -1;
|
||||
preCounter = 0;
|
||||
coverCounter = 0;
|
||||
options.section.name = SECTION_ENDING;
|
||||
options.section.subsection = 0;
|
||||
options.section.section = Section::ENDING;
|
||||
options.section.subsection = Subsection::NONE;
|
||||
ticks = 0;
|
||||
ticksSpeed = 15;
|
||||
scene = 0;
|
||||
@@ -52,7 +52,7 @@ Ending::Ending()
|
||||
iniScenes();
|
||||
|
||||
// Cambia el color del borde
|
||||
screen->setBorderColor(stringToColor(options.palette, "black"));
|
||||
screen->setBorderColor(stringToColor(options.video.palette, "black"));
|
||||
|
||||
// Crea la textura para cubrir el rexto
|
||||
coverTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT + 8);
|
||||
@@ -131,7 +131,7 @@ void Ending::render()
|
||||
screen->start();
|
||||
|
||||
// Limpia la pantalla
|
||||
screen->clean(stringToColor(options.palette, "black"));
|
||||
screen->clean(stringToColor(options.video.palette, "black"));
|
||||
|
||||
// Dibuja las imagenes de la escena
|
||||
spritePics[scene].sprite->render();
|
||||
@@ -150,8 +150,6 @@ void Ending::render()
|
||||
// Dibuja la cortinilla de cambio de escena
|
||||
renderCoverTexture();
|
||||
|
||||
// text->write(0, 0, std::to_string(counter));
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
screen->render();
|
||||
}
|
||||
@@ -222,7 +220,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 c = stringToColor(options.video.palette, "black");
|
||||
|
||||
// Crea la texture
|
||||
st.texture = new Texture(renderer);
|
||||
@@ -246,7 +244,7 @@ void Ending::iniTexts()
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
// Los primeros 8 pixels crea una malla
|
||||
c = stringToColor(options.palette, "black");
|
||||
c = stringToColor(options.video.palette, "black");
|
||||
SDL_SetRenderDrawColor(renderer, c.r, c.g, c.b, 0xFF);
|
||||
for (int i = 0; i < width; i += 2)
|
||||
{
|
||||
@@ -261,7 +259,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.video.palette, "black");
|
||||
SDL_SetRenderDrawColor(renderer, c.r, c.g, c.b, 0xFF);
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
|
||||
@@ -284,7 +282,7 @@ void Ending::iniPics()
|
||||
// Vector con las rutas y la posición
|
||||
std::vector<textAndPos_t> pics;
|
||||
|
||||
if (options.palette == p_zxspectrum)
|
||||
if (options.video.palette == Palette::ZXSPECTRUM)
|
||||
{
|
||||
pics.push_back({"ending1.png", 48});
|
||||
pics.push_back({"ending2.png", 26});
|
||||
@@ -334,7 +332,7 @@ void Ending::iniPics()
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
// Los primeros 8 pixels crea una malla
|
||||
color_t c = stringToColor(options.palette, "black");
|
||||
Color c = stringToColor(options.video.palette, "black");
|
||||
SDL_SetRenderDrawColor(renderer, c.r, c.g, c.b, 0xFF);
|
||||
for (int i = 0; i < width; i += 2)
|
||||
{
|
||||
@@ -349,7 +347,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.video.palette, "black");
|
||||
SDL_SetRenderDrawColor(renderer, c.r, c.g, c.b, 0xFF);
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
|
||||
@@ -454,7 +452,7 @@ void Ending::run()
|
||||
{
|
||||
JA_PlayMusic(music);
|
||||
|
||||
while (options.section.name == SECTION_ENDING)
|
||||
while (options.section.section == Section::ENDING)
|
||||
{
|
||||
update();
|
||||
checkEvents();
|
||||
@@ -538,7 +536,7 @@ void Ending::checkChangeScene()
|
||||
if (scene == 5)
|
||||
{
|
||||
// Termina el bucle
|
||||
options.section.name = SECTION_ENDING2;
|
||||
options.section.section = Section::ENDING2;
|
||||
|
||||
// Mantiene los valores anteriores
|
||||
scene = 4;
|
||||
@@ -556,8 +554,8 @@ void Ending::fillCoverTexture()
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
// Los primeros 8 pixels crea una malla
|
||||
const color_t c = stringToColor(options.palette, "brack");
|
||||
SDL_SetRenderDrawColor(renderer, c.r, c.g, c.b, 0xFF);
|
||||
const Color color = stringToColor(options.video.palette, "black");
|
||||
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF);
|
||||
for (int i = 0; i < 256; i += 2)
|
||||
{
|
||||
SDL_RenderDrawPoint(renderer, i + 0, GAMECANVAS_HEIGHT + 0);
|
||||
@@ -597,29 +595,4 @@ void Ending::updateMusicVolume()
|
||||
const int volume = 128 * step;
|
||||
JA_SetVolume(volume);
|
||||
}
|
||||
}
|
||||
|
||||
// Cambia la paleta
|
||||
void Ending::switchPalette()
|
||||
{
|
||||
if (options.palette == p_zxspectrum)
|
||||
{
|
||||
options.palette = p_zxarne;
|
||||
|
||||
spritePics[0].sprite->setTexture(resource->getTexture("ending1_zxarne.png"));
|
||||
spritePics[1].sprite->setTexture(resource->getTexture("ending2_zxarne.png"));
|
||||
spritePics[2].sprite->setTexture(resource->getTexture("ending3_zxarne.png"));
|
||||
spritePics[3].sprite->setTexture(resource->getTexture("ending4_zxarne.png"));
|
||||
spritePics[4].sprite->setTexture(resource->getTexture("ending5_zxarne.png"));
|
||||
}
|
||||
else
|
||||
{
|
||||
options.palette = p_zxspectrum;
|
||||
|
||||
spritePics[0].sprite->setTexture(resource->getTexture("ending1.png"));
|
||||
spritePics[1].sprite->setTexture(resource->getTexture("ending2.png"));
|
||||
spritePics[2].sprite->setTexture(resource->getTexture("ending3.png"));
|
||||
spritePics[3].sprite->setTexture(resource->getTexture("ending4.png"));
|
||||
spritePics[4].sprite->setTexture(resource->getTexture("ending5.png"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user