val! ja pinta coses en altres surfaces
This commit is contained in:
@@ -24,13 +24,8 @@ LoadingScreen::LoadingScreen()
|
|||||||
color_loading_screen_sprite_(std::make_shared<SSprite>(color_loading_screen_surface_, 0, 0, color_loading_screen_surface_->getWidth(), color_loading_screen_surface_->getHeight())),
|
color_loading_screen_sprite_(std::make_shared<SSprite>(color_loading_screen_surface_, 0, 0, color_loading_screen_surface_->getWidth(), color_loading_screen_surface_->getHeight())),
|
||||||
screen_surface_(std::make_shared<Surface>(Screen::get()->getRendererSurface(), options.game.width, options.game.height))
|
screen_surface_(std::make_shared<Surface>(Screen::get()->getRendererSurface(), options.game.width, options.game.height))
|
||||||
{
|
{
|
||||||
// Cambia el destino de las surfaces
|
|
||||||
mono_loading_screen_surface_->setSurfaceDest(screen_surface_);
|
|
||||||
color_loading_screen_surface_->setSurfaceDest(screen_surface_);
|
|
||||||
|
|
||||||
// Configura la superficie donde se van a pintar los sprites
|
// Configura la superficie donde se van a pintar los sprites
|
||||||
screen_surface_->setColor(0, 0xFF000000);
|
screen_surface_->clear(stringToColor("white"));
|
||||||
screen_surface_->clear(0);
|
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
options.section.section = Section::LOADING_SCREEN;
|
options.section.section = Section::LOADING_SCREEN;
|
||||||
@@ -141,6 +136,7 @@ void LoadingScreen::updateCounter()
|
|||||||
// Dibuja la pantalla de carga
|
// Dibuja la pantalla de carga
|
||||||
void LoadingScreen::renderLoad()
|
void LoadingScreen::renderLoad()
|
||||||
{
|
{
|
||||||
|
Screen::get()->setRendererSurface(screen_surface_);
|
||||||
loading_first_part_ ? mono_loading_screen_sprite_->render(1, stringToColor("black")) : color_loading_screen_sprite_->render();
|
loading_first_part_ ? mono_loading_screen_sprite_->render(1, stringToColor("black")) : color_loading_screen_sprite_->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,8 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer)
|
|||||||
border_surface_ = std::make_shared<Surface>(nullptr, options.game.width + options.video.border.width * 2, options.game.height + options.video.border.height * 2);
|
border_surface_ = std::make_shared<Surface>(nullptr, options.game.width + options.video.border.width * 2, options.game.height + options.video.border.height * 2);
|
||||||
border_surface_->loadPalette(palettes_.front());
|
border_surface_->loadPalette(palettes_.front());
|
||||||
|
|
||||||
|
renderer_surface_ = std::make_shared<std::shared_ptr<Surface>>(game_surface_);
|
||||||
|
|
||||||
// Establece el modo de video
|
// Establece el modo de video
|
||||||
setVideoMode(options.video.mode);
|
setVideoMode(options.video.mode);
|
||||||
|
|
||||||
@@ -379,7 +381,9 @@ void Screen::resetShaders()
|
|||||||
// Establece el renderizador para las surfaces
|
// Establece el renderizador para las surfaces
|
||||||
void Screen::setRendererSurface(std::shared_ptr<Surface> surface)
|
void Screen::setRendererSurface(std::shared_ptr<Surface> surface)
|
||||||
{
|
{
|
||||||
(surface) ? game_surface_->setSurfaceDest(surface) : game_surface_->setSurfaceDest(nullptr);
|
(surface) ?
|
||||||
|
renderer_surface_ = std::make_shared<std::shared_ptr<Surface>>(surface):
|
||||||
|
renderer_surface_ = std::make_shared<std::shared_ptr<Surface>>(game_surface_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cambia la paleta
|
// Cambia la paleta
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ private:
|
|||||||
SDL_Texture *border_texture_; // Textura donde se dibuja el borde del juego
|
SDL_Texture *border_texture_; // Textura donde se dibuja el borde del juego
|
||||||
std::shared_ptr<Surface> game_surface_; // Surface principal para manejar game_surface_data_
|
std::shared_ptr<Surface> game_surface_; // Surface principal para manejar game_surface_data_
|
||||||
std::shared_ptr<Surface> border_surface_; // Surface para pintar el el borde de la pantalla
|
std::shared_ptr<Surface> border_surface_; // Surface para pintar el el borde de la pantalla
|
||||||
|
std::shared_ptr<std::shared_ptr<Surface>> renderer_surface_;
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int window_width_; // Ancho de la pantalla o ventana
|
int window_width_; // Ancho de la pantalla o ventana
|
||||||
@@ -138,7 +139,7 @@ public:
|
|||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
SDL_Renderer *getRenderer() { return renderer_; }
|
SDL_Renderer *getRenderer() { return renderer_; }
|
||||||
std::shared_ptr<Surface> getRendererSurface() { return game_surface_; }
|
std::shared_ptr<Surface> getRendererSurface() { return (*renderer_surface_); }
|
||||||
|
|
||||||
// Cambia la paleta
|
// Cambia la paleta
|
||||||
void nextPalette();
|
void nextPalette();
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <stdexcept> // for runtime_error
|
#include <stdexcept> // for runtime_error
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
#include "asset.h" // for Asset
|
#include "asset.h" // for Asset
|
||||||
|
#include "screen.h"
|
||||||
#include "gif.h" // for LoadGif, LoadPalette
|
#include "gif.h" // for LoadGif, LoadPalette
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
@@ -183,7 +184,7 @@ void Surface::drawLine(int x1, int y1, int x2, int y2, Uint8 color)
|
|||||||
// Copia una región de la superficie de origen a la de destino
|
// Copia una región de la superficie de origen a la de destino
|
||||||
void Surface::render(int dx, int dy, int sx, int sy, int w, int h)
|
void Surface::render(int dx, int dy, int sx, int sy, int w, int h)
|
||||||
{
|
{
|
||||||
auto surface_data = surface_dest_->getSurfaceData();
|
auto surface_data = Screen::get()->getRendererSurface()->getSurfaceData();
|
||||||
|
|
||||||
// Limitar la región para evitar accesos fuera de rango
|
// Limitar la región para evitar accesos fuera de rango
|
||||||
w = std::min(w, surface_data_->width - sx);
|
w = std::min(w, surface_data_->width - sx);
|
||||||
@@ -207,7 +208,7 @@ void Surface::render(int dx, int dy, int sx, int sy, int w, int h)
|
|||||||
// Copia una región de la superficie de origen a la de destino
|
// Copia una región de la superficie de origen a la de destino
|
||||||
void Surface::render(int x, int y, SDL_Rect *srcRect, SDL_RendererFlip flip)
|
void Surface::render(int x, int y, SDL_Rect *srcRect, SDL_RendererFlip flip)
|
||||||
{
|
{
|
||||||
auto surface_data = surface_dest_->getSurfaceData();
|
auto surface_data = Screen::get()->getRendererSurface()->getSurfaceData();
|
||||||
|
|
||||||
// Determina la región de origen (clip) a renderizar
|
// Determina la región de origen (clip) a renderizar
|
||||||
int sx = (srcRect) ? srcRect->x : 0;
|
int sx = (srcRect) ? srcRect->x : 0;
|
||||||
@@ -247,7 +248,7 @@ void Surface::render(int x, int y, SDL_Rect *srcRect, SDL_RendererFlip flip)
|
|||||||
// Copia una región de la superficie de origen a la de destino
|
// Copia una región de la superficie de origen a la de destino
|
||||||
void Surface::render(SDL_Rect *srcRect, SDL_Rect *dstRect, SDL_RendererFlip flip)
|
void Surface::render(SDL_Rect *srcRect, SDL_Rect *dstRect, SDL_RendererFlip flip)
|
||||||
{
|
{
|
||||||
auto surface_data = surface_dest_->getSurfaceData();
|
auto surface_data = Screen::get()->getRendererSurface()->getSurfaceData();
|
||||||
|
|
||||||
// Si srcRect es nullptr, tomar toda la superficie fuente
|
// Si srcRect es nullptr, tomar toda la superficie fuente
|
||||||
int sx = (srcRect) ? srcRect->x : 0;
|
int sx = (srcRect) ? srcRect->x : 0;
|
||||||
@@ -303,7 +304,7 @@ void Surface::render(SDL_Rect *srcRect, SDL_Rect *dstRect, SDL_RendererFlip flip
|
|||||||
// Copia una región de la SurfaceData de origen a la SurfaceData de destino reemplazando un color por otro
|
// Copia una región de la SurfaceData de origen a la SurfaceData de destino reemplazando un color por otro
|
||||||
void Surface::renderWithColorReplace(int x, int y, Uint8 source_color, Uint8 target_color, SDL_Rect *srcRect, SDL_RendererFlip flip)
|
void Surface::renderWithColorReplace(int x, int y, Uint8 source_color, Uint8 target_color, SDL_Rect *srcRect, SDL_RendererFlip flip)
|
||||||
{
|
{
|
||||||
auto surface_data = surface_dest_->getSurfaceData();
|
auto surface_data = Screen::get()->getRendererSurface()->getSurfaceData();
|
||||||
|
|
||||||
// Determina la región de origen (clip) a renderizar
|
// Determina la región de origen (clip) a renderizar
|
||||||
int sx = (srcRect) ? srcRect->x : 0;
|
int sx = (srcRect) ? srcRect->x : 0;
|
||||||
|
|||||||
@@ -316,7 +316,7 @@ void Title::fillSurface()
|
|||||||
Screen::get()->setRendererSurface(bg_surface_);
|
Screen::get()->setRendererSurface(bg_surface_);
|
||||||
|
|
||||||
// Rellena la textura de color
|
// Rellena la textura de color
|
||||||
Screen::get()->clearSurface(4);
|
bg_surface_->clear(1);
|
||||||
|
|
||||||
// Pinta el gráfico del titulo a partir del sprite
|
// Pinta el gráfico del titulo a partir del sprite
|
||||||
title_logo_sprite_->render();
|
title_logo_sprite_->render();
|
||||||
|
|||||||
Reference in New Issue
Block a user