forked from jaildesigner-jailgames/jaildoctors_dilemma
fix: s'havien fotut els dos finals, pero ja estan corregits
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
#include <SDL2/SDL_timer.h> // for SDL_GetTicks
|
||||
#include <algorithm> // for max, min, replace
|
||||
#include "animated_sprite.h" // for AnimatedSprite
|
||||
#include "defines.h" // for GAMECANVAS_HEIGHT, GAMECANVAS_CENTER_X
|
||||
#include "defines.h" // for options.game.height, GAMECANVAS_CENTER_X
|
||||
#include "global_events.h" // for check
|
||||
#include "global_inputs.h" // for check
|
||||
#include "jail_audio.h" // for JA_SetVolume, JA_PlayMusic, JA_StopM...
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "text.h" // for Text
|
||||
#include "texture.h" // for Texture
|
||||
#include "utils.h" // for Color, stringToColor
|
||||
#include <iostream>
|
||||
|
||||
// Constructor
|
||||
Ending2::Ending2()
|
||||
@@ -279,9 +280,9 @@ void Ending2::loadSprites()
|
||||
sprite_max_height_ = 0;
|
||||
|
||||
// Carga los sprites
|
||||
for (const auto &sl : sprite_list_)
|
||||
for (const auto &file : sprite_list_)
|
||||
{
|
||||
sprites_.emplace_back(std::make_shared<AnimatedSprite>(Resource::get()->getTexture(sl + ".png"), Resource::get()->getAnimations(sl + ".ani")));
|
||||
sprites_.emplace_back(std::make_shared<AnimatedSprite>(Resource::get()->getTexture(file + ".png"), Resource::get()->getAnimations(file + ".ani")));
|
||||
sprite_max_width_ = std::max(sprites_.back()->getWidth(), sprite_max_width_);
|
||||
sprite_max_height_ = std::max(sprites_.back()->getHeight(), sprite_max_height_);
|
||||
}
|
||||
@@ -327,9 +328,9 @@ void Ending2::renderSprites()
|
||||
const Color color = stringToColor(options.video.palette, "red");
|
||||
for (auto sprite : sprites_)
|
||||
{
|
||||
const bool a = sprite->getRect().y + sprite->getRect().h > 0;
|
||||
const bool b = sprite->getRect().y < GAMECANVAS_HEIGHT;
|
||||
if (a && b)
|
||||
const bool A = sprite->getRect().y + sprite->getRect().h > 0;
|
||||
const bool B = sprite->getRect().y < options.game.height;
|
||||
if (A && B)
|
||||
{
|
||||
sprite->getTexture()->setColor(color.r, color.g, color.b);
|
||||
sprite->render();
|
||||
@@ -348,9 +349,9 @@ void Ending2::renderSpriteTexts()
|
||||
const Color color = stringToColor(options.video.palette, "white");
|
||||
for (auto sprite : sprite_texts_)
|
||||
{
|
||||
const bool a = sprite->getRect().y + sprite->getRect().h > 0;
|
||||
const bool b = sprite->getRect().y < GAMECANVAS_HEIGHT;
|
||||
if (a && b)
|
||||
const bool A = sprite->getRect().y + sprite->getRect().h > 0;
|
||||
const bool B = sprite->getRect().y < options.game.height;
|
||||
if (A && B)
|
||||
{
|
||||
sprite->getTexture()->setColor(color.r, color.g, color.b);
|
||||
sprite->render();
|
||||
@@ -363,9 +364,9 @@ void Ending2::renderTexts()
|
||||
{
|
||||
for (auto sprite : texts_)
|
||||
{
|
||||
const bool a = sprite->getRect().y + sprite->getRect().h > 0;
|
||||
const bool b = sprite->getRect().y < GAMECANVAS_HEIGHT;
|
||||
if (a && b)
|
||||
const bool A = sprite->getRect().y + sprite->getRect().h > 0;
|
||||
const bool B = sprite->getRect().y < options.game.height;
|
||||
if (A && B)
|
||||
{
|
||||
sprite->render();
|
||||
}
|
||||
@@ -375,25 +376,23 @@ void Ending2::renderTexts()
|
||||
// Coloca los sprites en su sito
|
||||
void Ending2::placeSprites()
|
||||
{
|
||||
for (int i = 0; i < (int)sprites_.size(); ++i)
|
||||
for (int i = 0; i < static_cast<int>(sprites_.size()); ++i)
|
||||
{
|
||||
const int X = i % 2 == 0 ? FIRST_COL_ : SECOND_COL_;
|
||||
const int Y = (i / 1) * (sprite_max_height_ + DIST_SPRITE_TEXT_ + Resource::get()->getText("smb2")->getCharacterSize() + DIST_SPRITE_SPRITE_) + GAMECANVAS_HEIGHT + 40;
|
||||
const int Y = (i / 1) * (sprite_max_height_ + DIST_SPRITE_TEXT_ + Resource::get()->getText("smb2")->getCharacterSize() + DIST_SPRITE_SPRITE_) + options.game.height + 40;
|
||||
const int W = sprites_.at(i)->getWidth();
|
||||
const int H = sprites_.at(i)->getHeight();
|
||||
const int DX = -(W / 2);
|
||||
const int DY = sprite_max_height_ - H;
|
||||
|
||||
sprites_.at(i)->setPosition({X + DX, Y + DY, W, H});
|
||||
sprites_.at(i)->setPos({X + DX, Y + DY, W, H});
|
||||
sprites_.at(i)->setVelY(SPRITE_DESP_SPEED_);
|
||||
}
|
||||
|
||||
// Recoloca el último sprite, que es el del jugador
|
||||
const int W = sprites_.back()->getWidth();
|
||||
const int X = GAMECANVAS_CENTER_X - (W / 2);
|
||||
// Recoloca el sprite del jugador, que es el último de la lista
|
||||
const int X = (options.game.width - sprites_.back()->getWidth()) / 2;
|
||||
const int Y = sprites_.back()->getPosY() + sprite_max_height_ * 2;
|
||||
sprites_.back()->setPosX(X);
|
||||
sprites_.back()->setPosY(Y);
|
||||
sprites_.back()->setPos(X, Y);
|
||||
sprites_.back()->setCurrentAnimation("walk");
|
||||
}
|
||||
|
||||
@@ -456,7 +455,7 @@ void Ending2::createTexts()
|
||||
const int h = text->getCharacterSize();
|
||||
const int x = GAMECANVAS_CENTER_X;
|
||||
const int dx = -(w / 2);
|
||||
const int y = GAMECANVAS_HEIGHT + (text->getCharacterSize() * (i * 2));
|
||||
const int y = options.game.height + (text->getCharacterSize() * (i * 2));
|
||||
|
||||
// Crea la textura
|
||||
auto texture = std::make_shared<Texture>(Screen::get()->getRenderer());
|
||||
@@ -473,7 +472,7 @@ void Ending2::createTexts()
|
||||
|
||||
// Crea los últimos textos
|
||||
// El primer texto va a continuación del ultimo spriteText
|
||||
const int start = sprite_texts_.back()->getPosY() + text->getCharacterSize() * 15;
|
||||
const int START = sprite_texts_.back()->getPosY() + text->getCharacterSize() * 15;
|
||||
list.clear();
|
||||
list.push_back("THANK YOU");
|
||||
list.push_back("FOR PLAYING!");
|
||||
@@ -486,7 +485,7 @@ void Ending2::createTexts()
|
||||
const int h = text->getCharacterSize();
|
||||
const int x = GAMECANVAS_CENTER_X;
|
||||
const int dx = -(w / 2);
|
||||
const int y = start + (text->getCharacterSize() * (i * 2));
|
||||
const int y = START + (text->getCharacterSize() * (i * 2));
|
||||
|
||||
// Crea la textura
|
||||
auto texture = std::make_shared<Texture>(Screen::get()->getRenderer());
|
||||
|
||||
Reference in New Issue
Block a user