forked from jaildesigner-jailgames/jaildoctors_dilemma
Transició a surface: crec que falta room.cpp
This commit is contained in:
@@ -10,12 +10,12 @@
|
||||
#include "global_events.h" // for check
|
||||
#include "global_inputs.h" // for check
|
||||
#include "jail_audio.h" // for JA_SetVolume, JA_PlayMusic, JA_StopM...
|
||||
#include "s_moving_sprite.h" // for MovingSprite
|
||||
#include "s_moving_sprite.h" // for SMovingSprite
|
||||
#include "options.h" // for Options, options, OptionsVideo, Sect...
|
||||
#include "resource.h" // for Resource
|
||||
#include "screen.h" // for Screen
|
||||
#include "text.h" // for Text
|
||||
#include "surface.h" // for Texture
|
||||
#include "surface.h" // for Surface
|
||||
#include "utils.h" // for Color, stringToColor
|
||||
#include <iostream>
|
||||
|
||||
@@ -31,10 +31,10 @@ Ending2::Ending2()
|
||||
options.section.subsection = Subsection::NONE;
|
||||
|
||||
// Inicializa el vector de colores
|
||||
const std::vector<std::string> color_list = {"white", "yellow", "cyan", "green", "magenta", "red", "blue", "black"};
|
||||
for (const auto &color : color_list)
|
||||
const std::vector<std::string> COLORS = {"white", "yellow", "cyan", "green", "magenta", "red", "blue", "black"};
|
||||
for (const auto &color : COLORS)
|
||||
{
|
||||
colors_.push_back(stringToColor(options.video.palette, color));
|
||||
colors_.push_back(stringToColor(color));
|
||||
}
|
||||
|
||||
// Cambia el color del borde
|
||||
@@ -97,7 +97,7 @@ void Ending2::update()
|
||||
// Dibuja el final en pantalla
|
||||
void Ending2::render()
|
||||
{
|
||||
// Prepara para empezar a dibujar en la textura de juego
|
||||
// Prepara para empezar a dibujar en la surface de juego
|
||||
Screen::get()->start();
|
||||
|
||||
// Limpia la pantalla
|
||||
@@ -325,36 +325,33 @@ void Ending2::updateTexts()
|
||||
// Dibuja los sprites
|
||||
void Ending2::renderSprites()
|
||||
{
|
||||
const Color color = stringToColor(options.video.palette, "red");
|
||||
const Uint8 colorA = stringToColor("red");
|
||||
for (auto sprite : sprites_)
|
||||
{
|
||||
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();
|
||||
sprite->render(1, colorA);
|
||||
}
|
||||
}
|
||||
|
||||
// Pinta el ultimo elemento de otro color
|
||||
const Color c = stringToColor(options.video.palette, "white");
|
||||
sprites_.back()->getTexture()->setColor(c.r, c.g, c.b);
|
||||
sprites_.back()->render();
|
||||
const Uint8 colorB = stringToColor("white");
|
||||
sprites_.back()->render(1, colorB);
|
||||
}
|
||||
|
||||
// Dibuja los sprites con el texto
|
||||
void Ending2::renderSpriteTexts()
|
||||
{
|
||||
const Color color = stringToColor(options.video.palette, "white");
|
||||
const Uint8 color = stringToColor("white");
|
||||
for (auto sprite : sprite_texts_)
|
||||
{
|
||||
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();
|
||||
sprite->render(1, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -424,17 +421,16 @@ void Ending2::createSpriteTexts()
|
||||
// Calcula la posición Y del texto en base a la posición y altura del sprite
|
||||
const int Y = sprites_.at(i)->getPosY() + sprites_.at(i)->getHeight() + DIST_SPRITE_TEXT_;
|
||||
|
||||
// Crea la textura
|
||||
auto texture = std::make_shared<Texture>(Screen::get()->getRenderer());
|
||||
texture->createBlank(W, H);
|
||||
texture->setAsRenderTarget(Screen::get()->getRenderer());
|
||||
texture->setBlendMode(SDL_BLENDMODE_BLEND);
|
||||
// Crea la surface
|
||||
auto surface = std::make_shared<Surface>(Screen::get()->getRenderSurfaceData(), W, H);
|
||||
Screen::get()->setRenderSurfaceData(surface);
|
||||
text->write(0, 0, txt);
|
||||
|
||||
// Crea el sprite
|
||||
SDL_Rect pos = {X, Y, W, H};
|
||||
sprite_texts_.emplace_back(std::make_shared<MovingSprite>(texture, pos));
|
||||
sprite_texts_.emplace_back(std::make_shared<SMovingSprite>(surface, pos));
|
||||
sprite_texts_.back()->setVelY(SPRITE_DESP_SPEED_);
|
||||
Screen::get()->setRenderSurfaceData(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -457,17 +453,16 @@ void Ending2::createTexts()
|
||||
const int dx = -(w / 2);
|
||||
const int y = options.game.height + (text->getCharacterSize() * (i * 2));
|
||||
|
||||
// Crea la textura
|
||||
auto texture = std::make_shared<Texture>(Screen::get()->getRenderer());
|
||||
texture->createBlank(w, h);
|
||||
texture->setAsRenderTarget(Screen::get()->getRenderer());
|
||||
texture->setBlendMode(SDL_BLENDMODE_BLEND);
|
||||
// Crea la surface
|
||||
auto surface = std::make_shared<Surface>(Screen::get()->getRenderSurfaceData(), w, h);
|
||||
Screen::get()->setRenderSurfaceData(surface);
|
||||
text->write(0, 0, list[i]);
|
||||
|
||||
// Crea el sprite
|
||||
SDL_Rect pos = {x + dx, y, w, h};
|
||||
texts_.emplace_back(std::make_shared<MovingSprite>(texture, pos));
|
||||
texts_.emplace_back(std::make_shared<SMovingSprite>(surface, pos));
|
||||
texts_.back()->setVelY(SPRITE_DESP_SPEED_);
|
||||
Screen::get()->setRenderSurfaceData(nullptr);
|
||||
}
|
||||
|
||||
// Crea los últimos textos
|
||||
@@ -487,17 +482,16 @@ void Ending2::createTexts()
|
||||
const int dx = -(w / 2);
|
||||
const int y = START + (text->getCharacterSize() * (i * 2));
|
||||
|
||||
// Crea la textura
|
||||
auto texture = std::make_shared<Texture>(Screen::get()->getRenderer());
|
||||
texture->createBlank(w, h);
|
||||
texture->setAsRenderTarget(Screen::get()->getRenderer());
|
||||
texture->setBlendMode(SDL_BLENDMODE_BLEND);
|
||||
// Crea la surface
|
||||
auto surface = std::make_shared<Surface>(Screen::get()->getRenderSurfaceData(),w, h);
|
||||
Screen::get()->setRenderSurfaceData(surface);
|
||||
text->write(0, 0, list[i]);
|
||||
|
||||
// Crea el sprite
|
||||
SDL_Rect pos = {x + dx, y, w, h};
|
||||
texts_.emplace_back(std::make_shared<MovingSprite>(texture, pos));
|
||||
texts_.emplace_back(std::make_shared<SMovingSprite>(surface, pos));
|
||||
texts_.back()->setVelY(SPRITE_DESP_SPEED_);
|
||||
Screen::get()->setRenderSurfaceData(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -510,7 +504,7 @@ void Ending2::updateFinalFade()
|
||||
|
||||
for (const auto &text : texts_)
|
||||
{
|
||||
text->getTexture()->setColor(colors_.at(INDEX).r, colors_.at(INDEX).g, colors_.at(INDEX).b);
|
||||
//text->getTexture()->setColor(colors_.at(INDEX).r, colors_.at(INDEX).g, colors_.at(INDEX).b);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user