forked from jaildesigner-jailgames/jaildoctors_dilemma
canvi de pc
This commit is contained in:
@@ -152,6 +152,10 @@ std::string Asset::getTypeName(AssetType type) const
|
|||||||
return "TILEMAP";
|
return "TILEMAP";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case AssetType::PALETTE:
|
||||||
|
return "PALETTE";
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return "ERROR";
|
return "ERROR";
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ enum class AssetType : int
|
|||||||
FONT,
|
FONT,
|
||||||
ROOM,
|
ROOM,
|
||||||
TILEMAP,
|
TILEMAP,
|
||||||
|
PALETTE,
|
||||||
MAX_ASSET_TYPE
|
MAX_ASSET_TYPE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ void Credits::fillTexture()
|
|||||||
|
|
||||||
// Rellena la textura de texto
|
// Rellena la textura de texto
|
||||||
Screen::get()->setRenderSurfaceData(text_surface_);
|
Screen::get()->setRenderSurfaceData(text_surface_);
|
||||||
Screen::get()->clear(stringToColor("black"));
|
Screen::get()->clearSurface(stringToColor("black"));
|
||||||
|
|
||||||
auto text = Resource::get()->getText("smb2");
|
auto text = Resource::get()->getText("smb2");
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ void Credits::fillTexture()
|
|||||||
|
|
||||||
// Rellena la textura que cubre el texto con color transparente
|
// Rellena la textura que cubre el texto con color transparente
|
||||||
Screen::get()->setRenderSurfaceData(text_surface_);
|
Screen::get()->setRenderSurfaceData(text_surface_);
|
||||||
Screen::get()->clear(stringToColor("transparent"));
|
Screen::get()->clearSurface(stringToColor("transparent"));
|
||||||
|
|
||||||
// Los primeros 8 pixels crea una malla
|
// Los primeros 8 pixels crea una malla
|
||||||
auto surface = Screen::get()->getRenderSurfaceData();
|
auto surface = Screen::get()->getRenderSurfaceData();
|
||||||
@@ -252,7 +252,7 @@ void Credits::render()
|
|||||||
Screen::get()->start();
|
Screen::get()->start();
|
||||||
|
|
||||||
// Limpia la pantalla
|
// Limpia la pantalla
|
||||||
Screen::get()->clear(1);
|
Screen::get()->clearSurface(1);
|
||||||
|
|
||||||
if (counter_ < 1150)
|
if (counter_ < 1150)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -394,11 +394,11 @@ bool Director::setFileList()
|
|||||||
Asset::get()->add(prefix + "/data/font/8bithud.txt", AssetType::FONT);
|
Asset::get()->add(prefix + "/data/font/8bithud.txt", AssetType::FONT);
|
||||||
|
|
||||||
// Paletas
|
// Paletas
|
||||||
Asset::get()->add(prefix + "/data/palette/ruzx-spectrum-8x.gif", AssetType::DATA);
|
Asset::get()->add(prefix + "/data/palette/zx-spectrum-8x.gif", AssetType::PALETTE);
|
||||||
Asset::get()->add(prefix + "/data/palette/ruzx-spectrum-revision-2-8x.gif", AssetType::DATA);
|
Asset::get()->add(prefix + "/data/palette/zx-spectrum-adjusted-8x.gif", AssetType::PALETTE);
|
||||||
Asset::get()->add(prefix + "/data/palette/zxarne-5-2-8x.gif", AssetType::DATA);
|
Asset::get()->add(prefix + "/data/palette/ruzx-spectrum-8x.gif", AssetType::PALETTE);
|
||||||
Asset::get()->add(prefix + "/data/palette/zx-spectrum-8x.gif", AssetType::DATA);
|
Asset::get()->add(prefix + "/data/palette/ruzx-spectrum-revision-2-8x.gif", AssetType::PALETTE);
|
||||||
Asset::get()->add(prefix + "/data/palette/zx-spectrum-adjusted-8x.gif", AssetType::DATA);
|
Asset::get()->add(prefix + "/data/palette/zxarne-5-2-8x.gif", AssetType::PALETTE);
|
||||||
|
|
||||||
// Shaders
|
// Shaders
|
||||||
Asset::get()->add(prefix + "/data/shaders/crtpi_192.glsl", AssetType::DATA);
|
Asset::get()->add(prefix + "/data/shaders/crtpi_192.glsl", AssetType::DATA);
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ void Ending::render()
|
|||||||
Screen::get()->start();
|
Screen::get()->start();
|
||||||
|
|
||||||
// Limpia la pantalla
|
// Limpia la pantalla
|
||||||
Screen::get()->clear(stringToColor("yellow"));
|
Screen::get()->clearSurface(stringToColor("yellow"));
|
||||||
|
|
||||||
// Dibuja las imagenes de la escena
|
// Dibuja las imagenes de la escena
|
||||||
sprite_pics_.at(current_scene_).image_sprite->render();
|
sprite_pics_.at(current_scene_).image_sprite->render();
|
||||||
@@ -185,7 +185,7 @@ void Ending::iniTexts()
|
|||||||
Screen::get()->setRenderSurfaceData(st.cover_surface);
|
Screen::get()->setRenderSurfaceData(st.cover_surface);
|
||||||
|
|
||||||
// Rellena la cover_surface con color transparente
|
// Rellena la cover_surface con color transparente
|
||||||
Screen::get()->clear(stringToColor("transparent"));
|
Screen::get()->clearSurface(stringToColor("transparent"));
|
||||||
|
|
||||||
// Crea una malla de 8 pixels de alto
|
// Crea una malla de 8 pixels de alto
|
||||||
auto surface = Screen::get()->getRenderSurfaceData();
|
auto surface = Screen::get()->getRenderSurfaceData();
|
||||||
@@ -252,7 +252,7 @@ void Ending::iniPics()
|
|||||||
Screen::get()->setRenderSurfaceData(sp.cover_surface);
|
Screen::get()->setRenderSurfaceData(sp.cover_surface);
|
||||||
|
|
||||||
// Rellena la cover_surface con color transparente
|
// Rellena la cover_surface con color transparente
|
||||||
Screen::get()->clear(stringToColor("transparent"));
|
Screen::get()->clearSurface(stringToColor("transparent"));
|
||||||
|
|
||||||
// Crea una malla en los primeros 8 pixels
|
// Crea una malla en los primeros 8 pixels
|
||||||
auto surface = Screen::get()->getRenderSurfaceData();
|
auto surface = Screen::get()->getRenderSurfaceData();
|
||||||
@@ -473,7 +473,7 @@ void Ending::fillCoverTexture()
|
|||||||
{
|
{
|
||||||
// Rellena la textura que cubre el texto con color transparente
|
// Rellena la textura que cubre el texto con color transparente
|
||||||
Screen::get()->setRenderSurfaceData(cover_surface_);
|
Screen::get()->setRenderSurfaceData(cover_surface_);
|
||||||
Screen::get()->clear(stringToColor("transparent"));
|
Screen::get()->clearSurface(stringToColor("transparent"));
|
||||||
|
|
||||||
// Los primeros 8 pixels crea una malla
|
// Los primeros 8 pixels crea una malla
|
||||||
const Uint8 color = stringToColor("black");
|
const Uint8 color = stringToColor("black");
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ void Ending2::render()
|
|||||||
Screen::get()->start();
|
Screen::get()->start();
|
||||||
|
|
||||||
// Limpia la pantalla
|
// Limpia la pantalla
|
||||||
Screen::get()->clear(stringToColor("black"));
|
Screen::get()->clearSurface(stringToColor("black"));
|
||||||
|
|
||||||
// Dibuja los sprites
|
// Dibuja los sprites
|
||||||
renderSprites();
|
renderSprites();
|
||||||
|
|||||||
@@ -565,7 +565,7 @@ void Game::fillRoomNameTexture()
|
|||||||
Screen::get()->setRenderSurfaceData(room_name_surface_);
|
Screen::get()->setRenderSurfaceData(room_name_surface_);
|
||||||
|
|
||||||
// Rellena la textura de color
|
// Rellena la textura de color
|
||||||
Screen::get()->clear(stringToColor("white"));
|
Screen::get()->clearSurface(stringToColor("white"));
|
||||||
|
|
||||||
// Escribe el texto en la textura
|
// Escribe el texto en la textura
|
||||||
auto text = Resource::get()->getText("smb2");
|
auto text = Resource::get()->getText("smb2");
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ void GameOver::render()
|
|||||||
constexpr int Y = 32;
|
constexpr int Y = 32;
|
||||||
|
|
||||||
Screen::get()->start();
|
Screen::get()->start();
|
||||||
Screen::get()->clear(1);
|
Screen::get()->clearSurface(1);
|
||||||
|
|
||||||
auto text = Resource::get()->getText("smb2");
|
auto text = Resource::get()->getText("smb2");
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ namespace globalInputs
|
|||||||
// Cambia la paleta de colores
|
// Cambia la paleta de colores
|
||||||
void switchPalette()
|
void switchPalette()
|
||||||
{
|
{
|
||||||
options.video.palette = options.video.palette == Palette::ZXSPECTRUM ? Palette::ZXARNE : Palette::ZXSPECTRUM;
|
//options.video.palette = options.video.palette == Palette::ZXSPECTRUM ? Palette::ZXARNE : Palette::ZXSPECTRUM;
|
||||||
|
Screen::get()->nextPalette();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cambia de seccion
|
// Cambia de seccion
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ void LoadingScreen::updateCounter()
|
|||||||
// Dibuja la pantalla de carga
|
// Dibuja la pantalla de carga
|
||||||
void LoadingScreen::renderLoad()
|
void LoadingScreen::renderLoad()
|
||||||
{
|
{
|
||||||
loading_first_part_ ? mono_loading_screen_sprite_->render() : color_loading_screen_sprite_->render();
|
loading_first_part_ ? mono_loading_screen_sprite_->render(1, stringToColor("black")) : color_loading_screen_sprite_->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja el efecto de carga en el borde
|
// Dibuja el efecto de carga en el borde
|
||||||
@@ -149,7 +149,7 @@ void LoadingScreen::renderBorder()
|
|||||||
{
|
{
|
||||||
// Pinta el borde de colro azul
|
// Pinta el borde de colro azul
|
||||||
Uint8 color = stringToColor("blue");
|
Uint8 color = stringToColor("blue");
|
||||||
Screen::get()->clear(color);
|
Screen::get()->clearSurface(color);
|
||||||
|
|
||||||
// Añade lineas amarillas
|
// Añade lineas amarillas
|
||||||
color = stringToColor("yellow");
|
color = stringToColor("yellow");
|
||||||
@@ -203,6 +203,7 @@ void LoadingScreen::render()
|
|||||||
|
|
||||||
// Prepara para empezar a dibujar en la textura de juego
|
// Prepara para empezar a dibujar en la textura de juego
|
||||||
Screen::get()->start();
|
Screen::get()->start();
|
||||||
|
Screen::get()->clearSurface(stringToColor("white"));
|
||||||
|
|
||||||
// Copia la surface a la surface de Screen
|
// Copia la surface a la surface de Screen
|
||||||
screen_surface_->render(0, 0);
|
screen_surface_->render(0, 0);
|
||||||
|
|||||||
@@ -221,14 +221,14 @@ void Logo::render()
|
|||||||
Screen::get()->start();
|
Screen::get()->start();
|
||||||
|
|
||||||
// Limpia la pantalla
|
// Limpia la pantalla
|
||||||
Screen::get()->clear();
|
Screen::get()->clearSurface();
|
||||||
|
|
||||||
// Dibuja los objetos
|
// Dibuja los objetos
|
||||||
for (const auto &s : jailgames_sprite_)
|
for (const auto &s : jailgames_sprite_)
|
||||||
{
|
{
|
||||||
s->render();
|
s->render(1, stringToColor("white"));
|
||||||
}
|
}
|
||||||
since_1998_sprite_->render();
|
since_1998_sprite_->render(1, stringToColor("white"));
|
||||||
|
|
||||||
// Vuelca el contenido del renderizador en pantalla
|
// Vuelca el contenido del renderizador en pantalla
|
||||||
Screen::get()->render();
|
Screen::get()->render();
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ void Notifier::update()
|
|||||||
{
|
{
|
||||||
// const float step = ((float)notifications_[i].counter / notifications_[i].travel_dist);
|
// const float step = ((float)notifications_[i].counter / notifications_[i].travel_dist);
|
||||||
// const int alpha = 255 * step;
|
// const int alpha = 255 * step;
|
||||||
//constexpr int ALPHA = 255;
|
// constexpr int ALPHA = 255;
|
||||||
|
|
||||||
if (options.notifications.getVerticalPosition() == NotificationPosition::TOP)
|
if (options.notifications.getVerticalPosition() == NotificationPosition::TOP)
|
||||||
{
|
{
|
||||||
@@ -96,12 +96,12 @@ void Notifier::update()
|
|||||||
{
|
{
|
||||||
notifications_[i].rect.y--;
|
notifications_[i].rect.y--;
|
||||||
}
|
}
|
||||||
//notifications_[i].surface->setAlpha(ALPHA);
|
// notifications_[i].surface->setAlpha(ALPHA);
|
||||||
|
|
||||||
if (notifications_[i].rect.y == notifications_[i].y)
|
if (notifications_[i].rect.y == notifications_[i].y)
|
||||||
{
|
{
|
||||||
notifications_[i].state = NotificationStatus::STAY;
|
notifications_[i].state = NotificationStatus::STAY;
|
||||||
//notifications_[i].surface->setAlpha(255);
|
// notifications_[i].surface->setAlpha(255);
|
||||||
notifications_[i].counter = 0;
|
notifications_[i].counter = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -119,7 +119,7 @@ void Notifier::update()
|
|||||||
|
|
||||||
// const float step = (notifications_[i].counter / (float)notifications_[i].travel_dist);
|
// const float step = (notifications_[i].counter / (float)notifications_[i].travel_dist);
|
||||||
// const int ALPHA = 255 * (1 - step);
|
// const int ALPHA = 255 * (1 - step);
|
||||||
//constexpr int ALPHA = 255;
|
// constexpr int ALPHA = 255;
|
||||||
|
|
||||||
if (options.notifications.getVerticalPosition() == NotificationPosition::TOP)
|
if (options.notifications.getVerticalPosition() == NotificationPosition::TOP)
|
||||||
{
|
{
|
||||||
@@ -129,7 +129,7 @@ void Notifier::update()
|
|||||||
{
|
{
|
||||||
notifications_[i].rect.y++;
|
notifications_[i].rect.y++;
|
||||||
}
|
}
|
||||||
//notifications_[i].surface->setAlpha(ALPHA);
|
// notifications_[i].surface->setAlpha(ALPHA);
|
||||||
|
|
||||||
if (notifications_[i].rect.y == notifications_[i].y - notifications_[i].travel_dist)
|
if (notifications_[i].rect.y == notifications_[i].y - notifications_[i].travel_dist)
|
||||||
{
|
{
|
||||||
@@ -259,7 +259,7 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, in
|
|||||||
|
|
||||||
else if (shape == NotificationShape::SQUARED)
|
else if (shape == NotificationShape::SQUARED)
|
||||||
{
|
{
|
||||||
Screen::get()->clear(bg_color_);
|
Screen::get()->clearSurface(bg_color_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja el icono de la notificación
|
// Dibuja el icono de la notificación
|
||||||
@@ -294,7 +294,7 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, in
|
|||||||
n.sprite = std::make_shared<SSprite>(n.surface, n.rect);
|
n.sprite = std::make_shared<SSprite>(n.surface, n.rect);
|
||||||
|
|
||||||
// Deja la notificación invisible
|
// Deja la notificación invisible
|
||||||
//n.surface->setAlpha(0);
|
// n.surface->setAlpha(0);
|
||||||
|
|
||||||
// Añade la notificación a la lista
|
// Añade la notificación a la lista
|
||||||
notifications_.emplace_back(n);
|
notifications_.emplace_back(n);
|
||||||
|
|||||||
@@ -405,17 +405,16 @@ void Resource::renderProgress()
|
|||||||
constexpr int BAR_HEIGHT = 10;
|
constexpr int BAR_HEIGHT = 10;
|
||||||
const int bar_position = options.game.height - BAR_HEIGHT - Y_PADDING;
|
const int bar_position = options.game.height - BAR_HEIGHT - Y_PADDING;
|
||||||
Screen::get()->start();
|
Screen::get()->start();
|
||||||
Screen::get()->clear(4);
|
Screen::get()->clearSurface();
|
||||||
|
|
||||||
//SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 255, 255, 255, 255);
|
auto surface = std::make_shared<Surface>(Screen::get()->getRenderSurfaceData(), 1, 1);
|
||||||
//
|
const int wired_bar_width = options.game.width - (X_PADDING * 2);
|
||||||
//const int wired_bar_width = options.game.width - (X_PADDING * 2);
|
SDL_Rect rect_wired = {X_PADDING, bar_position, wired_bar_width, X_PADDING};
|
||||||
//SDL_Rect rect_wired = {X_PADDING, bar_position, wired_bar_width, X_PADDING};
|
surface->fillRect(Screen::get()->getRenderSurfaceData(), &rect_wired, stringToColor("blue"));
|
||||||
//SDL_RenderDrawRect(Screen::get()->getRenderer(), &rect_wired);
|
|
||||||
//
|
const int full_bar_width = wired_bar_width * count_.getPercentage();
|
||||||
//const int full_bar_width = wired_bar_width * count_.getPercentage();
|
SDL_Rect rect_full = {X_PADDING, bar_position, full_bar_width, X_PADDING};
|
||||||
//SDL_Rect rect_full = {X_PADDING, bar_position, full_bar_width, X_PADDING};
|
surface->fillRect(Screen::get()->getRenderSurfaceData(), &rect_full, stringToColor("white"));
|
||||||
//SDL_RenderFillRect(Screen::get()->getRenderer(), &rect_full);
|
|
||||||
|
|
||||||
Screen::get()->renderWithoutNotifier();
|
Screen::get()->renderWithoutNotifier();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -475,7 +475,7 @@ void Room::fillMapTexture()
|
|||||||
{
|
{
|
||||||
const Uint8 color = stringToColor(bg_color_);
|
const Uint8 color = stringToColor(bg_color_);
|
||||||
Screen::get()->setRenderSurfaceData(map_surface_);
|
Screen::get()->setRenderSurfaceData(map_surface_);
|
||||||
Screen::get()->clear(color);
|
Screen::get()->clearSurface(color);
|
||||||
|
|
||||||
// Los tileSetFiles son de 20x20 tiles. El primer tile es el 0. Cuentan hacia la derecha y hacia abajo
|
// Los tileSetFiles son de 20x20 tiles. El primer tile es el 0. Cuentan hacia la derecha y hacia abajo
|
||||||
|
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ void Scoreboard::fillTexture()
|
|||||||
Screen::get()->setRenderSurfaceData(surface_);
|
Screen::get()->setRenderSurfaceData(surface_);
|
||||||
|
|
||||||
// Limpia la textura
|
// Limpia la textura
|
||||||
Screen::get()->clear(stringToColor("black"));
|
Screen::get()->clearSurface(stringToColor("black"));
|
||||||
|
|
||||||
// Anclas
|
// Anclas
|
||||||
constexpr int LINE1 = BLOCK;
|
constexpr int LINE1 = BLOCK;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
#include "notifier.h" // Para Notify
|
#include "notifier.h" // Para Notify
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "mouse.h"
|
#include "mouse.h"
|
||||||
// #include "surface.h"
|
#include "surface.h"
|
||||||
|
|
||||||
// [SINGLETON]
|
// [SINGLETON]
|
||||||
Screen *Screen::screen_ = nullptr;
|
Screen *Screen::screen_ = nullptr;
|
||||||
@@ -39,7 +39,8 @@ Screen *Screen::get()
|
|||||||
// Constructor
|
// Constructor
|
||||||
Screen::Screen(SDL_Window *window, SDL_Renderer *renderer)
|
Screen::Screen(SDL_Window *window, SDL_Renderer *renderer)
|
||||||
: window_(window),
|
: window_(window),
|
||||||
renderer_(renderer)
|
renderer_(renderer),
|
||||||
|
palettes_(Asset::get()->getListByType(AssetType::PALETTE))
|
||||||
{
|
{
|
||||||
// Ajusta los tamaños
|
// Ajusta los tamaños
|
||||||
adjustGameCanvasRect();
|
adjustGameCanvasRect();
|
||||||
@@ -53,7 +54,7 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer)
|
|||||||
|
|
||||||
// Crea la textura donde se dibujan los graficos del juego
|
// Crea la textura donde se dibujan los graficos del juego
|
||||||
game_texture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, options.game.width, options.game.height);
|
game_texture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, options.game.width, options.game.height);
|
||||||
//game_texture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, options.game.width, options.game.height);
|
// game_texture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, options.game.width, options.game.height);
|
||||||
if (!game_texture_)
|
if (!game_texture_)
|
||||||
{
|
{
|
||||||
// Registrar el error si está habilitado
|
// Registrar el error si está habilitado
|
||||||
@@ -65,7 +66,7 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer)
|
|||||||
|
|
||||||
// Crea la textura donde se dibuja el borde que rodea el area de juego
|
// Crea la textura donde se dibuja el borde que rodea el area de juego
|
||||||
border_texture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, options.game.width + options.video.border.width * 2, options.game.height + options.video.border.height * 2);
|
border_texture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, options.game.width + options.video.border.width * 2, options.game.height + options.video.border.height * 2);
|
||||||
//border_texture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, options.game.width + options.video.border.width * 2, options.game.height + options.video.border.height * 2);
|
// border_texture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, options.game.width + options.video.border.width * 2, options.game.height + options.video.border.height * 2);
|
||||||
if (!border_texture_)
|
if (!border_texture_)
|
||||||
{
|
{
|
||||||
// Registrar el error si está habilitado
|
// Registrar el error si está habilitado
|
||||||
@@ -77,11 +78,11 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer)
|
|||||||
|
|
||||||
// Crea la surface donde se dibujan los graficos del juego
|
// Crea la surface donde se dibujan los graficos del juego
|
||||||
game_surface_ = std::make_shared<Surface>(nullptr, options.game.width, options.game.height);
|
game_surface_ = std::make_shared<Surface>(nullptr, options.game.width, options.game.height);
|
||||||
game_surface_->loadPalette(Asset::get()->get("zx-spectrum-8x.gif"));
|
game_surface_->loadPalette(palettes_.front());
|
||||||
|
|
||||||
// Crea la surface donde se dibujan los graficos del juego
|
// Crea la surface donde se dibujan los graficos del juego
|
||||||
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(Asset::get()->get("zx-spectrum-8x.gif"));
|
border_surface_->loadPalette(palettes_.front());
|
||||||
|
|
||||||
// Establece el modo de video
|
// Establece el modo de video
|
||||||
setVideoMode(options.video.mode);
|
setVideoMode(options.video.mode);
|
||||||
@@ -106,7 +107,7 @@ void Screen::clear(Color color)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Limpia la pantalla
|
// Limpia la pantalla
|
||||||
void Screen::clear(Uint8 index)
|
void Screen::clearSurface(Uint8 index)
|
||||||
{
|
{
|
||||||
game_surface_->clear(index);
|
game_surface_->clear(index);
|
||||||
}
|
}
|
||||||
@@ -125,7 +126,7 @@ void Screen::render()
|
|||||||
game_surface_->copyToTexture(renderer_, game_texture_);
|
game_surface_->copyToTexture(renderer_, game_texture_);
|
||||||
|
|
||||||
// Renderiza sobre gameCanvas los overlays
|
// Renderiza sobre gameCanvas los overlays
|
||||||
//renderNotifications();
|
// renderNotifications();
|
||||||
|
|
||||||
// Si está el borde activo, vuelca gameCanvas sobre borderCanvas
|
// Si está el borde activo, vuelca gameCanvas sobre borderCanvas
|
||||||
if (options.video.border.enabled)
|
if (options.video.border.enabled)
|
||||||
@@ -140,6 +141,9 @@ void Screen::render()
|
|||||||
// Vuelca el contenido del renderizador en pantalla
|
// Vuelca el contenido del renderizador en pantalla
|
||||||
void Screen::renderWithoutNotifier()
|
void Screen::renderWithoutNotifier()
|
||||||
{
|
{
|
||||||
|
// Copia la surface a game_texture_
|
||||||
|
game_surface_->copyToTexture(renderer_, game_texture_);
|
||||||
|
|
||||||
// Si está el borde activo, vuelca gameCanvas sobre borderCanvas
|
// Si está el borde activo, vuelca gameCanvas sobre borderCanvas
|
||||||
if (options.video.border.enabled)
|
if (options.video.border.enabled)
|
||||||
{
|
{
|
||||||
@@ -374,3 +378,16 @@ void Screen::setRenderSurfaceData(std::shared_ptr<Surface> surface)
|
|||||||
{
|
{
|
||||||
(surface) ? game_surface_->redirectSurfaceDataTo(surface) : game_surface_->restoreOriginalSurfaceData();
|
(surface) ? game_surface_->redirectSurfaceDataTo(surface) : game_surface_->restoreOriginalSurfaceData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cambia la paleta
|
||||||
|
void Screen::nextPalette()
|
||||||
|
{
|
||||||
|
++current_palette_;
|
||||||
|
if (current_palette_ == static_cast<int>(palettes_.size()))
|
||||||
|
{
|
||||||
|
current_palette_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
game_surface_->loadPalette(palettes_.at(current_palette_));
|
||||||
|
border_surface_->loadPalette(palettes_.at(current_palette_));
|
||||||
|
}
|
||||||
@@ -38,6 +38,8 @@ private:
|
|||||||
int window_height_; // Alto de la pantalla o ventana
|
int window_height_; // Alto de la pantalla o ventana
|
||||||
SDL_Rect game_rect_; // Coordenadas donde se va a dibujar la textura del juego sobre la pantalla o ventana
|
SDL_Rect game_rect_; // Coordenadas donde se va a dibujar la textura del juego sobre la pantalla o ventana
|
||||||
Uint8 border_color_; // Color del borde añadido a la textura de juego para rellenar la pantalla
|
Uint8 border_color_; // Color del borde añadido a la textura de juego para rellenar la pantalla
|
||||||
|
std::vector<std::string> palettes_; // Listado de los ficheros de paletta disponibles
|
||||||
|
Uint8 current_palette_ = 0; // Indice para el vector de paletas
|
||||||
|
|
||||||
// Dibuja las notificaciones
|
// Dibuja las notificaciones
|
||||||
void renderNotifications();
|
void renderNotifications();
|
||||||
@@ -78,7 +80,7 @@ public:
|
|||||||
|
|
||||||
// Limpia la pantalla
|
// Limpia la pantalla
|
||||||
void clear(Color color = {0x00, 0x00, 0x00});
|
void clear(Color color = {0x00, 0x00, 0x00});
|
||||||
void clear(Uint8 index);
|
void clearSurface(Uint8 index = 1);
|
||||||
|
|
||||||
// Prepara para empezar a dibujar en la textura de juego
|
// Prepara para empezar a dibujar en la textura de juego
|
||||||
void start();
|
void start();
|
||||||
@@ -139,4 +141,7 @@ public:
|
|||||||
|
|
||||||
// Prepara para empezar a dibujar en la textura del borde
|
// Prepara para empezar a dibujar en la textura del borde
|
||||||
void startDrawOnBorder() { setRenderSurfaceData(border_surface_); }
|
void startDrawOnBorder() { setRenderSurfaceData(border_surface_); }
|
||||||
|
|
||||||
|
// Cambia la paleta
|
||||||
|
void nextPalette();
|
||||||
};
|
};
|
||||||
@@ -10,25 +10,45 @@
|
|||||||
#include "asset.h" // for Asset
|
#include "asset.h" // for Asset
|
||||||
#include "gif.h" // for LoadGif, LoadPalette
|
#include "gif.h" // for LoadGif, LoadPalette
|
||||||
|
|
||||||
Surface::Surface(std::shared_ptr<SurfaceData> surface_dest, int w, int h)
|
Surface::Surface(std::shared_ptr<SurfaceData> surface_data_dest, int w, int h)
|
||||||
: surface_data_dest_(surface_dest),
|
|
||||||
surface_data_(std::make_shared<SurfaceData>(w, h)),
|
|
||||||
original_surface_data_(surface_data_),
|
|
||||||
transparent_color_(0) {}
|
|
||||||
|
|
||||||
Surface::Surface(std::shared_ptr<SurfaceData> surface_dest, const std::string &file_path)
|
|
||||||
: surface_data_dest_(surface_dest),
|
|
||||||
transparent_color_(0)
|
|
||||||
{
|
{
|
||||||
// Carga la SurfaceData
|
// Inicializar surface_data_ con un nuevo SurfaceData
|
||||||
SurfaceData loadedData = loadSurface(file_path);
|
surface_data_ = std::make_shared<SurfaceData>(w, h);
|
||||||
surface_data_ = std::make_shared<SurfaceData>(std::move(loadedData));
|
|
||||||
|
|
||||||
// Inicializa el puntero original
|
// Guardar la copia original de surface_data_
|
||||||
original_surface_data_ = surface_data_;
|
original_surface_data_ = surface_data_;
|
||||||
|
|
||||||
|
// Si se proporciona un surface_data_dest, enlazamos surface_data_dest_
|
||||||
|
if (surface_data_dest)
|
||||||
|
{
|
||||||
|
surface_data_dest_ = surface_data_dest;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Si no se pasa otro puntero, surface_data_dest_ apunta al propio surface_data_
|
||||||
|
surface_data_dest_ = surface_data_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Surface::~Surface() {}
|
Surface::Surface(std::shared_ptr<SurfaceData> surface_data_dest, const std::string &file_path)
|
||||||
|
{
|
||||||
|
// Cargar surface_data_ desde el archivo
|
||||||
|
surface_data_ = std::make_shared<SurfaceData>(loadSurface(file_path));
|
||||||
|
|
||||||
|
// Guardar la copia original de surface_data_
|
||||||
|
original_surface_data_ = surface_data_;
|
||||||
|
|
||||||
|
// Si se proporciona un surface_data_dest, enlazamos surface_data_dest_
|
||||||
|
if (surface_data_dest)
|
||||||
|
{
|
||||||
|
surface_data_dest_ = surface_data_dest;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Si no se pasa otro puntero, surface_data_dest_ apunta al propio surface_data_
|
||||||
|
surface_data_dest_ = surface_data_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Carga una superficie desde un archivo
|
// Carga una superficie desde un archivo
|
||||||
SurfaceData Surface::loadSurface(const std::string &file_path)
|
SurfaceData Surface::loadSurface(const std::string &file_path)
|
||||||
@@ -335,8 +355,6 @@ void Surface::renderWithColorReplace(int x, int y, Uint8 source_color, Uint8 tar
|
|||||||
// 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);
|
||||||
h = std::min(h, surface_data_->height - sy);
|
h = std::min(h, surface_data_->height - sy);
|
||||||
w = std::min(w, surface_data_dest_->width - x);
|
|
||||||
h = std::min(h, surface_data_dest_->height - y);
|
|
||||||
|
|
||||||
// Renderiza píxel por píxel aplicando el flip si es necesario
|
// Renderiza píxel por píxel aplicando el flip si es necesario
|
||||||
for (int iy = 0; iy < h; ++iy)
|
for (int iy = 0; iy < h; ++iy)
|
||||||
@@ -351,6 +369,12 @@ void Surface::renderWithColorReplace(int x, int y, Uint8 source_color, Uint8 tar
|
|||||||
int dest_x = x + ix;
|
int dest_x = x + ix;
|
||||||
int dest_y = y + iy;
|
int dest_y = y + iy;
|
||||||
|
|
||||||
|
// Verifica que las coordenadas de destino estén dentro de los límites
|
||||||
|
if (dest_x < 0 || dest_y < 0 || dest_x >= surface_data_dest_->width || dest_y >= surface_data_dest_->height)
|
||||||
|
{
|
||||||
|
continue; // Saltar píxeles fuera del rango del destino
|
||||||
|
}
|
||||||
|
|
||||||
// Copia el píxel si no es transparente
|
// Copia el píxel si no es transparente
|
||||||
Uint8 color = surface_data_->data[src_x + src_y * surface_data_->width];
|
Uint8 color = surface_data_->data[src_x + src_y * surface_data_->width];
|
||||||
if (color != transparent_color_)
|
if (color != transparent_color_)
|
||||||
@@ -430,3 +454,28 @@ bool Surface::fadePalette()
|
|||||||
// Devolver si el índice 15 coincide con el índice 0
|
// Devolver si el índice 15 coincide con el índice 0
|
||||||
return palette_[15] == palette_[0];
|
return palette_[15] == palette_[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Método para redirigir surface_data_ al surface_data_ de otro objeto
|
||||||
|
void Surface::redirectSurfaceDataTo(const std::shared_ptr<SurfaceData>& newSurfaceData)
|
||||||
|
{
|
||||||
|
// Guardar el surface_data_ original para poder restaurarlo
|
||||||
|
original_surface_data_ = surface_data_;
|
||||||
|
|
||||||
|
// Redirigir surface_data_ al nuevo surface_data_
|
||||||
|
surface_data_ = newSurfaceData;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Surface::redirectSurfaceDataTo(const std::shared_ptr<Surface> &otherSurface)
|
||||||
|
{
|
||||||
|
// Guardar el surface_data_ original para poder restaurarlo
|
||||||
|
original_surface_data_ = surface_data_;
|
||||||
|
|
||||||
|
// Redirigir surface_data_ al nuevo surface_data_
|
||||||
|
surface_data_ = otherSurface->getSurfaceData();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Método para restaurar surface_data_ al valor original
|
||||||
|
void Surface::restoreOriginalSurfaceData()
|
||||||
|
{
|
||||||
|
surface_data_ = original_surface_data_;
|
||||||
|
}
|
||||||
|
|||||||
@@ -68,11 +68,11 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Surface(std::shared_ptr<SurfaceData> surface_data_dest, int w, int h);
|
Surface(std::shared_ptr<SurfaceData> surface_data_dest = nullptr, int w = 0, int h = 0);
|
||||||
Surface(std::shared_ptr<SurfaceData> surface_data_dest, const std::string &file_path);
|
Surface(std::shared_ptr<SurfaceData> surface_data_dest, const std::string &file_path);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Surface();
|
~Surface() = default;
|
||||||
|
|
||||||
// Carga una SurfaceData desde un archivo
|
// Carga una SurfaceData desde un archivo
|
||||||
SurfaceData loadSurface(const std::string &file_path);
|
SurfaceData loadSurface(const std::string &file_path);
|
||||||
@@ -124,10 +124,10 @@ public:
|
|||||||
void setPalette(const std::array<Uint32, 256> &palette) { palette_ = palette; }
|
void setPalette(const std::array<Uint32, 256> &palette) { palette_ = palette; }
|
||||||
void setSurface(std::shared_ptr<SurfaceData> surface) { surface_data_ = surface; }
|
void setSurface(std::shared_ptr<SurfaceData> surface) { surface_data_ = surface; }
|
||||||
|
|
||||||
// Permite que una Surface apunte al SurfaceData de otra Surface
|
// Método para redirigir surface_data_ al surface_data_ de otro objeto
|
||||||
void redirectSurfaceDataTo(const std::shared_ptr<SurfaceData> &newSurfaceData) { surface_data_ = newSurfaceData; }
|
void redirectSurfaceDataTo(const std::shared_ptr<SurfaceData> &newSurfaceData);
|
||||||
void redirectSurfaceDataTo(const std::shared_ptr<Surface> &otherSurface) { surface_data_ = otherSurface->getSurfaceData(); }
|
void redirectSurfaceDataTo(const std::shared_ptr<Surface> &otherSurface);
|
||||||
|
|
||||||
// Método para restaurar
|
// Método para restaurar surface_data_ al valor original
|
||||||
void restoreOriginalSurfaceData() { surface_data_ = original_surface_data_; }
|
void restoreOriginalSurfaceData();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ std::shared_ptr<Surface> Text::writeToSurface(const std::string &text, int zoom,
|
|||||||
auto height = box_height_ * zoom;
|
auto height = box_height_ * zoom;
|
||||||
auto surface = std::make_shared<Surface>(Screen::get()->getRenderSurfaceData(), width, height);
|
auto surface = std::make_shared<Surface>(Screen::get()->getRenderSurfaceData(), width, height);
|
||||||
Screen::get()->setRenderSurfaceData(surface);
|
Screen::get()->setRenderSurfaceData(surface);
|
||||||
Screen::get()->clear(stringToColor("transparent"));
|
Screen::get()->clearSurface(stringToColor("transparent"));
|
||||||
write(0, 0, text, kerning);
|
write(0, 0, text, kerning);
|
||||||
Screen::get()->setRenderSurfaceData(nullptr);
|
Screen::get()->setRenderSurfaceData(nullptr);
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ std::shared_ptr<Surface> Text::writeDXToSurface(Uint8 flags, const std::string &
|
|||||||
auto height = box_height_ + shadow_distance;
|
auto height = box_height_ + shadow_distance;
|
||||||
auto surface = std::make_shared<Surface>(Screen::get()->getRenderSurfaceData(), width, height);
|
auto surface = std::make_shared<Surface>(Screen::get()->getRenderSurfaceData(), width, height);
|
||||||
Screen::get()->setRenderSurfaceData(surface);
|
Screen::get()->setRenderSurfaceData(surface);
|
||||||
Screen::get()->clear(stringToColor("transparent"));
|
Screen::get()->clearSurface(stringToColor("transparent"));
|
||||||
writeDX(flags, 0, 0, text, kerning, textColor, shadow_distance, shadow_color, lenght);
|
writeDX(flags, 0, 0, text, kerning, textColor, shadow_distance, shadow_color, lenght);
|
||||||
Screen::get()->setRenderSurfaceData(nullptr);
|
Screen::get()->setRenderSurfaceData(nullptr);
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,8 @@
|
|||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Title::Title()
|
Title::Title()
|
||||||
: surface_(Resource::get()->getSurface("title_logo.gif")),
|
: title_logo_surface_(Resource::get()->getSurface("title_logo.gif")),
|
||||||
sprite_(std::make_shared<SSprite>(surface_, 0, 0, surface_->getWidth(), surface_->getHeight())),
|
title_logo_sprite_(std::make_shared<SSprite>(title_logo_surface_, 0, 0, title_logo_surface_->getWidth(), title_logo_surface_->getHeight())),
|
||||||
bg_surface_(std::make_shared<Surface>(Screen::get()->getRenderSurfaceData(), options.game.width, options.game.height))
|
bg_surface_(std::make_shared<Surface>(Screen::get()->getRenderSurfaceData(), options.game.width, options.game.height))
|
||||||
{
|
{
|
||||||
// Carga la surface con los gráficos de la pantalla de carga
|
// Carga la surface con los gráficos de la pantalla de carga
|
||||||
@@ -33,6 +33,8 @@ Title::Title()
|
|||||||
pLoadPal(Asset::get()->get("loading_screen_color.gif").c_str());
|
pLoadPal(Asset::get()->get("loading_screen_color.gif").c_str());
|
||||||
pSetSource(loading_screen_);
|
pSetSource(loading_screen_);
|
||||||
|
|
||||||
|
//title_logo_surface_->setSurfaceDataDest(bg_surface_->getSurfaceData());
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
state_ = options.section.subsection == Subsection::TITLE_WITH_LOADING_SCREEN ? TitleState::SHOW_LOADING_SCREEN : TitleState::SHOW_MENU;
|
state_ = options.section.subsection == Subsection::TITLE_WITH_LOADING_SCREEN ? TitleState::SHOW_LOADING_SCREEN : TitleState::SHOW_MENU;
|
||||||
options.section.section = Section::TITLE;
|
options.section.section = Section::TITLE;
|
||||||
@@ -246,7 +248,7 @@ void Title::render()
|
|||||||
{
|
{
|
||||||
// Prepara para empezar a dibujar en la textura de juego
|
// Prepara para empezar a dibujar en la textura de juego
|
||||||
Screen::get()->start();
|
Screen::get()->start();
|
||||||
Screen::get()->clear(stringToColor("black"));
|
Screen::get()->clearSurface(stringToColor("black"));
|
||||||
|
|
||||||
if (state_ == TitleState::SHOW_MENU)
|
if (state_ == TitleState::SHOW_MENU)
|
||||||
{
|
{
|
||||||
@@ -270,7 +272,7 @@ void Title::render()
|
|||||||
pFlip(Screen::get()->getRenderer());
|
pFlip(Screen::get()->getRenderer());
|
||||||
|
|
||||||
// Dibuja el logo del título
|
// Dibuja el logo del título
|
||||||
sprite_->render();
|
title_logo_sprite_->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vuelca el contenido del renderizador en pantalla
|
// Vuelca el contenido del renderizador en pantalla
|
||||||
@@ -314,11 +316,10 @@ void Title::fillSurface()
|
|||||||
Screen::get()->setRenderSurfaceData(bg_surface_);
|
Screen::get()->setRenderSurfaceData(bg_surface_);
|
||||||
|
|
||||||
// Rellena la textura de color
|
// Rellena la textura de color
|
||||||
bg_surface_->setColor(255, 0xFF000000);
|
Screen::get()->clearSurface(4);
|
||||||
bg_surface_->clear(255);
|
|
||||||
|
|
||||||
// Pinta el gráfico del titulo a partir del sprite
|
// Pinta el gráfico del titulo a partir del sprite
|
||||||
sprite_->render();
|
title_logo_sprite_->render();
|
||||||
|
|
||||||
// Escribe el texto en la textura
|
// Escribe el texto en la textura
|
||||||
auto text = Resource::get()->getText("smb2");
|
auto text = Resource::get()->getText("smb2");
|
||||||
@@ -328,6 +329,7 @@ void Title::fillSurface()
|
|||||||
text->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 13 * TEXT_SIZE, "2.ACHIEVEMENTS", 1, COLOR);
|
text->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 13 * TEXT_SIZE, "2.ACHIEVEMENTS", 1, COLOR);
|
||||||
text->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 15 * TEXT_SIZE, "3.REDEFINE KEYS", 1, COLOR);
|
text->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 15 * TEXT_SIZE, "3.REDEFINE KEYS", 1, COLOR);
|
||||||
text->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 20 * TEXT_SIZE, "ESC.EXIT GAME", 1, COLOR);
|
text->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 20 * TEXT_SIZE, "ESC.EXIT GAME", 1, COLOR);
|
||||||
|
text->writeColored(PLAY_AREA_CENTER_X, 30 * TEXT_SIZE, "ESC.EXIT GAME", COLOR);
|
||||||
|
|
||||||
// Devuelve el puntero del renderizador a su sitio
|
// Devuelve el puntero del renderizador a su sitio
|
||||||
Screen::get()->setRenderSurfaceData(nullptr);
|
Screen::get()->setRenderSurfaceData(nullptr);
|
||||||
@@ -352,7 +354,7 @@ void Title::createCheevosTexture()
|
|||||||
|
|
||||||
// Rellena la textura con color sólido
|
// Rellena la textura con color sólido
|
||||||
const Uint8 CHEEVOS_BG_COLOR = stringToColor("black");
|
const Uint8 CHEEVOS_BG_COLOR = stringToColor("black");
|
||||||
Screen::get()->clear(CHEEVOS_BG_COLOR);
|
Screen::get()->clearSurface(CHEEVOS_BG_COLOR);
|
||||||
|
|
||||||
// Escribe la lista de logros en la textura
|
// Escribe la lista de logros en la textura
|
||||||
const std::string CHEEVOS_OWNER = "ACHIEVEMENTS";
|
const std::string CHEEVOS_OWNER = "ACHIEVEMENTS";
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
std::shared_ptr<Surface> surface_; // Textura con los graficos
|
std::shared_ptr<Surface> title_logo_surface_; // Textura con los graficos
|
||||||
std::shared_ptr<SSprite> sprite_; // SSprite para manejar la surface
|
std::shared_ptr<SSprite> title_logo_sprite_; // SSprite para manejar la surface
|
||||||
std::shared_ptr<Surface> bg_surface_; // Textura para dibujar el fondo de la pantalla
|
std::shared_ptr<Surface> bg_surface_; // Textura para dibujar el fondo de la pantalla
|
||||||
std::shared_ptr<Surface> cheevos_surface_; // Textura con la lista de logros
|
std::shared_ptr<Surface> cheevos_surface_; // Textura con la lista de logros
|
||||||
std::shared_ptr<SSprite> cheevos_sprite_; // SSprite para manejar la surface con la lista de logros
|
std::shared_ptr<SSprite> cheevos_sprite_; // SSprite para manejar la surface con la lista de logros
|
||||||
|
|||||||
@@ -358,76 +358,6 @@ bool checkCollision(const SDL_Point &p, const LineDiagonal &l)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convierte una cadena a un color
|
|
||||||
Color stringToColor(Palette pal, const std::string &str)
|
|
||||||
{
|
|
||||||
// Mapas de colores para cada paleta
|
|
||||||
static const std::unordered_map<std::string, Color> zxSpectrumColors = {
|
|
||||||
{"black", {0x00, 0x00, 0x00}},
|
|
||||||
{"bright_black", {0x00, 0x00, 0x00}},
|
|
||||||
{"blue", {0x00, 0x00, 0xD8}},
|
|
||||||
{"bright_blue", {0x00, 0x00, 0xFF}},
|
|
||||||
{"red", {0xD8, 0x00, 0x00}},
|
|
||||||
{"bright_red", {0xFF, 0x00, 0x00}},
|
|
||||||
{"magenta", {0xD8, 0x00, 0xD8}},
|
|
||||||
{"bright_magenta", {0xFF, 0x00, 0xFF}},
|
|
||||||
{"green", {0x00, 0xD8, 0x00}},
|
|
||||||
{"bright_green", {0x00, 0xFF, 0x00}},
|
|
||||||
{"cyan", {0x00, 0xD8, 0xD8}},
|
|
||||||
{"bright_cyan", {0x00, 0xFF, 0xFF}},
|
|
||||||
{"yellow", {0xD8, 0xD8, 0x00}},
|
|
||||||
{"bright_yellow", {0xFF, 0xFF, 0x00}},
|
|
||||||
{"white", {0xD8, 0xD8, 0xD8}},
|
|
||||||
{"bright_white", {0xFF, 0xFF, 0xFF}}};
|
|
||||||
|
|
||||||
static const std::unordered_map<std::string, Color> zxArneColors = {
|
|
||||||
{"black", {0x00, 0x00, 0x00}},
|
|
||||||
{"bright_black", {0x3C, 0x35, 0x1F}},
|
|
||||||
{"blue", {0x31, 0x33, 0x90}},
|
|
||||||
{"bright_blue", {0x15, 0x59, 0xDB}},
|
|
||||||
{"red", {0xA7, 0x32, 0x11}},
|
|
||||||
{"bright_red", {0xD8, 0x55, 0x25}},
|
|
||||||
{"magenta", {0xA1, 0x55, 0x89}},
|
|
||||||
{"bright_magenta", {0xCD, 0x7A, 0x50}},
|
|
||||||
{"green", {0x62, 0x9A, 0x31}},
|
|
||||||
{"bright_green", {0x9C, 0xD3, 0x3C}},
|
|
||||||
{"cyan", {0x28, 0xA4, 0xCB}},
|
|
||||||
{"bright_cyan", {0x65, 0xDC, 0xD6}},
|
|
||||||
{"yellow", {0xE8, 0xBC, 0x50}},
|
|
||||||
{"bright_yellow", {0xF1, 0xE7, 0x82}},
|
|
||||||
{"white", {0xBF, 0xBF, 0xBD}},
|
|
||||||
{"bright_white", {0xF2, 0xF1, 0xED}}};
|
|
||||||
|
|
||||||
// Selecciona el mapa de colores adecuado según la paleta
|
|
||||||
const std::unordered_map<std::string, Color> *paletteMap = nullptr;
|
|
||||||
|
|
||||||
if (pal == Palette::ZXSPECTRUM)
|
|
||||||
{
|
|
||||||
paletteMap = &zxSpectrumColors;
|
|
||||||
}
|
|
||||||
else if (pal == Palette::ZXARNE)
|
|
||||||
{
|
|
||||||
paletteMap = &zxArneColors;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Paleta desconocida, devolvemos negro por defecto
|
|
||||||
return {0x00, 0x00, 0x00};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Busca el color en el mapa
|
|
||||||
auto it = paletteMap->find(str);
|
|
||||||
if (it != paletteMap->end())
|
|
||||||
{
|
|
||||||
return it->second;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Si no se encuentra el color, devolvemos negro por defecto
|
|
||||||
return {0x00, 0x00, 0x00};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convierte una cadena a un indice de la paleta
|
// Convierte una cadena a un indice de la paleta
|
||||||
Uint8 stringToColor(const std::string &str)
|
Uint8 stringToColor(const std::string &str)
|
||||||
{
|
{
|
||||||
@@ -460,7 +390,7 @@ Uint8 stringToColor(const std::string &str)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Si no se encuentra el color, devolvemos negro por defecto
|
// Si no se encuentra el color, devolvemos negro por defecto
|
||||||
return {0};
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user