forked from jaildesigner-jailgames/jaildoctors_dilemma
Trabajando en el ending2
This commit is contained in:
@@ -83,10 +83,25 @@ void Ending2::render()
|
||||
screen->clean(stringToColor(options->palette, "black"));
|
||||
|
||||
// Dibuja los sprites
|
||||
void renderSprites();
|
||||
renderSprites();
|
||||
|
||||
const std::string txt = std::to_string(preCounter) + " - " + std::to_string(counter);
|
||||
text->write(0, 0, txt);
|
||||
const std::string txt = std::to_string(preCounter) + " - " + std::to_string(counter) + " - W:" + std::to_string(maxSpriteWidth) + " - H:" + std::to_string(maxSpriteHeight);
|
||||
text->write(0, 192 - 8, txt);
|
||||
|
||||
// Dibuja la cuadricula
|
||||
{
|
||||
SDL_SetRenderDrawColor(renderer, 128, 128, 128, 255);
|
||||
const int sw = maxSpriteWidth + 6;
|
||||
const int sh = maxSpriteHeight + 6;
|
||||
for (int i = 0; i < (int)sprites.size(); ++i)
|
||||
{
|
||||
const int x = (i * sw) % (256 - sw);
|
||||
const int y = (i / (256 / sw)) * sh;
|
||||
const int w = sprites.at(i)->getAnimationClip(0, 0).w;
|
||||
const int h = sprites.at(i)->getAnimationClip(0, 0).h;
|
||||
sprites.at(i)->setRect({x, y, w, h});
|
||||
}
|
||||
}
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
screen->blit();
|
||||
@@ -158,7 +173,7 @@ void Ending2::checkEventHandler()
|
||||
// Bucle principal
|
||||
section_t Ending2::run()
|
||||
{
|
||||
JA_PlayMusic(music);
|
||||
// JA_PlayMusic(music);
|
||||
|
||||
while (section.name == SECTION_PROG_ENDING2)
|
||||
{
|
||||
@@ -166,7 +181,7 @@ section_t Ending2::run()
|
||||
render();
|
||||
}
|
||||
|
||||
JA_StopMusic();
|
||||
// JA_StopMusic();
|
||||
|
||||
return section;
|
||||
}
|
||||
@@ -175,7 +190,7 @@ section_t Ending2::run()
|
||||
void Ending2::updateCounters()
|
||||
{
|
||||
// Incrementa el contador
|
||||
if (preCounter < 200)
|
||||
if (preCounter < 20)
|
||||
{
|
||||
preCounter++;
|
||||
}
|
||||
@@ -242,16 +257,25 @@ void Ending2::iniSpriteList()
|
||||
// Carga todos los sprites desde una lista
|
||||
void Ending2::loadSprites()
|
||||
{
|
||||
maxSpriteWidth = 0;
|
||||
maxSpriteHeight = 0;
|
||||
|
||||
for (auto sl : spriteList)
|
||||
{
|
||||
sprites.push_back(new AnimatedSprite(renderer, resource->getAnimation(sl + ".ani")));
|
||||
maxSpriteWidth = std::max(sprites.back()->getAnimationClip(0, 0).w, maxSpriteWidth);
|
||||
maxSpriteHeight = std::max(sprites.back()->getAnimationClip(0, 0).h, maxSpriteHeight);
|
||||
}
|
||||
|
||||
const int sw = maxSpriteWidth + 6;
|
||||
const int sh = maxSpriteHeight + 6;
|
||||
for (int i = 0; i < (int)sprites.size(); ++i)
|
||||
{
|
||||
const int x = (i * 20) % 220;
|
||||
const int y = (i / 11) * 20;
|
||||
sprites.at(i)->setPos({x, y});
|
||||
const int x = (i * sw) % (256 - sw);
|
||||
const int y = (i / (256 / sw)) * sh;
|
||||
const int w = sprites.at(i)->getAnimationClip(0, 0).w;
|
||||
const int h = sprites.at(i)->getAnimationClip(0, 0).h;
|
||||
sprites.at(i)->setRect({x, y, w, h});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,8 +291,11 @@ void Ending2::updateSprites()
|
||||
// Dibuja los sprites
|
||||
void Ending2::renderSprites()
|
||||
{
|
||||
const color_t color = stringToColor(options->palette, "red");
|
||||
for (auto sprite : sprites)
|
||||
{
|
||||
sprite->getTexture()->setColor(color.r, color.g, color.b);
|
||||
sprite->render();
|
||||
sprite->getTexture()->setColor(255, 255, 255);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user