Cambio de paleta en los finales
This commit is contained in:
@@ -191,15 +191,7 @@ void Ending::checkEventHandler()
|
||||
break;
|
||||
|
||||
case SDL_SCANCODE_F5:
|
||||
// switchPalette();
|
||||
break;
|
||||
|
||||
case SDL_SCANCODE_RIGHT:
|
||||
++scene %= 5;
|
||||
break;
|
||||
|
||||
case SDL_SCANCODE_LEFT:
|
||||
--scene %= 5;
|
||||
switchPalette();
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -319,13 +311,24 @@ void Ending::iniTexts()
|
||||
void Ending::iniPics()
|
||||
{
|
||||
// Vector con las rutas y la posición
|
||||
std::vector<textAndPos_t> texts;
|
||||
std::vector<textAndPos_t> pics;
|
||||
|
||||
texts.push_back({"ending1.png", 48});
|
||||
texts.push_back({"ending2.png", 26});
|
||||
texts.push_back({"ending3.png", 29});
|
||||
texts.push_back({"ending4.png", 63});
|
||||
texts.push_back({"ending5.png", 53});
|
||||
if (options->palette == p_zxspectrum)
|
||||
{
|
||||
pics.push_back({"ending1.png", 48});
|
||||
pics.push_back({"ending2.png", 26});
|
||||
pics.push_back({"ending3.png", 29});
|
||||
pics.push_back({"ending4.png", 63});
|
||||
pics.push_back({"ending5.png", 53});
|
||||
}
|
||||
else
|
||||
{
|
||||
pics.push_back({"ending1_zxarne.png", 48});
|
||||
pics.push_back({"ending2_zxarne.png", 26});
|
||||
pics.push_back({"ending3_zxarne.png", 29});
|
||||
pics.push_back({"ending4_zxarne.png", 63});
|
||||
pics.push_back({"ending5_zxarne.png", 53});
|
||||
}
|
||||
|
||||
// Crea los sprites
|
||||
for (auto sp : spritePics)
|
||||
@@ -336,18 +339,18 @@ void Ending::iniPics()
|
||||
}
|
||||
spritePics.clear();
|
||||
|
||||
for (auto t : texts)
|
||||
for (auto p : pics)
|
||||
{
|
||||
endingTexture_t sp;
|
||||
|
||||
// Crea la texture
|
||||
sp.texture = resource->getTexture(t.caption);
|
||||
sp.texture = resource->getTexture(p.caption);
|
||||
const int width = sp.texture->getWidth();
|
||||
const int height = sp.texture->getHeight();
|
||||
|
||||
// Crea el sprite
|
||||
sp.sprite = new Sprite({0, 0, width, height}, sp.texture, renderer);
|
||||
sp.sprite->setPos({(GAMECANVAS_WIDTH - width) / 2, t.pos});
|
||||
sp.sprite->setPos({(GAMECANVAS_WIDTH - width) / 2, p.pos});
|
||||
|
||||
// Crea la coverTexture
|
||||
sp.coverTexture = new Texture(renderer);
|
||||
@@ -381,7 +384,7 @@ void Ending::iniPics()
|
||||
|
||||
// Crea el sprite
|
||||
sp.coverSprite = new Sprite({0, 0, sp.coverTexture->getWidth(), sp.coverTexture->getHeight() - 8}, sp.coverTexture, renderer);
|
||||
sp.coverSprite->setPos({(GAMECANVAS_WIDTH - sp.coverTexture->getWidth()) / 2, t.pos});
|
||||
sp.coverSprite->setPos({(GAMECANVAS_WIDTH - sp.coverTexture->getWidth()) / 2, p.pos});
|
||||
sp.coverSprite->setSpriteClip(0, 8, -1, -1);
|
||||
|
||||
// Inicializa variables
|
||||
@@ -624,4 +627,29 @@ 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.at(0).sprite->setTexture(resource->getTexture("ending1_zxarne.png"));
|
||||
spritePics.at(1).sprite->setTexture(resource->getTexture("ending2_zxarne.png"));
|
||||
spritePics.at(2).sprite->setTexture(resource->getTexture("ending3_zxarne.png"));
|
||||
spritePics.at(3).sprite->setTexture(resource->getTexture("ending4_zxarne.png"));
|
||||
spritePics.at(4).sprite->setTexture(resource->getTexture("ending5_zxarne.png"));
|
||||
}
|
||||
else
|
||||
{
|
||||
options->palette = p_zxspectrum;
|
||||
|
||||
spritePics.at(0).sprite->setTexture(resource->getTexture("ending1.png"));
|
||||
spritePics.at(1).sprite->setTexture(resource->getTexture("ending2.png"));
|
||||
spritePics.at(2).sprite->setTexture(resource->getTexture("ending3.png"));
|
||||
spritePics.at(3).sprite->setTexture(resource->getTexture("ending4.png"));
|
||||
spritePics.at(4).sprite->setTexture(resource->getTexture("ending5.png"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user