forked from jaildesigner-jailgames/jaildoctors_dilemma
Transició a surface: barallantme amb tots els Color que hi ha pel codi
This commit is contained in:
@@ -26,7 +26,7 @@ Credits::Credits()
|
||||
shining_sprite_->setPos({194, 174, 8, 8});
|
||||
|
||||
// Cambia el color del borde
|
||||
Screen::get()->setBorderColor(stringToColor(options.video.palette, "black"));
|
||||
Screen::get()->setBorderColor(stringToColor("black"));
|
||||
|
||||
// Crea la textura para el texto que se escribe en pantalla
|
||||
text_surface_ = std::make_shared<Surface>(Screen::get()->getRenderSurfaceData(), options.game.width, options.game.height);
|
||||
@@ -76,62 +76,62 @@ void Credits::iniTexts()
|
||||
}
|
||||
|
||||
texts_.clear();
|
||||
texts_.push_back({"", stringToColor(options.video.palette, "white")});
|
||||
texts_.push_back({"INSTRUCTIONS:", stringToColor(options.video.palette, "yellow")});
|
||||
texts_.push_back({"", stringToColor(options.video.palette, "white")});
|
||||
texts_.push_back({"HELP JAILDOC TO GET BACK ALL", stringToColor(options.video.palette, "white")});
|
||||
texts_.push_back({"HIS PROJECTS AND GO TO THE", stringToColor(options.video.palette, "white")});
|
||||
texts_.push_back({"JAIL TO FINISH THEM", stringToColor(options.video.palette, "white")});
|
||||
texts_.push_back({"", stringToColor(options.video.palette, "white")});
|
||||
texts_.push_back({"", stringToColor(options.video.palette, "white")});
|
||||
texts_.push_back({"", stringToColor("white")});
|
||||
texts_.push_back({"INSTRUCTIONS:", stringToColor("yellow")});
|
||||
texts_.push_back({"", stringToColor("white")});
|
||||
texts_.push_back({"HELP JAILDOC TO GET BACK ALL", stringToColor("white")});
|
||||
texts_.push_back({"HIS PROJECTS AND GO TO THE", stringToColor("white")});
|
||||
texts_.push_back({"JAIL TO FINISH THEM", stringToColor("white")});
|
||||
texts_.push_back({"", stringToColor("white")});
|
||||
texts_.push_back({"", stringToColor("white")});
|
||||
|
||||
texts_.push_back({"KEYS:", stringToColor(options.video.palette, "yellow")});
|
||||
texts_.push_back({"", stringToColor(options.video.palette, "white")});
|
||||
texts_.push_back({keys + " TO MOVE AND JUMP", stringToColor(options.video.palette, "white")});
|
||||
texts_.push_back({"M TO SWITCH THE MUSIC", stringToColor(options.video.palette, "white")});
|
||||
texts_.push_back({"H TO PAUSE THE GAME", stringToColor(options.video.palette, "white")});
|
||||
texts_.push_back({"F1-F2 TO CHANGE WINDOWS SIZE", stringToColor(options.video.palette, "white")});
|
||||
texts_.push_back({"F3 TO SWITCH TO FULLSCREEN", stringToColor(options.video.palette, "white")});
|
||||
texts_.push_back({"B TO TOOGLE THE BORDER SCREEN", stringToColor(options.video.palette, "white")});
|
||||
texts_.push_back({"", stringToColor(options.video.palette, "white")});
|
||||
texts_.push_back({"", stringToColor(options.video.palette, "white")});
|
||||
texts_.push_back({"KEYS:", stringToColor("yellow")});
|
||||
texts_.push_back({"", stringToColor("white")});
|
||||
texts_.push_back({keys + " TO MOVE AND JUMP", stringToColor("white")});
|
||||
texts_.push_back({"M TO SWITCH THE MUSIC", stringToColor("white")});
|
||||
texts_.push_back({"H TO PAUSE THE GAME", stringToColor("white")});
|
||||
texts_.push_back({"F1-F2 TO CHANGE WINDOWS SIZE", stringToColor("white")});
|
||||
texts_.push_back({"F3 TO SWITCH TO FULLSCREEN", stringToColor("white")});
|
||||
texts_.push_back({"B TO TOOGLE THE BORDER SCREEN", stringToColor("white")});
|
||||
texts_.push_back({"", stringToColor("white")});
|
||||
texts_.push_back({"", stringToColor("white")});
|
||||
|
||||
texts_.push_back({"A GAME BY JAILDESIGNER", stringToColor(options.video.palette, "yellow")});
|
||||
texts_.push_back({"MADE ON SUMMER/FALL 2022", stringToColor(options.video.palette, "yellow")});
|
||||
texts_.push_back({"", stringToColor(options.video.palette, "white")});
|
||||
texts_.push_back({"", stringToColor(options.video.palette, "white")});
|
||||
texts_.push_back({"A GAME BY JAILDESIGNER", stringToColor("yellow")});
|
||||
texts_.push_back({"MADE ON SUMMER/FALL 2022", stringToColor("yellow")});
|
||||
texts_.push_back({"", stringToColor("white")});
|
||||
texts_.push_back({"", stringToColor("white")});
|
||||
|
||||
texts_.push_back({"I LOVE JAILGAMES! ", stringToColor(options.video.palette, "white")});
|
||||
texts_.push_back({"", stringToColor(options.video.palette, "white")});
|
||||
texts_.push_back({"I LOVE JAILGAMES! ", stringToColor("white")});
|
||||
texts_.push_back({"", stringToColor("white")});
|
||||
#else
|
||||
texts.clear();
|
||||
texts.push_back({"", stringToColor(options.video.palette, "white")});
|
||||
texts.push_back({"INSTRUCTIONS:", stringToColor(options.video.palette, "yellow")});
|
||||
texts.push_back({"", stringToColor(options.video.palette, "white")});
|
||||
texts.push_back({"HELP JAILDOC TO GET BACK ALL", stringToColor(options.video.palette, "white")});
|
||||
texts.push_back({"HIS PROJECTS AND GO TO THE", stringToColor(options.video.palette, "white")});
|
||||
texts.push_back({"JAIL TO FINISH THEM", stringToColor(options.video.palette, "white")});
|
||||
texts.push_back({"", stringToColor(options.video.palette, "white")});
|
||||
texts.push_back({"", stringToColor(options.video.palette, "white")});
|
||||
texts.push_back({"", stringToColor("white")});
|
||||
texts.push_back({"INSTRUCTIONS:", stringToColor("yellow")});
|
||||
texts.push_back({"", stringToColor("white")});
|
||||
texts.push_back({"HELP JAILDOC TO GET BACK ALL", stringToColor("white")});
|
||||
texts.push_back({"HIS PROJECTS AND GO TO THE", stringToColor("white")});
|
||||
texts.push_back({"JAIL TO FINISH THEM", stringToColor("white")});
|
||||
texts.push_back({"", stringToColor("white")});
|
||||
texts.push_back({"", stringToColor("white")});
|
||||
|
||||
texts.push_back({"KEYS:", stringToColor(options.video.palette, "yellow")});
|
||||
texts.push_back({"", stringToColor(options.video.palette, "white")});
|
||||
texts.push_back({"B TO JUMP", stringToColor(options.video.palette, "white")});
|
||||
texts.push_back({"R TO SWITCH THE MUSIC", stringToColor(options.video.palette, "white")});
|
||||
texts.push_back({"L TO SWAP THE COLOR PALETTE", stringToColor(options.video.palette, "white")});
|
||||
texts.push_back({"START TO PAUSE", stringToColor(options.video.palette, "white")});
|
||||
texts.push_back({"SELECT TO EXIT", stringToColor(options.video.palette, "white")});
|
||||
texts.push_back({"", stringToColor(options.video.palette, "white")});
|
||||
texts.push_back({"", stringToColor(options.video.palette, "white")});
|
||||
texts.push_back({"", stringToColor(options.video.palette, "white")});
|
||||
texts.push_back({"KEYS:", stringToColor("yellow")});
|
||||
texts.push_back({"", stringToColor("white")});
|
||||
texts.push_back({"B TO JUMP", stringToColor("white")});
|
||||
texts.push_back({"R TO SWITCH THE MUSIC", stringToColor("white")});
|
||||
texts.push_back({"L TO SWAP THE COLOR PALETTE", stringToColor("white")});
|
||||
texts.push_back({"START TO PAUSE", stringToColor("white")});
|
||||
texts.push_back({"SELECT TO EXIT", stringToColor("white")});
|
||||
texts.push_back({"", stringToColor("white")});
|
||||
texts.push_back({"", stringToColor("white")});
|
||||
texts.push_back({"", stringToColor("white")});
|
||||
|
||||
texts.push_back({"A GAME BY JAILDESIGNER", stringToColor(options.video.palette, "yellow")});
|
||||
texts.push_back({"MADE ON SUMMER/FALL 2022", stringToColor(options.video.palette, "yellow")});
|
||||
texts.push_back({"", stringToColor(options.video.palette, "white")});
|
||||
texts.push_back({"", stringToColor(options.video.palette, "white")});
|
||||
texts.push_back({"A GAME BY JAILDESIGNER", stringToColor("yellow")});
|
||||
texts.push_back({"MADE ON SUMMER/FALL 2022", stringToColor("yellow")});
|
||||
texts.push_back({"", stringToColor("white")});
|
||||
texts.push_back({"", stringToColor("white")});
|
||||
|
||||
texts.push_back({"I LOVE JAILGAMES! ", stringToColor(options.video.palette, "white")});
|
||||
texts.push_back({"", stringToColor(options.video.palette, "white")});
|
||||
texts.push_back({"I LOVE JAILGAMES! ", stringToColor("white")});
|
||||
texts.push_back({"", stringToColor("white")});
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ void Credits::fillTexture()
|
||||
// Escribe el corazón
|
||||
const int TEXT_LENGHT = text->lenght(texts_[22].label, 1) - text->lenght(" ", 1); // Se resta el ultimo caracter que es un espacio
|
||||
const int POS_X = ((PLAY_AREA_WIDTH - TEXT_LENGHT) / 2) + TEXT_LENGHT;
|
||||
text->writeColored(POS_X, 176, "}", stringToColor(options.video.palette, "bright_red"));
|
||||
text->writeColored(POS_X, 176, "}", stringToColor("bright_red"));
|
||||
|
||||
// Recoloca el sprite del brillo
|
||||
shining_sprite_->setPosX(POS_X + 2);
|
||||
|
||||
@@ -16,7 +16,7 @@ private:
|
||||
struct Captions
|
||||
{
|
||||
std::string label; // Texto a escribir
|
||||
Color color; // Color del texto
|
||||
Uint8 color; // Color del texto
|
||||
};
|
||||
|
||||
// Objetos y punteros
|
||||
|
||||
@@ -48,7 +48,7 @@ void Debug::render()
|
||||
y = 0;
|
||||
for (const auto &l : log_)
|
||||
{
|
||||
text->writeColored(x_ + 10, y, l, Color(255, 255, 255));
|
||||
text->writeColored(x_ + 10, y, l, stringToColor("white"));
|
||||
y += text->getCharacterSize() + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ Ending::Ending()
|
||||
iniScenes();
|
||||
|
||||
// Cambia el color del borde
|
||||
Screen::get()->setBorderColor(stringToColor(options.video.palette, "black"));
|
||||
Screen::get()->setBorderColor(stringToColor("black"));
|
||||
|
||||
// Crea la textura para cubrir el texto
|
||||
cover_surface_ = createTexture(Screen::get()->getRenderer(), options.game.width, options.game.height + 8);
|
||||
@@ -91,7 +91,7 @@ void Ending::render()
|
||||
Screen::get()->start();
|
||||
|
||||
// Limpia la pantalla
|
||||
Screen::get()->clean(stringToColor(options.video.palette, "yellow"));
|
||||
Screen::get()->clean(stringToColor("yellow"));
|
||||
|
||||
// Dibuja las imagenes de la escena
|
||||
sprite_pics_.at(current_scene_).image_sprite->render();
|
||||
@@ -484,7 +484,7 @@ void Ending::fillCoverTexture()
|
||||
SDL_RenderClear(Screen::get()->getRenderer());
|
||||
|
||||
// Los primeros 8 pixels crea una malla
|
||||
const Color color = stringToColor(options.video.palette, "black");
|
||||
const Uint8 color = stringToColor("black");
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), color.r, color.g, color.b, 0xFF);
|
||||
for (int i = 0; i < 256; i += 2)
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <SDL2/SDL_render.h> // for SDL_RenderDrawPoint, SDL_SetRenderDr...
|
||||
#include <SDL2/SDL_timer.h> // for SDL_GetTicks
|
||||
#include <algorithm> // for max, min, replace
|
||||
#include "s_animated_sprite.h" // for AnimatedSprite
|
||||
#include "s_animated_sprite.h" // for SAnimatedSprite
|
||||
#include "defines.h" // for options.game.height, GAMECANVAS_CENTER_X
|
||||
#include "global_events.h" // for check
|
||||
#include "global_inputs.h" // for check
|
||||
@@ -38,7 +38,7 @@ Ending2::Ending2()
|
||||
}
|
||||
|
||||
// Cambia el color del borde
|
||||
Screen::get()->setBorderColor(stringToColor(options.video.palette, "black"));
|
||||
Screen::get()->setBorderColor(stringToColor("black"));
|
||||
|
||||
// Inicializa la lista de sprites
|
||||
iniSpriteList();
|
||||
@@ -101,7 +101,7 @@ void Ending2::render()
|
||||
Screen::get()->start();
|
||||
|
||||
// Limpia la pantalla
|
||||
Screen::get()->clean(stringToColor(options.video.palette, "black"));
|
||||
Screen::get()->clean(stringToColor("black"));
|
||||
|
||||
// Dibuja los sprites
|
||||
renderSprites();
|
||||
@@ -282,7 +282,7 @@ void Ending2::loadSprites()
|
||||
// Carga los sprites
|
||||
for (const auto &file : sprite_list_)
|
||||
{
|
||||
sprites_.emplace_back(std::make_shared<AnimatedSprite>(Resource::get()->getSurface(file + ".gif"), Resource::get()->getAnimations(file + ".ani")));
|
||||
sprites_.emplace_back(std::make_shared<SAnimatedSprite>(Resource::get()->getSurface(file + ".gif"), 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_);
|
||||
}
|
||||
@@ -497,15 +497,16 @@ void Ending2::createTexts()
|
||||
|
||||
// Actualiza el fade final
|
||||
void Ending2::updateFinalFade()
|
||||
{
|
||||
{/*
|
||||
// La variable step va de 0 a 40 en el tramo de postCounter que va de 500 a 540. Al dividirlo por 40, va de 0.0f a 1.0f
|
||||
const float STEP = std::min(std::max(post_counter_, 500) - 500, 40) / 40.0f;
|
||||
const int INDEX = (colors_.size() - 1) * STEP;
|
||||
|
||||
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);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// Actualiza el volumen de la musica
|
||||
|
||||
@@ -18,7 +18,6 @@ Enemy::Enemy(const EnemyData &enemy)
|
||||
should_mirror_(enemy.mirror)
|
||||
{
|
||||
// Obten el resto de valores
|
||||
setPalette(options.video.palette);
|
||||
sprite_->setPosX(enemy.x);
|
||||
sprite_->setPosY(enemy.y);
|
||||
sprite_->setVelX(enemy.vx);
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
// Constructor
|
||||
Game::Game(GameMode mode)
|
||||
: board_(std::make_shared<ScoreboardData>(0, 9, 0, true, Color(0, 0, 0), SDL_GetTicks(), options.cheats.jail_is_open == Cheat::CheatState::ENABLED)),
|
||||
: board_(std::make_shared<ScoreboardData>(0, 9, 0, true, 0, SDL_GetTicks(), options.cheats.jail_is_open == Cheat::CheatState::ENABLED)),
|
||||
scoreboard_(std::make_shared<Scoreboard>(board_)),
|
||||
room_tracker_(std::make_shared<RoomTracker>()),
|
||||
stats_(std::make_shared<Stats>(Asset::get()->get("stats.csv"), Asset::get()->get("stats_buffer.csv"))),
|
||||
@@ -447,7 +447,7 @@ void Game::renderBlackScreen()
|
||||
if (black_screen_)
|
||||
{
|
||||
Screen::get()->clean();
|
||||
Screen::get()->setBorderColor(stringToColor(options.video.palette, "black"));
|
||||
Screen::get()->setBorderColor(stringToColor("black"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -455,13 +455,13 @@ void Game::renderBlackScreen()
|
||||
void Game::setScoreBoardColor()
|
||||
{
|
||||
// Obtiene el color del borde
|
||||
const Color colorBorder = room_->getBorderColor();
|
||||
const Uint8 colorBorder = room_->getBorderColor();
|
||||
|
||||
const bool isBlack = colorAreEqual(colorBorder, stringToColor(options.video.palette, "black"));
|
||||
const bool isBrightBlack = colorAreEqual(colorBorder, stringToColor(options.video.palette, "bright_black"));
|
||||
const bool isBlack = colorBorder, stringToColor("black");
|
||||
const bool isBrightBlack = colorBorder, stringToColor("bright_black");
|
||||
|
||||
// Si el color del borde es negro o negro brillante cambia el texto del marcador a blanco
|
||||
board_->color = isBlack || isBrightBlack ? stringToColor(options.video.palette, "white") : colorBorder;
|
||||
board_->color = isBlack || isBrightBlack ? stringToColor("white") : colorBorder;
|
||||
}
|
||||
|
||||
// Comprueba si ha finalizado el juego
|
||||
|
||||
@@ -54,7 +54,7 @@ LoadingScreen::LoadingScreen()
|
||||
}
|
||||
|
||||
// Cambia el color del borde
|
||||
Screen::get()->setBorderColor(stringToColor(options.video.palette, "black"));
|
||||
Screen::get()->setBorderColor(stringToColor("black"));
|
||||
}
|
||||
|
||||
// Destructor
|
||||
@@ -148,12 +148,12 @@ void LoadingScreen::renderLoad()
|
||||
void LoadingScreen::renderBorder()
|
||||
{
|
||||
// Pinta el borde de colro azul
|
||||
Color color = stringToColor(options.video.palette, "blue");
|
||||
Uint8 color = stringToColor("blue");
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), color.r, color.g, color.b, 0xFF);
|
||||
SDL_RenderClear(Screen::get()->getRenderer());
|
||||
|
||||
// Añade lineas amarillas
|
||||
color = stringToColor(options.video.palette, "yellow");
|
||||
color = stringToColor("yellow");
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), color.r, color.g, color.b, 0xFF);
|
||||
const int WIDTH = options.game.width + (options.video.border.width * 2);
|
||||
const int HEIGHT = options.game.height + (options.video.border.height * 2);
|
||||
|
||||
@@ -38,11 +38,11 @@ Logo::Logo()
|
||||
const std::vector<std::string> COLORS = {"black", "blue", "red", "magenta", "green", "cyan", "yellow", "bright_white"};
|
||||
for (const auto &color : COLORS)
|
||||
{
|
||||
color_.push_back(stringToColor(options.video.palette, color));
|
||||
color_.push_back(stringToColor(color));
|
||||
}
|
||||
|
||||
// Cambia el color del borde
|
||||
Screen::get()->setBorderColor(stringToColor(options.video.palette, "black"));
|
||||
Screen::get()->setBorderColor(stringToColor("black"));
|
||||
}
|
||||
|
||||
// Comprueba el manejador de eventos
|
||||
|
||||
@@ -22,7 +22,7 @@ private:
|
||||
std::shared_ptr<SSprite> since_1998_sprite_; // SSprite para manejar la textura2
|
||||
|
||||
// Variables
|
||||
std::vector<Color> color_; // Vector con los colores para el fade
|
||||
std::vector<Uint8> color_; // Vector con los colores para el fade
|
||||
int counter_ = 0; // Contador
|
||||
Uint32 ticks_ = 0; // Contador de ticks para ajustar la velocidad del programa
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ Notifier *Notifier::get()
|
||||
|
||||
// Constructor
|
||||
Notifier::Notifier(const std::string &icon_file, const std::string &text)
|
||||
: icon_texture_(!icon_file.empty() ? Resource::get()->getSurface(icon_file) : nullptr),
|
||||
: icon_surface_(!icon_file.empty() ? Resource::get()->getSurface(icon_file) : nullptr),
|
||||
text_(Resource::get()->getText(text)),
|
||||
bg_color_(options.notifications.color),
|
||||
wait_time_(150),
|
||||
@@ -86,7 +86,7 @@ void Notifier::update()
|
||||
{
|
||||
// const float step = ((float)notifications_[i].counter / notifications_[i].travel_dist);
|
||||
// const int alpha = 255 * step;
|
||||
constexpr int ALPHA = 255;
|
||||
//constexpr int ALPHA = 255;
|
||||
|
||||
if (options.notifications.getVerticalPosition() == NotificationPosition::TOP)
|
||||
{
|
||||
@@ -96,12 +96,12 @@ void Notifier::update()
|
||||
{
|
||||
notifications_[i].rect.y--;
|
||||
}
|
||||
notifications_[i].texture->setAlpha(ALPHA);
|
||||
//notifications_[i].surface->setAlpha(ALPHA);
|
||||
|
||||
if (notifications_[i].rect.y == notifications_[i].y)
|
||||
{
|
||||
notifications_[i].state = NotificationStatus::STAY;
|
||||
notifications_[i].texture->setAlpha(255);
|
||||
//notifications_[i].surface->setAlpha(255);
|
||||
notifications_[i].counter = 0;
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ void Notifier::update()
|
||||
|
||||
// const float step = (notifications_[i].counter / (float)notifications_[i].travel_dist);
|
||||
// const int ALPHA = 255 * (1 - step);
|
||||
constexpr int ALPHA = 255;
|
||||
//constexpr int ALPHA = 255;
|
||||
|
||||
if (options.notifications.getVerticalPosition() == NotificationPosition::TOP)
|
||||
{
|
||||
@@ -129,7 +129,7 @@ void Notifier::update()
|
||||
{
|
||||
notifications_[i].rect.y++;
|
||||
}
|
||||
notifications_[i].texture->setAlpha(ALPHA);
|
||||
//notifications_[i].surface->setAlpha(ALPHA);
|
||||
|
||||
if (notifications_[i].rect.y == notifications_[i].y - notifications_[i].travel_dist)
|
||||
{
|
||||
@@ -234,12 +234,12 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, in
|
||||
n.rect = {desp_h, y_pos, width, height};
|
||||
|
||||
// Crea la textura
|
||||
n.texture = std::make_shared<Texture>(Screen::get()->getRenderer());
|
||||
n.texture->createBlank(width, height, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET);
|
||||
n.texture->setBlendMode(SDL_BLENDMODE_BLEND);
|
||||
n.surface = std::make_shared<Texture>(Screen::get()->getRenderer());
|
||||
n.surface->createBlank(width, height, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET);
|
||||
n.surface->setBlendMode(SDL_BLENDMODE_BLEND);
|
||||
|
||||
// Prepara para dibujar en la textura
|
||||
n.texture->setAsRenderTarget(Screen::get()->getRenderer());
|
||||
n.surface->setAsRenderTarget(Screen::get()->getRenderer());
|
||||
|
||||
// Dibuja el fondo de la notificación
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), bg_color_.r, bg_color_.g, bg_color_.b, 255);
|
||||
@@ -267,7 +267,7 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, in
|
||||
// Dibuja el icono de la notificación
|
||||
if (has_icons_ && icon >= 0 && texts.size() >= 2)
|
||||
{
|
||||
auto sp = std::make_unique<Sprite>(icon_texture_, (SDL_Rect){0, 0, ICON_SIZE_, ICON_SIZE_});
|
||||
auto sp = std::make_unique<Sprite>(icon_surface_, (SDL_Rect){0, 0, ICON_SIZE_, ICON_SIZE_});
|
||||
sp->setPosition({padding_in_h, padding_in_v, ICON_SIZE_, ICON_SIZE_});
|
||||
sp->setClip({ICON_SIZE_ * (icon % 10), ICON_SIZE_ * (icon / 10), ICON_SIZE_, ICON_SIZE_});
|
||||
sp->render();
|
||||
@@ -293,10 +293,10 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, in
|
||||
SDL_SetRenderTarget(Screen::get()->getRenderer(), nullptr);
|
||||
|
||||
// Crea el sprite de la notificación
|
||||
n.sprite = std::make_shared<Sprite>(n.texture, n.rect);
|
||||
n.sprite = std::make_shared<Sprite>(n.surface, n.rect);
|
||||
|
||||
// Deja la notificación invisible
|
||||
n.texture->setAlpha(0);
|
||||
n.surface->setAlpha(0);
|
||||
|
||||
// Añade la notificación a la lista
|
||||
notifications_.emplace_back(n);
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL_rect.h> // for SDL_Rect
|
||||
#include <memory> // for shared_ptr
|
||||
#include <string> // for string, basic_string
|
||||
#include <vector> // for vector
|
||||
#include "utils.h" // for Color
|
||||
class Sprite; // lines 9-9
|
||||
class Text; // lines 10-10
|
||||
class Texture; // lines 11-11
|
||||
#include <SDL2/SDL_rect.h> // for SDL_Rect
|
||||
#include <memory> // for shared_ptr
|
||||
#include <string> // for string, basic_string
|
||||
#include <vector> // for vector
|
||||
#include "utils.h" // for Color
|
||||
class SSprite; // lines 9-9
|
||||
class Text; // lines 10-10
|
||||
class Surface; // lines 11-11
|
||||
|
||||
enum class NotificationText
|
||||
{
|
||||
@@ -41,8 +41,8 @@ private:
|
||||
|
||||
struct Notification
|
||||
{
|
||||
std::shared_ptr<Texture> texture;
|
||||
std::shared_ptr<Sprite> sprite;
|
||||
std::shared_ptr<Surface> surface;
|
||||
std::shared_ptr<SSprite> sprite;
|
||||
std::vector<std::string> texts;
|
||||
int counter;
|
||||
NotificationStatus state;
|
||||
@@ -56,12 +56,12 @@ private:
|
||||
|
||||
// Constructor
|
||||
explicit Notification()
|
||||
: texture(nullptr), sprite(nullptr), texts(), counter(0), state(NotificationStatus::RISING),
|
||||
: surface(nullptr), sprite(nullptr), texts(), counter(0), state(NotificationStatus::RISING),
|
||||
shape(NotificationShape::SQUARED), rect{0, 0, 0, 0}, y(0), travel_dist(0), code(""),
|
||||
can_be_removed(true), height(0) {}
|
||||
};
|
||||
|
||||
std::shared_ptr<Texture> icon_texture_; // Textura para los iconos de las notificaciones
|
||||
std::shared_ptr<Surface> icon_surface_; // Textura para los iconos de las notificaciones
|
||||
std::shared_ptr<Text> text_; // Objeto para dibujar texto
|
||||
|
||||
// Variables
|
||||
|
||||
@@ -635,15 +635,15 @@ void Player::setColor()
|
||||
{
|
||||
if (options.cheats.invincible == Cheat::CheatState::ENABLED)
|
||||
{
|
||||
color_ = stringToColor(options.video.palette, "cyan");
|
||||
color_ = stringToColor("cyan");
|
||||
}
|
||||
else if (options.cheats.infinite_lives == Cheat::CheatState::ENABLED)
|
||||
{
|
||||
color_ = stringToColor(options.video.palette, "yellow");
|
||||
color_ = stringToColor("yellow");
|
||||
}
|
||||
else
|
||||
{
|
||||
color_ = stringToColor(options.video.palette, "white");
|
||||
color_ = stringToColor("white");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <memory> // for shared_ptr, __shared_ptr_access
|
||||
#include <string> // for string
|
||||
#include <vector> // for vector
|
||||
#include "s_animated_sprite.h" // for AnimatedSprite
|
||||
#include "s_animated_sprite.h" // for SAnimatedSprite
|
||||
#include "defines.h" // for BORDER_TOP, BLOCK
|
||||
#include "surface.h" // for Texture
|
||||
#include "utils.h" // for Color
|
||||
@@ -60,14 +60,14 @@ public:
|
||||
|
||||
// Objetos y punteros
|
||||
std::shared_ptr<Room> room_; // Objeto encargado de gestionar cada habitación del juego
|
||||
std::shared_ptr<AnimatedSprite> sprite_; // Sprite del jugador
|
||||
std::shared_ptr<SAnimatedSprite> sprite_; // Sprite del jugador
|
||||
|
||||
// Variables
|
||||
float x_; // Posición del jugador en el eje X
|
||||
float y_; // Posición del jugador en el eje Y
|
||||
float vx_; // Velocidad/desplazamiento del jugador en el eje X
|
||||
float vy_; // Velocidad/desplazamiento del jugador en el eje Y
|
||||
Color color_; // Color del jugador
|
||||
Uint8 color_; // Color del jugador
|
||||
SDL_Rect collider_box_; // Caja de colisión con los enemigos u objetos
|
||||
std::vector<SDL_Point> collider_points_; // Puntos de colisión con el mapa
|
||||
std::vector<SDL_Point> under_feet_; // Contiene los puntos que hay bajo cada pie del jugador
|
||||
@@ -189,9 +189,6 @@ public:
|
||||
// Obtiene el estado de reaparición del jugador
|
||||
PlayerSpawn getSpawnParams() { return {x_, y_, vx_, vy_, jump_init_pos_, state_, sprite_->getFlip()}; }
|
||||
|
||||
// Recarga la textura
|
||||
void reLoadTexture() { sprite_->getTexture()->reLoad(); }
|
||||
|
||||
// Establece el color del jugador
|
||||
void setColor();
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "resource.h" // for Resource
|
||||
#include "scoreboard.h" // for ScoreboardData
|
||||
#include "screen.h" // for Screen
|
||||
#include "s_sprite.h" // for Sprite
|
||||
#include "s_sprite.h" // for SSprite
|
||||
#include "surface.h" // for Texture
|
||||
#include "utils.h" // for LineHorizontal, LineDiagonal, LineVe...
|
||||
|
||||
@@ -77,7 +77,7 @@ RoomData loadRoomFile(const std::string &file_path, bool verbose)
|
||||
RoomData room;
|
||||
room.item_color1 = "yellow";
|
||||
room.item_color2 = "magenta";
|
||||
room.auto_surface_direction = 1;
|
||||
room.conveyor_belt_direction = 1;
|
||||
|
||||
const std::string fileName = file_path.substr(file_path.find_last_of("\\/") + 1);
|
||||
room.number = fileName.substr(0, fileName.find_last_of("."));
|
||||
@@ -125,8 +125,8 @@ RoomData loadRoomFile(const std::string &file_path, bool verbose)
|
||||
{
|
||||
ItemData item;
|
||||
item.counter = 0;
|
||||
item.color1 = stringToColor(Palette::ZXSPECTRUM, "yellow");
|
||||
item.color2 = stringToColor(Palette::ZXSPECTRUM, "magenta");
|
||||
item.color1 = stringToColor("yellow");
|
||||
item.color2 = stringToColor("magenta");
|
||||
|
||||
do
|
||||
{
|
||||
@@ -226,23 +226,23 @@ bool setRoom(RoomData *room, const std::string &key, const std::string &value)
|
||||
}
|
||||
else if (key == "roomUp")
|
||||
{
|
||||
room->room_top = value;
|
||||
room->upper_room = value;
|
||||
}
|
||||
else if (key == "roomDown")
|
||||
{
|
||||
room->room_bottom = value;
|
||||
room->lower_room = value;
|
||||
}
|
||||
else if (key == "roomLeft")
|
||||
{
|
||||
room->room_left = value;
|
||||
room->left_room = value;
|
||||
}
|
||||
else if (key == "roomRight")
|
||||
{
|
||||
room->room_right = value;
|
||||
room->right_room = value;
|
||||
}
|
||||
else if (key == "autoSurface")
|
||||
{
|
||||
room->auto_surface_direction = (value == "right") ? 1 : -1;
|
||||
room->conveyor_belt_direction = (value == "right") ? 1 : -1;
|
||||
}
|
||||
else if (key == "" || key.substr(0, 1) == "#")
|
||||
{
|
||||
@@ -415,17 +415,17 @@ Room::Room(const std::string &room_path, std::shared_ptr<ScoreboardData> data)
|
||||
setAnimatedTiles();
|
||||
|
||||
// Crea la textura para el mapa de tiles de la habitación
|
||||
map_texture_ = createTexture(Screen::get()->getRenderer(), PLAY_AREA_WIDTH, PLAY_AREA_HEIGHT);
|
||||
map_surface_ = createTexture(Screen::get()->getRenderer(), PLAY_AREA_WIDTH, PLAY_AREA_HEIGHT);
|
||||
|
||||
// Pinta el mapa de la habitación en la textura
|
||||
fillMapTexture();
|
||||
|
||||
// Establece el color del borde
|
||||
Screen::get()->setBorderColor(stringToColor(options.video.palette, border_color_));
|
||||
Screen::get()->setBorderColor(stringToColor(border_color_));
|
||||
}
|
||||
|
||||
// Destructor
|
||||
Room::~Room() { SDL_DestroyTexture(map_texture_); }
|
||||
Room::~Room() { SDL_DestroyTexture(map_surface_); }
|
||||
|
||||
void Room::initializeRoom(const RoomData &room)
|
||||
{
|
||||
@@ -436,16 +436,16 @@ void Room::initializeRoom(const RoomData &room)
|
||||
border_color_ = room.border_color;
|
||||
item_color1_ = room.item_color1.empty() ? "yellow" : room.item_color1;
|
||||
item_color2_ = room.item_color2.empty() ? "magenta" : room.item_color2;
|
||||
room_top_ = room.room_top;
|
||||
room_bottom_ = room.room_bottom;
|
||||
room_left_ = room.room_left;
|
||||
room_right_ = room.room_right;
|
||||
upper_room_ = room.upper_room;
|
||||
lower_room_ = room.lower_room;
|
||||
left_room_ = room.left_room;
|
||||
right_room_ = room.right_room;
|
||||
tile_set_file_ = room.tile_set_file;
|
||||
tile_map_file_ = room.tile_map_file;
|
||||
auto_surface_direction_ = room.auto_surface_direction;
|
||||
conveyor_belt_direction_ = room.conveyor_belt_direction;
|
||||
tile_map_ = Resource::get()->getTileMap(room.tile_map_file);
|
||||
texture_ = Resource::get()->getSurface(room.tile_set_file);
|
||||
tile_set_width_ = texture_->getWidth() / TILE_SIZE_;
|
||||
surface_ = Resource::get()->getSurface(room.tile_set_file);
|
||||
tile_set_width_ = surface_->getWidth() / TILE_SIZE_;
|
||||
is_paused_ = false;
|
||||
counter_ = 0;
|
||||
|
||||
@@ -464,8 +464,8 @@ void Room::initializeRoom(const RoomData &room)
|
||||
{
|
||||
// Crear una copia local de los datos del item
|
||||
ItemData itemCopy = item;
|
||||
itemCopy.color1 = stringToColor(options.video.palette, item_color1_);
|
||||
itemCopy.color2 = stringToColor(options.video.palette, item_color2_);
|
||||
itemCopy.color1 = stringToColor(item_color1_);
|
||||
itemCopy.color2 = stringToColor(item_color2_);
|
||||
|
||||
// Crear el objeto Item usando la copia modificada
|
||||
items_.emplace_back(std::make_shared<Item>(itemCopy));
|
||||
@@ -476,8 +476,8 @@ void Room::initializeRoom(const RoomData &room)
|
||||
// Crea la textura con el mapeado de la habitación
|
||||
void Room::fillMapTexture()
|
||||
{
|
||||
const Color color = stringToColor(options.video.palette, bg_color_);
|
||||
SDL_SetRenderTarget(Screen::get()->getRenderer(), map_texture_);
|
||||
const Uint8 color = stringToColor(bg_color_);
|
||||
SDL_SetRenderTarget(Screen::get()->getRenderer(), map_surface_);
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), color.r, color.g, color.b, 0xFF);
|
||||
SDL_RenderClear(Screen::get()->getRenderer());
|
||||
|
||||
@@ -498,7 +498,7 @@ void Room::fillMapTexture()
|
||||
{
|
||||
clip.x = (tile_map_[index] % tile_set_width_) * TILE_SIZE_;
|
||||
clip.y = (tile_map_[index] / tile_set_width_) * TILE_SIZE_;
|
||||
texture_->render(x * TILE_SIZE_, y * TILE_SIZE_, &clip);
|
||||
surface_->render(x * TILE_SIZE_, y * TILE_SIZE_, &clip);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (Debug::get()->getEnabled())
|
||||
@@ -521,7 +521,7 @@ void Room::fillMapTexture()
|
||||
// BottomSurfaces
|
||||
if (true)
|
||||
{
|
||||
for (auto l : bottom_surfaces_)
|
||||
for (auto l : bottom_floors_)
|
||||
{
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 255, 0, 0, 0xFF);
|
||||
@@ -532,7 +532,7 @@ void Room::fillMapTexture()
|
||||
// TopSurfaces
|
||||
if (true)
|
||||
{
|
||||
for (auto l : top_surfaces_)
|
||||
for (auto l : top_floors_)
|
||||
{
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 255, 0, 0xFF);
|
||||
@@ -543,7 +543,7 @@ void Room::fillMapTexture()
|
||||
// LeftSurfaces
|
||||
if (true)
|
||||
{
|
||||
for (auto l : left_surfaces_)
|
||||
for (auto l : left_walls_)
|
||||
{
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 128, 128, 255, 0xFF);
|
||||
@@ -554,7 +554,7 @@ void Room::fillMapTexture()
|
||||
// RightSurfaces
|
||||
if (true)
|
||||
{
|
||||
for (auto l : right_surfaces_)
|
||||
for (auto l : right_walls_)
|
||||
{
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 255, 255, 0, 0xFF);
|
||||
@@ -587,7 +587,7 @@ void Room::fillMapTexture()
|
||||
// AutoSurfaces
|
||||
if (true)
|
||||
{
|
||||
for (auto l : auto_surfaces_)
|
||||
for (auto l : conveyor_belt_floors_)
|
||||
{
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96, 0xFF);
|
||||
SDL_RenderDrawLine(Screen::get()->getRenderer(), l.x1, l.y, l.x2, l.y);
|
||||
@@ -604,7 +604,7 @@ void Room::renderMap()
|
||||
{
|
||||
// Dibuja la textura con el mapa en pantalla
|
||||
SDL_Rect dest = {0, 0, PLAY_AREA_WIDTH, PLAY_AREA_HEIGHT};
|
||||
SDL_RenderCopy(Screen::get()->getRenderer(), map_texture_, nullptr, &dest);
|
||||
SDL_RenderCopy(Screen::get()->getRenderer(), map_surface_, nullptr, &dest);
|
||||
|
||||
// Dibuja los tiles animados
|
||||
#ifdef DEBUG
|
||||
@@ -669,19 +669,19 @@ std::string Room::getRoom(int border)
|
||||
switch (border)
|
||||
{
|
||||
case BORDER_TOP:
|
||||
return room_top_;
|
||||
return upper_room_;
|
||||
break;
|
||||
|
||||
case BORDER_BOTTOM:
|
||||
return room_bottom_;
|
||||
return lower_room_;
|
||||
break;
|
||||
|
||||
case BORDER_RIGHT:
|
||||
return room_right_;
|
||||
return right_room_;
|
||||
break;
|
||||
|
||||
case BORDER_LEFT:
|
||||
return room_left_;
|
||||
return left_room_;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -861,7 +861,7 @@ void Room::setBottomSurfaces()
|
||||
}
|
||||
|
||||
line.x2 = ((tile[last_one] % MAP_WIDTH_) * TILE_SIZE_) + TILE_SIZE_ - 1;
|
||||
bottom_surfaces_.push_back(line);
|
||||
bottom_floors_.push_back(line);
|
||||
if (i <= (int)tile.size() - 1)
|
||||
{
|
||||
if (tile[i] == -1)
|
||||
@@ -923,7 +923,7 @@ void Room::setTopSurfaces()
|
||||
}
|
||||
|
||||
line.x2 = ((tile[last_one] % MAP_WIDTH_) * TILE_SIZE_) + TILE_SIZE_ - 1;
|
||||
top_surfaces_.push_back(line);
|
||||
top_floors_.push_back(line);
|
||||
if (i <= (int)tile.size() - 1)
|
||||
{
|
||||
if (tile[i] == -1)
|
||||
@@ -977,7 +977,7 @@ void Room::setLeftSurfaces()
|
||||
i++;
|
||||
}
|
||||
line.y2 = ((tile[i] / MAP_WIDTH_) * TILE_SIZE_) + TILE_SIZE_ - 1;
|
||||
left_surfaces_.push_back(line);
|
||||
left_walls_.push_back(line);
|
||||
i++;
|
||||
} while (i < (int)tile.size() - 1);
|
||||
}
|
||||
@@ -1025,7 +1025,7 @@ void Room::setRightSurfaces()
|
||||
i++;
|
||||
}
|
||||
line.y2 = ((tile[i] / MAP_WIDTH_) * TILE_SIZE_) + TILE_SIZE_ - 1;
|
||||
right_surfaces_.push_back(line);
|
||||
right_walls_.push_back(line);
|
||||
i++;
|
||||
} while (i < (int)tile.size() - 1);
|
||||
}
|
||||
@@ -1160,7 +1160,7 @@ void Room::setAutoSurfaces()
|
||||
}
|
||||
|
||||
line.x2 = ((tile[last_one] % MAP_WIDTH_) * TILE_SIZE_) + TILE_SIZE_ - 1;
|
||||
auto_surfaces_.push_back(line);
|
||||
conveyor_belt_floors_.push_back(line);
|
||||
if (i <= (int)tile.size() - 1)
|
||||
{
|
||||
if (tile[i] == -1)
|
||||
@@ -1189,7 +1189,7 @@ void Room::setAnimatedTiles()
|
||||
const int yc = (tile_map_[i] / tile_set_width_) * TILE_SIZE_;
|
||||
|
||||
AnimatedTile at;
|
||||
at.sprite = std::make_shared<Sprite>(texture_, x, y, 8, 8);
|
||||
at.sprite = std::make_shared<SSprite>(surface_, x, y, 8, 8);
|
||||
at.sprite->setClip(xc, yc, 8, 8);
|
||||
at.x_orig = xc;
|
||||
animated_tiles_.push_back(at);
|
||||
@@ -1202,7 +1202,7 @@ void Room::updateAnimatedTiles()
|
||||
{
|
||||
const int numFrames = 4;
|
||||
int offset = 0;
|
||||
if (auto_surface_direction_ == -1)
|
||||
if (conveyor_belt_direction_ == -1)
|
||||
{
|
||||
offset = ((counter_ / 3) % numFrames * TILE_SIZE_);
|
||||
}
|
||||
@@ -1231,7 +1231,7 @@ void Room::renderAnimatedTiles()
|
||||
// Comprueba las colisiones
|
||||
int Room::checkRightSurfaces(SDL_Rect *rect)
|
||||
{
|
||||
for (const auto &s : right_surfaces_)
|
||||
for (const auto &s : right_walls_)
|
||||
{
|
||||
if (checkCollision(s, *rect))
|
||||
{
|
||||
@@ -1245,7 +1245,7 @@ int Room::checkRightSurfaces(SDL_Rect *rect)
|
||||
// Comprueba las colisiones
|
||||
int Room::checkLeftSurfaces(SDL_Rect *rect)
|
||||
{
|
||||
for (const auto &s : left_surfaces_)
|
||||
for (const auto &s : left_walls_)
|
||||
{
|
||||
if (checkCollision(s, *rect))
|
||||
{
|
||||
@@ -1259,7 +1259,7 @@ int Room::checkLeftSurfaces(SDL_Rect *rect)
|
||||
// Comprueba las colisiones
|
||||
int Room::checkTopSurfaces(SDL_Rect *rect)
|
||||
{
|
||||
for (const auto &s : top_surfaces_)
|
||||
for (const auto &s : top_floors_)
|
||||
{
|
||||
if (checkCollision(s, *rect))
|
||||
{
|
||||
@@ -1273,7 +1273,7 @@ int Room::checkTopSurfaces(SDL_Rect *rect)
|
||||
// Comprueba las colisiones
|
||||
int Room::checkBottomSurfaces(SDL_Rect *rect)
|
||||
{
|
||||
for (const auto &s : bottom_surfaces_)
|
||||
for (const auto &s : bottom_floors_)
|
||||
{
|
||||
if (checkCollision(s, *rect))
|
||||
{
|
||||
@@ -1287,7 +1287,7 @@ int Room::checkBottomSurfaces(SDL_Rect *rect)
|
||||
// Comprueba las colisiones
|
||||
int Room::checkAutoSurfaces(SDL_Rect *rect)
|
||||
{
|
||||
for (const auto &s : auto_surfaces_)
|
||||
for (const auto &s : conveyor_belt_floors_)
|
||||
{
|
||||
if (checkCollision(s, *rect))
|
||||
{
|
||||
@@ -1301,7 +1301,7 @@ int Room::checkAutoSurfaces(SDL_Rect *rect)
|
||||
// Comprueba las colisiones
|
||||
bool Room::checkTopSurfaces(SDL_Point *p)
|
||||
{
|
||||
for (const auto &s : top_surfaces_)
|
||||
for (const auto &s : top_floors_)
|
||||
{
|
||||
if (checkCollision(s, *p))
|
||||
{
|
||||
@@ -1315,7 +1315,7 @@ bool Room::checkTopSurfaces(SDL_Point *p)
|
||||
// Comprueba las colisiones
|
||||
bool Room::checkAutoSurfaces(SDL_Point *p)
|
||||
{
|
||||
for (const auto &s : auto_surfaces_)
|
||||
for (const auto &s : conveyor_belt_floors_)
|
||||
{
|
||||
if (checkCollision(s, *p))
|
||||
{
|
||||
|
||||
104
source/room.h
104
source/room.h
@@ -1,20 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL_rect.h> // for SDL_Rect, SDL_Point
|
||||
#include <SDL2/SDL_render.h> // for SDL_Texture
|
||||
#include <memory> // for shared_ptr
|
||||
#include <string> // for string
|
||||
#include <vector> // for vector
|
||||
#include "enemy.h" // for EnemyData
|
||||
#include "item.h" // for ItemData
|
||||
#include "options.h" // for Options, OptionsVideo, options
|
||||
#include "utils.h" // for stringToColor, Color
|
||||
class Sprite; // lines 17-17
|
||||
class Texture; // lines 18-18
|
||||
struct JA_Sound_t; // lines 19-19
|
||||
struct ScoreboardData; // lines 20-20
|
||||
|
||||
|
||||
#include <SDL2/SDL_rect.h> // for SDL_Rect, SDL_Point
|
||||
#include <SDL2/SDL_render.h> // for SDL_Texture
|
||||
#include <memory> // for shared_ptr
|
||||
#include <string> // for string
|
||||
#include <vector> // for vector
|
||||
#include "enemy.h" // for EnemyData
|
||||
#include "item.h" // for ItemData
|
||||
#include "options.h" // for Options, OptionsVideo, options
|
||||
#include "utils.h" // for stringToColor, Color
|
||||
class SSprite; // lines 17-17
|
||||
class Surface; // lines 18-18
|
||||
struct JA_Sound_t; // lines 19-19
|
||||
struct ScoreboardData; // lines 20-20
|
||||
|
||||
enum class TileType
|
||||
{
|
||||
@@ -29,8 +27,8 @@ enum class TileType
|
||||
|
||||
struct AnimatedTile
|
||||
{
|
||||
std::shared_ptr<Sprite> sprite; // Sprite para dibujar el tile
|
||||
int x_orig; // Poicion X donde se encuentra el primer tile de la animacion en la tilesheet
|
||||
std::shared_ptr<SSprite> sprite; // SSprite para dibujar el tile
|
||||
int x_orig; // Poicion X donde se encuentra el primer tile de la animacion en la tilesheet
|
||||
};
|
||||
|
||||
struct RoomData
|
||||
@@ -41,13 +39,13 @@ struct RoomData
|
||||
std::string border_color; // Color del borde de la pantalla
|
||||
std::string item_color1; // Color 1 para los items de la habitación
|
||||
std::string item_color2; // Color 2 para los items de la habitación
|
||||
std::string room_top; // Identificador de la habitación que se encuentra arriba
|
||||
std::string room_bottom; // Identificador de la habitación que se encuentra abajp
|
||||
std::string room_left; // Identificador de la habitación que se encuentra a la izquierda
|
||||
std::string room_right; // Identificador de la habitación que se encuentra a la derecha
|
||||
std::string upper_room; // Identificador de la habitación que se encuentra arriba
|
||||
std::string lower_room; // Identificador de la habitación que se encuentra abajp
|
||||
std::string left_room; // Identificador de la habitación que se encuentra a la izquierda
|
||||
std::string right_room; // Identificador de la habitación que se encuentra a la derecha
|
||||
std::string tile_set_file; // Imagen con los graficos para la habitación
|
||||
std::string tile_map_file; // Fichero con el mapa de indices de tile
|
||||
int auto_surface_direction; // Sentido en el que arrastran las superficies automáticas de la habitación
|
||||
int conveyor_belt_direction; // Sentido en el que arrastran las superficies automáticas de la habitación
|
||||
std::vector<int> tile_map; // Indice de los tiles a dibujar en la habitación
|
||||
std::vector<EnemyData> enemies; // Listado con los enemigos de la habitación
|
||||
std::vector<ItemData> items; // Listado con los items que hay en la habitación
|
||||
@@ -79,37 +77,37 @@ private:
|
||||
// Objetos y punteros
|
||||
std::vector<std::shared_ptr<Enemy>> enemies_; // Listado con los enemigos de la habitación
|
||||
std::vector<std::shared_ptr<Item>> items_; // Listado con los items que hay en la habitación
|
||||
std::shared_ptr<Texture> texture_; // Textura con los graficos de la habitación
|
||||
SDL_Texture *map_texture_; // Textura para dibujar el mapa de la habitación
|
||||
std::shared_ptr<Surface> surface_; // Textura con los graficos de la habitación
|
||||
SDL_Texture *map_surface_; // Textura para dibujar el mapa de la habitación
|
||||
std::shared_ptr<ScoreboardData> data_; // Puntero a los datos del marcador
|
||||
|
||||
// Variables
|
||||
std::string number_; // Numero de la habitación
|
||||
std::string name_; // Nombre de la habitación
|
||||
std::string bg_color_; // Color de fondo de la habitación
|
||||
std::string border_color_; // Color del borde de la pantalla
|
||||
std::string item_color1_; // Color 1 para los items de la habitación
|
||||
std::string item_color2_; // Color 2 para los items de la habitación
|
||||
std::string room_top_; // Identificador de la habitación que se encuentra arriba
|
||||
std::string room_bottom_; // Identificador de la habitación que se encuentra abajp
|
||||
std::string room_left_; // Identificador de la habitación que se encuentra a la izquierda
|
||||
std::string room_right_; // Identificador de la habitación que se encuentra a la derecha
|
||||
std::string tile_set_file_; // Imagen con los graficos para la habitación
|
||||
std::string tile_map_file_; // Fichero con el mapa de indices de tile
|
||||
std::vector<int> tile_map_; // Indice de los tiles a dibujar en la habitación
|
||||
int auto_surface_direction_; // Sentido en el que arrastran las superficies automáticas de la habitación
|
||||
JA_Sound_t *item_sound_; // Sonido producido al coger un objeto
|
||||
std::vector<LineHorizontal> bottom_surfaces_; // Lista con las superficies inferiores de la habitación
|
||||
std::vector<LineHorizontal> top_surfaces_; // Lista con las superficies superiores de la habitación
|
||||
std::vector<LineVertical> left_surfaces_; // Lista con las superficies laterales de la parte izquierda de la habitación
|
||||
std::vector<LineVertical> right_surfaces_; // Lista con las superficies laterales de la parte derecha de la habitación
|
||||
std::vector<LineDiagonal> left_slopes_; // Lista con todas las rampas que suben hacia la izquierda
|
||||
std::vector<LineDiagonal> right_slopes_; // Lista con todas las rampas que suben hacia la derecha
|
||||
int counter_; // Contador para lo que haga falta
|
||||
bool is_paused_; // Indica si el mapa esta en modo pausa
|
||||
std::vector<AnimatedTile> animated_tiles_; // Vector con los indices de tiles animados
|
||||
std::vector<LineHorizontal> auto_surfaces_; // Lista con las superficies automaticas de la habitación
|
||||
int tile_set_width_; // Ancho del tileset en tiles
|
||||
std::string number_; // Numero de la habitación
|
||||
std::string name_; // Nombre de la habitación
|
||||
std::string bg_color_; // Color de fondo de la habitación
|
||||
std::string border_color_; // Color del borde de la pantalla
|
||||
std::string item_color1_; // Color 1 para los items de la habitación
|
||||
std::string item_color2_; // Color 2 para los items de la habitación
|
||||
std::string upper_room_; // Identificador de la habitación que se encuentra arriba
|
||||
std::string lower_room_; // Identificador de la habitación que se encuentra abajp
|
||||
std::string left_room_; // Identificador de la habitación que se encuentra a la izquierda
|
||||
std::string right_room_; // Identificador de la habitación que se encuentra a la derecha
|
||||
std::string tile_set_file_; // Imagen con los graficos para la habitación
|
||||
std::string tile_map_file_; // Fichero con el mapa de indices de tile
|
||||
std::vector<int> tile_map_; // Indice de los tiles a dibujar en la habitación
|
||||
int conveyor_belt_direction_; // Sentido en el que arrastran las superficies automáticas de la habitación
|
||||
JA_Sound_t *item_sound_; // Sonido producido al coger un objeto
|
||||
std::vector<LineHorizontal> bottom_floors_; // Lista con las superficies inferiores de la habitación
|
||||
std::vector<LineHorizontal> top_floors_; // Lista con las superficies superiores de la habitación
|
||||
std::vector<LineVertical> left_walls_; // Lista con las superficies laterales de la parte izquierda de la habitación
|
||||
std::vector<LineVertical> right_walls_; // Lista con las superficies laterales de la parte derecha de la habitación
|
||||
std::vector<LineDiagonal> left_slopes_; // Lista con todas las rampas que suben hacia la izquierda
|
||||
std::vector<LineDiagonal> right_slopes_; // Lista con todas las rampas que suben hacia la derecha
|
||||
int counter_; // Contador para lo que haga falta
|
||||
bool is_paused_; // Indica si el mapa esta en modo pausa
|
||||
std::vector<AnimatedTile> animated_tiles_; // Vector con los indices de tiles animados
|
||||
std::vector<LineHorizontal> conveyor_belt_floors_; // Lista con las superficies automaticas de la habitación
|
||||
int tile_set_width_; // Ancho del tileset en tiles
|
||||
|
||||
void initializeRoom(const RoomData &room);
|
||||
|
||||
@@ -166,10 +164,10 @@ public:
|
||||
std::string getName() const { return name_; }
|
||||
|
||||
// Devuelve el color de la habitación
|
||||
Color getBGColor() const { return stringToColor(options.video.palette, bg_color_); }
|
||||
Uint8 getBGColor() const { return stringToColor(bg_color_); }
|
||||
|
||||
// Devuelve el color del borde
|
||||
Color getBorderColor() const { return stringToColor(options.video.palette, border_color_); }
|
||||
Uint8 getBorderColor() const { return stringToColor(border_color_); }
|
||||
|
||||
// Dibuja el mapa en pantalla
|
||||
void renderMap();
|
||||
@@ -238,5 +236,5 @@ public:
|
||||
void setPaused(bool value) { is_paused_ = value; };
|
||||
|
||||
// Obten la direccion de las superficies automaticas
|
||||
int getAutoSurfaceDirection() const { return auto_surface_direction_; }
|
||||
int getAutoSurfaceDirection() const { return conveyor_belt_direction_; }
|
||||
};
|
||||
@@ -201,7 +201,7 @@ bool Screen::incWindowZoom()
|
||||
}
|
||||
|
||||
// Cambia el color del borde
|
||||
void Screen::setBorderColor(Color color)
|
||||
void Screen::setBorderColor(Uint8 color)
|
||||
{
|
||||
border_color_ = color;
|
||||
auto temp = SDL_GetRenderTarget(renderer_);
|
||||
|
||||
@@ -37,7 +37,7 @@ private:
|
||||
int window_width_; // Ancho de la pantalla o ventana
|
||||
int window_height_; // Alto de la pantalla o ventana
|
||||
SDL_Rect game_texture_rect_; // Coordenadas donde se va a dibujar la textura del juego sobre la pantalla o ventana
|
||||
Color 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
|
||||
|
||||
// Dibuja las notificaciones
|
||||
void renderNotifications();
|
||||
@@ -106,7 +106,7 @@ public:
|
||||
bool incWindowZoom();
|
||||
|
||||
// Cambia el color del borde
|
||||
void setBorderColor(Color color);
|
||||
void setBorderColor(Uint8 color);
|
||||
|
||||
// Cambia el tipo de mezcla
|
||||
void setBlendMode(SDL_BlendMode blendMode);
|
||||
|
||||
@@ -278,7 +278,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
|
||||
void Surface::renderWithColorReplace(int x, int y, Uint8 source_color = 0, Uint8 target_color = 0, SDL_Rect *clip = nullptr, SDL_RendererFlip flip = SDL_FLIP_NONE)
|
||||
void Surface::renderWithColorReplace(int x, int y, Uint8 source_color, Uint8 target_color, SDL_Rect *srcRect, SDL_RendererFlip flip)
|
||||
{
|
||||
if (!surface_data_ || !surface_data_dest_)
|
||||
{
|
||||
@@ -286,10 +286,10 @@ void Surface::renderWithColorReplace(int x, int y, Uint8 source_color = 0, Uint8
|
||||
}
|
||||
|
||||
// Determina la región de origen (clip) a renderizar
|
||||
int sx = (clip) ? clip->x : 0;
|
||||
int sy = (clip) ? clip->y : 0;
|
||||
int w = (clip) ? clip->w : surface_data_->width;
|
||||
int h = (clip) ? clip->h : surface_data_->height;
|
||||
int sx = (srcRect) ? srcRect->x : 0;
|
||||
int sy = (srcRect) ? srcRect->y : 0;
|
||||
int w = (srcRect) ? srcRect->w : surface_data_->width;
|
||||
int h = (srcRect) ? srcRect->h : surface_data_->height;
|
||||
|
||||
// Limitar la región para evitar accesos fuera de rango
|
||||
w = std::min(w, surface_data_->width - sx);
|
||||
|
||||
@@ -43,7 +43,7 @@ Title::Title()
|
||||
createCheevosTexture();
|
||||
|
||||
// Cambia el color del borde
|
||||
Screen::get()->setBorderColor(stringToColor(options.video.palette, "black"));
|
||||
Screen::get()->setBorderColor(stringToColor("black"));
|
||||
|
||||
// Rellena la textura de fondo con todos los gráficos
|
||||
fillSurface();
|
||||
@@ -177,7 +177,7 @@ void Title::renderMarquee()
|
||||
{
|
||||
if (l.enabled)
|
||||
{
|
||||
TEXT->writeColored(l.x, 184, l.letter, stringToColor(options.video.palette, "white"));
|
||||
TEXT->writeColored(l.x, 184, l.letter, stringToColor("white"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -322,7 +322,7 @@ void Title::fillSurface()
|
||||
|
||||
// Escribe el texto en la textura
|
||||
auto text = Resource::get()->getText("smb2");
|
||||
const Color COLOR = stringToColor(options.video.palette, "green");
|
||||
const Uint8 COLOR = stringToColor("green");
|
||||
const int TEXT_SIZE = text->getCharacterSize();
|
||||
text->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 11 * TEXT_SIZE, "1.PLAY", 1, COLOR);
|
||||
text->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 13 * TEXT_SIZE, "2.ACHIEVEMENTS", 1, COLOR);
|
||||
@@ -351,7 +351,7 @@ void Title::createCheevosTexture()
|
||||
Screen::get()->setRenderSurfaceData(cheevos_surface_);
|
||||
|
||||
// Rellena la textura con color sólido
|
||||
const Color CHEEVOS_BG_COLOR = stringToColor(options.video.palette, "black");
|
||||
const Uint8 CHEEVOS_BG_COLOR = stringToColor("black");
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), CHEEVOS_BG_COLOR.r, CHEEVOS_BG_COLOR.g, CHEEVOS_BG_COLOR.b, 0xFF);
|
||||
SDL_RenderClear(Screen::get()->getRenderer());
|
||||
|
||||
@@ -361,9 +361,9 @@ void Title::createCheevosTexture()
|
||||
int pos = 2;
|
||||
TEXT->writeDX(TEXT_CENTER | TEXT_COLOR, cheevos_surface_->getWidth() / 2, pos, CHEEVOS_LIST_CAPTION, 1, stringToColor(options.video.palette, "bright_green"));
|
||||
pos += TEXT->getCharacterSize();
|
||||
const Color CHEEVO_LOCKED_COLOR = stringToColor(options.video.palette, "white");
|
||||
const Color CHEEVO_UNLOCKED_COLOR = stringToColor(options.video.palette, "bright_green");
|
||||
Color cheevoColor;
|
||||
const Uint8 CHEEVO_LOCKED_COLOR = stringToColor("white");
|
||||
const Uint8 CHEEVO_UNLOCKED_COLOR = stringToColor("bright_green");
|
||||
Uint8 cheevoColor;
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), CHEEVO_LOCKED_COLOR.r, CHEEVO_LOCKED_COLOR.g, CHEEVO_LOCKED_COLOR.b, 0xFF);
|
||||
constexpr int LINE_X1 = (CHEEVOS_TEXTURE_WIDTH / 7) * 3;
|
||||
constexpr int LINE_X2 = LINE_X1 + ((CHEEVOS_TEXTURE_WIDTH / 7) * 1);
|
||||
|
||||
Reference in New Issue
Block a user