forked from jaildesigner-jailgames/jaildoctors_dilemma
style: arreglant capçaleres
This commit is contained in:
@@ -24,9 +24,9 @@ LoadingScreen::LoadingScreen()
|
|||||||
color_loading_screen_sprite_(std::make_shared<SurfaceSprite>(color_loading_screen_surface_, 0, 0, color_loading_screen_surface_->getWidth(), color_loading_screen_surface_->getHeight())),
|
color_loading_screen_sprite_(std::make_shared<SurfaceSprite>(color_loading_screen_surface_, 0, 0, color_loading_screen_surface_->getWidth(), color_loading_screen_surface_->getHeight())),
|
||||||
screen_surface_(std::make_shared<Surface>(Options::game.width, Options::game.height)),
|
screen_surface_(std::make_shared<Surface>(Options::game.width, Options::game.height)),
|
||||||
delta_timer_(std::make_unique<DeltaTimer>()),
|
delta_timer_(std::make_unique<DeltaTimer>()),
|
||||||
state_(LoadingState::SILENT1),
|
state_(State::SILENT1),
|
||||||
state_time_(0.0F),
|
state_time_(0.0F),
|
||||||
current_border_type_(BorderType::NONE),
|
current_border_type_(Border::NONE),
|
||||||
load_rect_{0, 0, 0, 1.0F} {
|
load_rect_{0, 0, 0, 1.0F} {
|
||||||
// Configura la superficie donde se van a pintar los sprites
|
// Configura la superficie donde se van a pintar los sprites
|
||||||
screen_surface_->clear(static_cast<Uint8>(PaletteColor::WHITE));
|
screen_surface_->clear(static_cast<Uint8>(PaletteColor::WHITE));
|
||||||
@@ -40,7 +40,7 @@ LoadingScreen::LoadingScreen()
|
|||||||
|
|
||||||
// Cambia el color del borde
|
// Cambia el color del borde
|
||||||
Screen::get()->setBorderColor(stringToColor("white"));
|
Screen::get()->setBorderColor(stringToColor("white"));
|
||||||
transitionToState(LoadingState::SILENT1);
|
transitionToState(State::SILENT1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
@@ -75,41 +75,41 @@ void LoadingScreen::initLineIndexArray() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Transiciona a un nuevo estado
|
// Transiciona a un nuevo estado
|
||||||
void LoadingScreen::transitionToState(LoadingState new_state) {
|
void LoadingScreen::transitionToState(State new_state) {
|
||||||
state_ = new_state;
|
state_ = new_state;
|
||||||
state_time_ = 0.0F;
|
state_time_ = 0.0F;
|
||||||
|
|
||||||
// Acciones específicas al entrar en cada estado
|
// Acciones específicas al entrar en cada estado
|
||||||
switch (new_state) {
|
switch (new_state) {
|
||||||
case LoadingState::SILENT1:
|
case State::SILENT1:
|
||||||
case LoadingState::SILENT2:
|
case State::SILENT2:
|
||||||
current_border_type_ = BorderType::WHITE;
|
current_border_type_ = Border::WHITE;
|
||||||
Audio::get()->stopMusic();
|
Audio::get()->stopMusic();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LoadingState::HEADER1:
|
case State::HEADER1:
|
||||||
case LoadingState::HEADER2:
|
case State::HEADER2:
|
||||||
current_border_type_ = BorderType::RED;
|
current_border_type_ = Border::RED;
|
||||||
// Reproducir sonido de cargar el header
|
// Reproducir sonido de cargar el header
|
||||||
Audio::get()->playMusic("loading_sound1.ogg");
|
Audio::get()->playMusic("loading_sound1.ogg");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LoadingState::BYTES1:
|
case State::BYTES1:
|
||||||
case LoadingState::BYTES2:
|
case State::BYTES2:
|
||||||
case LoadingState::LOADING_MONO:
|
case State::LOADING_MONO:
|
||||||
current_border_type_ = BorderType::YELLOW;
|
current_border_type_ = Border::YELLOW;
|
||||||
// Reproducir sonido de carga monocromática
|
// Reproducir sonido de carga monocromática
|
||||||
Audio::get()->playMusic("loading_sound2.ogg");
|
Audio::get()->playMusic("loading_sound2.ogg");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LoadingState::LOADING_COLOR:
|
case State::LOADING_COLOR:
|
||||||
current_border_type_ = BorderType::YELLOW;
|
current_border_type_ = Border::YELLOW;
|
||||||
// Reproducir sonido de carga en color
|
// Reproducir sonido de carga en color
|
||||||
Audio::get()->playMusic("loading_sound3.ogg");
|
Audio::get()->playMusic("loading_sound3.ogg");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LoadingState::COMPLETE:
|
case State::COMPLETE:
|
||||||
current_border_type_ = BorderType::WHITE;
|
current_border_type_ = Border::WHITE;
|
||||||
// Transicionar a la pantalla de título
|
// Transicionar a la pantalla de título
|
||||||
SceneManager::current = SceneManager::Scene::TITLE;
|
SceneManager::current = SceneManager::Scene::TITLE;
|
||||||
SceneManager::options = SceneManager::Options::TITLE_WITH_LOADING_SCREEN;
|
SceneManager::options = SceneManager::Options::TITLE_WITH_LOADING_SCREEN;
|
||||||
@@ -125,45 +125,45 @@ void LoadingScreen::updateState(float delta_time) {
|
|||||||
// Transiciones automáticas por tiempo para los estados iniciales
|
// Transiciones automáticas por tiempo para los estados iniciales
|
||||||
// LOADING_MONO y LOADING_COLOR transicionan en sus propias funciones
|
// LOADING_MONO y LOADING_COLOR transicionan en sus propias funciones
|
||||||
switch (state_) {
|
switch (state_) {
|
||||||
case LoadingState::SILENT1:
|
case State::SILENT1:
|
||||||
if (state_time_ >= SILENT1_DURATION) {
|
if (state_time_ >= SILENT1_DURATION) {
|
||||||
transitionToState(LoadingState::HEADER1);
|
transitionToState(State::HEADER1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LoadingState::HEADER1:
|
case State::HEADER1:
|
||||||
if (state_time_ >= HEADER1_DURATION) {
|
if (state_time_ >= HEADER1_DURATION) {
|
||||||
transitionToState(LoadingState::BYTES1);
|
transitionToState(State::BYTES1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LoadingState::BYTES1:
|
case State::BYTES1:
|
||||||
if (state_time_ >= BYTES1_DURATION) {
|
if (state_time_ >= BYTES1_DURATION) {
|
||||||
transitionToState(LoadingState::SILENT2);
|
transitionToState(State::SILENT2);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LoadingState::SILENT2:
|
case State::SILENT2:
|
||||||
if (state_time_ >= SILENT2_DURATION) {
|
if (state_time_ >= SILENT2_DURATION) {
|
||||||
transitionToState(LoadingState::HEADER2);
|
transitionToState(State::HEADER2);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LoadingState::HEADER2:
|
case State::HEADER2:
|
||||||
if (state_time_ >= HEADER2_DURATION) {
|
if (state_time_ >= HEADER2_DURATION) {
|
||||||
transitionToState(LoadingState::LOADING_MONO);
|
transitionToState(State::LOADING_MONO);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LoadingState::BYTES2:
|
case State::BYTES2:
|
||||||
if (state_time_ >= BYTES2_DURATION) {
|
if (state_time_ >= BYTES2_DURATION) {
|
||||||
transitionToState(LoadingState::COMPLETE);
|
transitionToState(State::COMPLETE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LoadingState::LOADING_MONO:
|
case State::LOADING_MONO:
|
||||||
case LoadingState::LOADING_COLOR:
|
case State::LOADING_COLOR:
|
||||||
case LoadingState::COMPLETE:
|
case State::COMPLETE:
|
||||||
// Estos estados se gestionan en updateMonoLoad/updateColorLoad
|
// Estos estados se gestionan en updateMonoLoad/updateColorLoad
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -185,7 +185,7 @@ void LoadingScreen::updateMonoLoad(float delta_time) {
|
|||||||
|
|
||||||
// Verificar si ha completado todas las líneas
|
// Verificar si ha completado todas las líneas
|
||||||
if (CURRENT_LINE >= MONO_TOTAL_LINES) {
|
if (CURRENT_LINE >= MONO_TOTAL_LINES) {
|
||||||
transitionToState(LoadingState::LOADING_COLOR);
|
transitionToState(State::LOADING_COLOR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,7 +224,7 @@ void LoadingScreen::updateColorLoad(float delta_time) {
|
|||||||
|
|
||||||
// Verificar si ha completado todos los bloques
|
// Verificar si ha completado todos los bloques
|
||||||
if (CURRENT_BLOCK >= COLOR_TOTAL_BLOCKS) {
|
if (CURRENT_BLOCK >= COLOR_TOTAL_BLOCKS) {
|
||||||
transitionToState(LoadingState::BYTES2);
|
transitionToState(State::BYTES2);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -328,25 +328,25 @@ void LoadingScreen::update() {
|
|||||||
|
|
||||||
// Actualizar la carga según el estado actual
|
// Actualizar la carga según el estado actual
|
||||||
switch (state_) {
|
switch (state_) {
|
||||||
case LoadingState::SILENT1:
|
case State::SILENT1:
|
||||||
case LoadingState::HEADER1:
|
case State::HEADER1:
|
||||||
case LoadingState::BYTES1:
|
case State::BYTES1:
|
||||||
case LoadingState::SILENT2:
|
case State::SILENT2:
|
||||||
case LoadingState::HEADER2:
|
case State::HEADER2:
|
||||||
case LoadingState::BYTES2:
|
case State::BYTES2:
|
||||||
// Por ahora no hacen nada específico
|
// Por ahora no hacen nada específico
|
||||||
// Tú definirás la lógica de cada estado aquí
|
// Tú definirás la lógica de cada estado aquí
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LoadingState::LOADING_MONO:
|
case State::LOADING_MONO:
|
||||||
updateMonoLoad(DELTA_TIME);
|
updateMonoLoad(DELTA_TIME);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LoadingState::LOADING_COLOR:
|
case State::LOADING_COLOR:
|
||||||
updateColorLoad(DELTA_TIME);
|
updateColorLoad(DELTA_TIME);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LoadingState::COMPLETE:
|
case State::COMPLETE:
|
||||||
// No hay más actualizaciones
|
// No hay más actualizaciones
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -396,16 +396,16 @@ void LoadingScreen::renderBorder() {
|
|||||||
if (Options::video.border.enabled) {
|
if (Options::video.border.enabled) {
|
||||||
// Dibuja el efecto de carga en el borde según el tipo actual
|
// Dibuja el efecto de carga en el borde según el tipo actual
|
||||||
switch (current_border_type_) {
|
switch (current_border_type_) {
|
||||||
case BorderType::YELLOW:
|
case Border::YELLOW:
|
||||||
renderYellowBorder();
|
renderYellowBorder();
|
||||||
break;
|
break;
|
||||||
case BorderType::RED:
|
case Border::RED:
|
||||||
renderRedBorder();
|
renderRedBorder();
|
||||||
break;
|
break;
|
||||||
case BorderType::WHITE:
|
case Border::WHITE:
|
||||||
renderWhiteBorder();
|
renderWhiteBorder();
|
||||||
break;
|
break;
|
||||||
case BorderType::NONE:
|
case Border::NONE:
|
||||||
// No renderizar borde
|
// No renderizar borde
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,10 @@
|
|||||||
class SurfaceSprite; // Forward declaration
|
class SurfaceSprite; // Forward declaration
|
||||||
class Surface; // Forward declaration
|
class Surface; // Forward declaration
|
||||||
|
|
||||||
// Estados de la secuencia de carga
|
class LoadingScreen {
|
||||||
enum class LoadingState {
|
public:
|
||||||
|
// Estados de la secuencia de carga
|
||||||
|
enum class State {
|
||||||
SILENT1, // Pausa inicial antes de empezar
|
SILENT1, // Pausa inicial antes de empezar
|
||||||
HEADER1, // Cabecera
|
HEADER1, // Cabecera
|
||||||
BYTES1, // Datos
|
BYTES1, // Datos
|
||||||
@@ -20,21 +22,22 @@ enum class LoadingState {
|
|||||||
LOADING_COLOR, // Carga de pantalla en color (bloques)
|
LOADING_COLOR, // Carga de pantalla en color (bloques)
|
||||||
BYTES2, // Datos
|
BYTES2, // Datos
|
||||||
COMPLETE // Carga completa
|
COMPLETE // Carga completa
|
||||||
};
|
};
|
||||||
|
|
||||||
// Tipos de borde para la pantalla de carga
|
// Tipos de borde para la pantalla de carga
|
||||||
enum class BorderType {
|
enum class Border {
|
||||||
NONE,
|
NONE,
|
||||||
YELLOW,
|
YELLOW,
|
||||||
RED,
|
RED,
|
||||||
WHITE
|
WHITE
|
||||||
};
|
};
|
||||||
|
|
||||||
class LoadingScreen {
|
// --- Constructor y Destructor ---
|
||||||
public:
|
LoadingScreen();
|
||||||
LoadingScreen(); // Constructor
|
~LoadingScreen();
|
||||||
~LoadingScreen(); // Destructor
|
|
||||||
void run(); // Bucle principal
|
// --- Bucle principal ---
|
||||||
|
void run();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// --- Constantes de tiempo (en segundos) ---
|
// --- Constantes de tiempo (en segundos) ---
|
||||||
@@ -65,9 +68,9 @@ class LoadingScreen {
|
|||||||
|
|
||||||
// --- Variables de estado ---
|
// --- Variables de estado ---
|
||||||
std::unique_ptr<DeltaTimer> delta_timer_; // Timer para delta time
|
std::unique_ptr<DeltaTimer> delta_timer_; // Timer para delta time
|
||||||
LoadingState state_; // Estado actual de la secuencia
|
State state_; // Estado actual de la secuencia
|
||||||
float state_time_; // Tiempo acumulado en el estado actual
|
float state_time_; // Tiempo acumulado en el estado actual
|
||||||
BorderType current_border_type_; // Tipo de borde actual
|
Border current_border_type_; // Tipo de borde actual
|
||||||
std::array<int, MONO_TOTAL_LINES> line_index_; // El orden en el que se procesan las 192 líneas de la pantalla de carga
|
std::array<int, MONO_TOTAL_LINES> line_index_; // El orden en el que se procesan las 192 líneas de la pantalla de carga
|
||||||
SDL_FRect load_rect_; // Rectángulo para dibujar la pantalla de carga
|
SDL_FRect load_rect_; // Rectángulo para dibujar la pantalla de carga
|
||||||
|
|
||||||
@@ -77,7 +80,7 @@ class LoadingScreen {
|
|||||||
static void checkEvents(); // Comprueba el manejador de eventos
|
static void checkEvents(); // Comprueba el manejador de eventos
|
||||||
static void checkInput(); // Comprueba las entradas
|
static void checkInput(); // Comprueba las entradas
|
||||||
void updateState(float delta_time); // Actualiza el estado actual
|
void updateState(float delta_time); // Actualiza el estado actual
|
||||||
void transitionToState(LoadingState new_state); // Transiciona a un nuevo estado
|
void transitionToState(State new_state); // Transiciona a un nuevo estado
|
||||||
void updateMonoLoad(float delta_time); // Gestiona la carga monocromática (time-based)
|
void updateMonoLoad(float delta_time); // Gestiona la carga monocromática (time-based)
|
||||||
void updateColorLoad(float delta_time); // Gestiona la carga en color (time-based)
|
void updateColorLoad(float delta_time); // Gestiona la carga en color (time-based)
|
||||||
void renderBorder(); // Pinta el borde
|
void renderBorder(); // Pinta el borde
|
||||||
|
|||||||
@@ -9,10 +9,10 @@
|
|||||||
#include "core/rendering/surface.hpp" // Para Surface
|
#include "core/rendering/surface.hpp" // Para Surface
|
||||||
#include "core/rendering/surface_sprite.hpp" // Para SSprite
|
#include "core/rendering/surface_sprite.hpp" // Para SSprite
|
||||||
#include "core/resources/resource.hpp" // Para Resource
|
#include "core/resources/resource.hpp" // Para Resource
|
||||||
|
#include "core/system/global_events.hpp" // Para check
|
||||||
#include "game/options.hpp" // Para Options, SectionState, options, Section
|
#include "game/options.hpp" // Para Options, SectionState, options, Section
|
||||||
#include "game/scene_manager.hpp" // Para SceneManager
|
#include "game/scene_manager.hpp" // Para SceneManager
|
||||||
#include "utils/delta_timer.hpp" // Para DeltaTimer
|
#include "utils/delta_timer.hpp" // Para DeltaTimer
|
||||||
#include "core/system/global_events.hpp" // Para check
|
|
||||||
#include "utils/utils.hpp" // Para PaletteColor
|
#include "utils/utils.hpp" // Para PaletteColor
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
@@ -21,7 +21,7 @@ Logo::Logo()
|
|||||||
since_1998_surface_(Resource::get()->getSurface("since_1998.gif")),
|
since_1998_surface_(Resource::get()->getSurface("since_1998.gif")),
|
||||||
since_1998_sprite_(std::make_shared<SurfaceSprite>(since_1998_surface_, (256 - since_1998_surface_->getWidth()) / 2, 83 + jailgames_surface_->getHeight() + 5, since_1998_surface_->getWidth(), since_1998_surface_->getHeight())),
|
since_1998_sprite_(std::make_shared<SurfaceSprite>(since_1998_surface_, (256 - since_1998_surface_->getWidth()) / 2, 83 + jailgames_surface_->getHeight() + 5, since_1998_surface_->getWidth(), since_1998_surface_->getHeight())),
|
||||||
delta_timer_(std::make_unique<DeltaTimer>()),
|
delta_timer_(std::make_unique<DeltaTimer>()),
|
||||||
state_(LogoState::INITIAL),
|
state_(State::INITIAL),
|
||||||
state_time_(0.0F) {
|
state_time_(0.0F) {
|
||||||
// Configura variables
|
// Configura variables
|
||||||
since_1998_sprite_->setClip(0, 0, since_1998_surface_->getWidth(), since_1998_surface_->getHeight());
|
since_1998_sprite_->setClip(0, 0, since_1998_surface_->getWidth(), since_1998_surface_->getHeight());
|
||||||
@@ -54,7 +54,7 @@ void Logo::checkInput() {
|
|||||||
// Gestiona el logo de JAILGAME (time-based)
|
// Gestiona el logo de JAILGAME (time-based)
|
||||||
void Logo::updateJAILGAMES(float delta_time) {
|
void Logo::updateJAILGAMES(float delta_time) {
|
||||||
// Solo actualizar durante el estado JAILGAMES_SLIDE_IN
|
// Solo actualizar durante el estado JAILGAMES_SLIDE_IN
|
||||||
if (state_ != LogoState::JAILGAMES_SLIDE_IN) {
|
if (state_ != State::JAILGAMES_SLIDE_IN) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,21 +97,21 @@ auto Logo::getColorIndex(float progress) const -> int {
|
|||||||
// Gestiona el color de las texturas
|
// Gestiona el color de las texturas
|
||||||
void Logo::updateTextureColors() {
|
void Logo::updateTextureColors() {
|
||||||
switch (state_) {
|
switch (state_) {
|
||||||
case LogoState::SINCE_1998_FADE_IN: {
|
case State::SINCE_1998_FADE_IN: {
|
||||||
// Fade-in de "Since 1998" de negro a blanco
|
// Fade-in de "Since 1998" de negro a blanco
|
||||||
const float PROGRESS = state_time_ / SINCE_1998_FADE_DURATION;
|
const float PROGRESS = state_time_ / SINCE_1998_FADE_DURATION;
|
||||||
since_1998_color_ = color_[getColorIndex(PROGRESS)];
|
since_1998_color_ = color_[getColorIndex(PROGRESS)];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case LogoState::DISPLAY: {
|
case State::DISPLAY: {
|
||||||
// Asegurar que ambos logos estén en blanco durante el display
|
// Asegurar que ambos logos estén en blanco durante el display
|
||||||
jailgames_color_ = color_.back(); // BRIGHT_WHITE
|
jailgames_color_ = color_.back(); // BRIGHT_WHITE
|
||||||
since_1998_color_ = color_.back(); // BRIGHT_WHITE
|
since_1998_color_ = color_.back(); // BRIGHT_WHITE
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case LogoState::FADE_OUT: {
|
case State::FADE_OUT: {
|
||||||
// Fade-out de ambos logos de blanco a negro
|
// Fade-out de ambos logos de blanco a negro
|
||||||
const float PROGRESS = 1.0F - (state_time_ / FADE_OUT_DURATION);
|
const float PROGRESS = 1.0F - (state_time_ / FADE_OUT_DURATION);
|
||||||
const int COLOR_INDEX = getColorIndex(PROGRESS);
|
const int COLOR_INDEX = getColorIndex(PROGRESS);
|
||||||
@@ -127,7 +127,7 @@ void Logo::updateTextureColors() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Transiciona a un nuevo estado
|
// Transiciona a un nuevo estado
|
||||||
void Logo::transitionToState(LogoState new_state) {
|
void Logo::transitionToState(State new_state) {
|
||||||
state_ = new_state;
|
state_ = new_state;
|
||||||
state_time_ = 0.0F;
|
state_time_ = 0.0F;
|
||||||
}
|
}
|
||||||
@@ -138,38 +138,38 @@ void Logo::updateState(float delta_time) {
|
|||||||
|
|
||||||
// Gestionar transiciones entre estados basándose en el tiempo
|
// Gestionar transiciones entre estados basándose en el tiempo
|
||||||
switch (state_) {
|
switch (state_) {
|
||||||
case LogoState::INITIAL:
|
case State::INITIAL:
|
||||||
if (state_time_ >= INITIAL_DELAY) {
|
if (state_time_ >= INITIAL_DELAY) {
|
||||||
transitionToState(LogoState::JAILGAMES_SLIDE_IN);
|
transitionToState(State::JAILGAMES_SLIDE_IN);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LogoState::JAILGAMES_SLIDE_IN:
|
case State::JAILGAMES_SLIDE_IN:
|
||||||
if (state_time_ >= JAILGAMES_SLIDE_DURATION) {
|
if (state_time_ >= JAILGAMES_SLIDE_DURATION) {
|
||||||
transitionToState(LogoState::SINCE_1998_FADE_IN);
|
transitionToState(State::SINCE_1998_FADE_IN);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LogoState::SINCE_1998_FADE_IN:
|
case State::SINCE_1998_FADE_IN:
|
||||||
if (state_time_ >= SINCE_1998_FADE_DURATION) {
|
if (state_time_ >= SINCE_1998_FADE_DURATION) {
|
||||||
transitionToState(LogoState::DISPLAY);
|
transitionToState(State::DISPLAY);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LogoState::DISPLAY:
|
case State::DISPLAY:
|
||||||
if (state_time_ >= DISPLAY_DURATION) {
|
if (state_time_ >= DISPLAY_DURATION) {
|
||||||
transitionToState(LogoState::FADE_OUT);
|
transitionToState(State::FADE_OUT);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LogoState::FADE_OUT:
|
case State::FADE_OUT:
|
||||||
if (state_time_ >= FADE_OUT_DURATION) {
|
if (state_time_ >= FADE_OUT_DURATION) {
|
||||||
transitionToState(LogoState::END);
|
transitionToState(State::END);
|
||||||
endSection();
|
endSection();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LogoState::END:
|
case State::END:
|
||||||
// Estado final, no hacer nada
|
// Estado final, no hacer nada
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,21 +9,24 @@
|
|||||||
class SurfaceSprite; // Forward declaration
|
class SurfaceSprite; // Forward declaration
|
||||||
class Surface; // Forward declaration
|
class Surface; // Forward declaration
|
||||||
|
|
||||||
// Estados de la secuencia del logo
|
class Logo {
|
||||||
enum class LogoState {
|
public:
|
||||||
|
// --- Enumeraciones ---
|
||||||
|
enum class State {
|
||||||
INITIAL, // Espera inicial
|
INITIAL, // Espera inicial
|
||||||
JAILGAMES_SLIDE_IN, // Las líneas de JAILGAMES se deslizan hacia el centro
|
JAILGAMES_SLIDE_IN, // Las líneas de JAILGAMES se deslizan hacia el centro
|
||||||
SINCE_1998_FADE_IN, // Aparición gradual del texto "Since 1998"
|
SINCE_1998_FADE_IN, // Aparición gradual del texto "Since 1998"
|
||||||
DISPLAY, // Logo completo visible
|
DISPLAY, // Logo completo visible
|
||||||
FADE_OUT, // Desaparición gradual
|
FADE_OUT, // Desaparición gradual
|
||||||
END // Fin de la secuencia
|
END // Fin de la secuencia
|
||||||
};
|
};
|
||||||
|
|
||||||
class Logo {
|
// --- Constructor y Destructor ---
|
||||||
public:
|
Logo();
|
||||||
Logo(); // Constructor
|
~Logo() = default;
|
||||||
~Logo() = default; // Destructor
|
|
||||||
void run(); // Bucle principal
|
// --- Bucle principal ---
|
||||||
|
void run();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// --- Constantes de tiempo (en segundos) ---
|
// --- Constantes de tiempo (en segundos) ---
|
||||||
@@ -38,18 +41,18 @@ class Logo {
|
|||||||
static constexpr int JAILGAMES_DEST_X = 37; // Posición X de destino para JAILGAMES
|
static constexpr int JAILGAMES_DEST_X = 37; // Posición X de destino para JAILGAMES
|
||||||
|
|
||||||
// --- Objetos y punteros ---
|
// --- Objetos y punteros ---
|
||||||
std::shared_ptr<Surface> jailgames_surface_; // Textura con los graficos "JAILGAMES"
|
std::shared_ptr<Surface> jailgames_surface_ = nullptr; // Textura con los graficos "JAILGAMES"
|
||||||
std::shared_ptr<Surface> since_1998_surface_; // Textura con los graficos "Since 1998"
|
std::shared_ptr<Surface> since_1998_surface_ = nullptr; // Textura con los graficos "Since 1998"
|
||||||
std::vector<std::shared_ptr<SurfaceSprite>> jailgames_sprite_; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES
|
std::vector<std::shared_ptr<SurfaceSprite>> jailgames_sprite_; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES
|
||||||
std::shared_ptr<SurfaceSprite> since_1998_sprite_; // SSprite para manejar la textura2
|
std::shared_ptr<SurfaceSprite> since_1998_sprite_ = nullptr; // SSprite para manejar la textura2
|
||||||
Uint8 jailgames_color_ = 0; // Color para el sprite de "JAILGAMES"
|
Uint8 jailgames_color_ = 0; // Color para el sprite de "JAILGAMES"
|
||||||
Uint8 since_1998_color_ = 0; // Color para el sprite de "Since 1998"
|
Uint8 since_1998_color_ = 0; // Color para el sprite de "Since 1998"
|
||||||
|
|
||||||
// --- Variables de estado ---
|
// --- Variables de estado ---
|
||||||
std::vector<Uint8> color_; // Vector con los colores para el fadeF
|
std::vector<Uint8> color_; // Vector con los colores para el fadeF
|
||||||
std::unique_ptr<DeltaTimer> delta_timer_; // Timer para delta time
|
std::unique_ptr<DeltaTimer> delta_timer_ = nullptr; // Timer para delta time
|
||||||
LogoState state_; // Estado actual de la secuencia
|
State state_ = State::INITIAL; // Estado actual de la secuencia
|
||||||
float state_time_; // Tiempo acumulado en el estado actual
|
float state_time_ = 0.0F; // Tiempo acumulado en el estado actual
|
||||||
|
|
||||||
// --- Funciones ---
|
// --- Funciones ---
|
||||||
void update(); // Actualiza las variables
|
void update(); // Actualiza las variables
|
||||||
@@ -59,7 +62,7 @@ class Logo {
|
|||||||
void updateJAILGAMES(float delta_time); // Gestiona el logo de JAILGAME (time-based)
|
void updateJAILGAMES(float delta_time); // Gestiona el logo de JAILGAME (time-based)
|
||||||
void updateTextureColors(); // Gestiona el color de las texturas
|
void updateTextureColors(); // Gestiona el color de las texturas
|
||||||
void updateState(float delta_time); // Actualiza el estado actual
|
void updateState(float delta_time); // Actualiza el estado actual
|
||||||
void transitionToState(LogoState new_state); // Transiciona a un nuevo estado
|
void transitionToState(State new_state); // Transiciona a un nuevo estado
|
||||||
[[nodiscard]] auto getColorIndex(float progress) const -> int; // Calcula el índice de color según el progreso (0.0-1.0)
|
[[nodiscard]] auto getColorIndex(float progress) const -> int; // Calcula el índice de color según el progreso (0.0-1.0)
|
||||||
static void endSection(); // Termina la sección
|
static void endSection(); // Termina la sección
|
||||||
void initColors(); // Inicializa el vector de colores
|
void initColors(); // Inicializa el vector de colores
|
||||||
|
|||||||
@@ -11,11 +11,11 @@
|
|||||||
#include "core/rendering/surface_sprite.hpp" // Para SSprite
|
#include "core/rendering/surface_sprite.hpp" // Para SSprite
|
||||||
#include "core/rendering/text.hpp" // Para Text, TEXT_CENTER, TEXT_COLOR
|
#include "core/rendering/text.hpp" // Para Text, TEXT_CENTER, TEXT_COLOR
|
||||||
#include "core/resources/resource.hpp" // Para Resource
|
#include "core/resources/resource.hpp" // Para Resource
|
||||||
|
#include "core/system/global_events.hpp" // Para check
|
||||||
#include "game/gameplay/cheevos.hpp" // Para Cheevos, Achievement
|
#include "game/gameplay/cheevos.hpp" // Para Cheevos, Achievement
|
||||||
#include "game/options.hpp" // Para Options, options, SectionState, Section
|
#include "game/options.hpp" // Para Options, options, SectionState, Section
|
||||||
#include "game/scene_manager.hpp" // Para SceneManager
|
#include "game/scene_manager.hpp" // Para SceneManager
|
||||||
#include "utils/defines.hpp" // Para PLAY_AREA_CENTER_X, GAMECANVAS_WIDTH
|
#include "utils/defines.hpp" // Para PLAY_AREA_CENTER_X, GAMECANVAS_WIDTH
|
||||||
#include "core/system/global_events.hpp" // Para check
|
|
||||||
#include "utils/utils.hpp" // Para stringToColor, PaletteColor, playMusic
|
#include "utils/utils.hpp" // Para stringToColor, PaletteColor, playMusic
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
@@ -33,7 +33,7 @@ Title::Title()
|
|||||||
fade_accumulator_(0.0F),
|
fade_accumulator_(0.0F),
|
||||||
current_delta_(0.0F) {
|
current_delta_(0.0F) {
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
state_ = SceneManager::options == SceneManager::Options::TITLE_WITH_LOADING_SCREEN ? TitleState::SHOW_LOADING_SCREEN : TitleState::SHOW_MENU;
|
state_ = SceneManager::options == SceneManager::Options::TITLE_WITH_LOADING_SCREEN ? State::SHOW_LOADING_SCREEN : State::SHOW_MENU;
|
||||||
SceneManager::current = SceneManager::Scene::TITLE;
|
SceneManager::current = SceneManager::Scene::TITLE;
|
||||||
SceneManager::options = SceneManager::Options::NONE;
|
SceneManager::options = SceneManager::Options::NONE;
|
||||||
initMarquee();
|
initMarquee();
|
||||||
@@ -58,7 +58,7 @@ void Title::initMarquee() {
|
|||||||
|
|
||||||
// Pre-calcular anchos de caracteres para eficiencia
|
// Pre-calcular anchos de caracteres para eficiencia
|
||||||
for (size_t i = 0; i < long_text_.length(); ++i) {
|
for (size_t i = 0; i < long_text_.length(); ++i) {
|
||||||
TitleLetter l;
|
Glyph l;
|
||||||
l.letter = long_text_[i]; // char directo, no substring
|
l.letter = long_text_[i]; // char directo, no substring
|
||||||
l.x = MARQUEE_START_X; // Usar constante
|
l.x = MARQUEE_START_X; // Usar constante
|
||||||
l.width = marquee_text_->lenght(std::string(1, long_text_[i])); // Pre-calcular ancho
|
l.width = marquee_text_->lenght(std::string(1, long_text_[i])); // Pre-calcular ancho
|
||||||
@@ -111,8 +111,8 @@ void Title::checkInput() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Input::get()->checkInput(InputAction::ACCEPT, INPUT_DO_NOT_ALLOW_REPEAT)) {
|
if (Input::get()->checkInput(InputAction::ACCEPT, INPUT_DO_NOT_ALLOW_REPEAT)) {
|
||||||
if (state_ == TitleState::SHOW_LOADING_SCREEN) {
|
if (state_ == State::SHOW_LOADING_SCREEN) {
|
||||||
transitionToState(TitleState::FADE_LOADING_SCREEN);
|
transitionToState(State::FADE_LOADING_SCREEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,8 +161,7 @@ void Title::renderMarquee() {
|
|||||||
static_cast<int>(letter.x), // Conversión explícita float→int
|
static_cast<int>(letter.x), // Conversión explícita float→int
|
||||||
static_cast<int>(MARQUEE_Y), // Usar constante
|
static_cast<int>(MARQUEE_Y), // Usar constante
|
||||||
std::string(1, letter.letter), // Convertir char a string
|
std::string(1, letter.letter), // Convertir char a string
|
||||||
static_cast<Uint8>(PaletteColor::BRIGHT_RED)
|
static_cast<Uint8>(PaletteColor::BRIGHT_RED));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -187,23 +186,23 @@ void Title::updateState(float delta_time) {
|
|||||||
state_time_ += delta_time;
|
state_time_ += delta_time;
|
||||||
|
|
||||||
switch (state_) {
|
switch (state_) {
|
||||||
case TitleState::SHOW_LOADING_SCREEN:
|
case State::SHOW_LOADING_SCREEN:
|
||||||
if (state_time_ >= SHOW_LOADING_DURATION) {
|
if (state_time_ >= SHOW_LOADING_DURATION) {
|
||||||
transitionToState(TitleState::FADE_LOADING_SCREEN);
|
transitionToState(State::FADE_LOADING_SCREEN);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TitleState::FADE_LOADING_SCREEN:
|
case State::FADE_LOADING_SCREEN:
|
||||||
fade_accumulator_ += delta_time;
|
fade_accumulator_ += delta_time;
|
||||||
if (fade_accumulator_ >= FADE_STEP_INTERVAL) {
|
if (fade_accumulator_ >= FADE_STEP_INTERVAL) {
|
||||||
fade_accumulator_ = 0.0F;
|
fade_accumulator_ = 0.0F;
|
||||||
if (loading_screen_surface_->fadeSubPalette()) {
|
if (loading_screen_surface_->fadeSubPalette()) {
|
||||||
transitionToState(TitleState::SHOW_MENU);
|
transitionToState(State::SHOW_MENU);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TitleState::SHOW_MENU:
|
case State::SHOW_MENU:
|
||||||
// Actualiza la marquesina
|
// Actualiza la marquesina
|
||||||
updateMarquee(delta_time);
|
updateMarquee(delta_time);
|
||||||
|
|
||||||
@@ -220,7 +219,7 @@ void Title::updateState(float delta_time) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Transiciona a un nuevo estado
|
// Transiciona a un nuevo estado
|
||||||
void Title::transitionToState(TitleState new_state) {
|
void Title::transitionToState(State new_state) {
|
||||||
state_ = new_state;
|
state_ = new_state;
|
||||||
state_time_ = 0.0F;
|
state_time_ = 0.0F;
|
||||||
fade_accumulator_ = 0.0F;
|
fade_accumulator_ = 0.0F;
|
||||||
@@ -233,7 +232,7 @@ void Title::render() {
|
|||||||
Screen::get()->clearSurface(static_cast<Uint8>(PaletteColor::BLACK));
|
Screen::get()->clearSurface(static_cast<Uint8>(PaletteColor::BLACK));
|
||||||
|
|
||||||
switch (state_) {
|
switch (state_) {
|
||||||
case TitleState::SHOW_MENU:
|
case State::SHOW_MENU:
|
||||||
// Dibuja la textura de fondo
|
// Dibuja la textura de fondo
|
||||||
bg_surface_->render(0, 0);
|
bg_surface_->render(0, 0);
|
||||||
|
|
||||||
@@ -246,8 +245,8 @@ void Title::render() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TitleState::SHOW_LOADING_SCREEN:
|
case State::SHOW_LOADING_SCREEN:
|
||||||
case TitleState::FADE_LOADING_SCREEN:
|
case State::FADE_LOADING_SCREEN:
|
||||||
loading_screen_sprite_->render();
|
loading_screen_sprite_->render();
|
||||||
title_logo_sprite_->render();
|
title_logo_sprite_->render();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -12,15 +12,24 @@ class Surface; // Forward declaration
|
|||||||
class Text; // Forward declaration
|
class Text; // Forward declaration
|
||||||
|
|
||||||
class Title {
|
class Title {
|
||||||
|
public:
|
||||||
|
// --- Constructor y Destructor ---
|
||||||
|
Title();
|
||||||
|
~Title() = default;
|
||||||
|
|
||||||
|
// --- Bucle principal ---
|
||||||
|
void run();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct TitleLetter {
|
// --- Estructuras y enumeraciones ---
|
||||||
|
struct Glyph {
|
||||||
char letter; // Letra a escribir (char es más eficiente que std::string)
|
char letter; // Letra a escribir (char es más eficiente que std::string)
|
||||||
float x; // Posición en el eje x (float para precisión con delta time)
|
float x; // Posición en el eje x (float para precisión con delta time)
|
||||||
float width; // Ancho pre-calculado del carácter
|
float width; // Ancho pre-calculado del carácter
|
||||||
bool enabled; // Solo se escriben y mueven si estan habilitadas
|
bool enabled; // Solo se escriben y mueven si estan habilitadas
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class TitleState {
|
enum class State {
|
||||||
SHOW_LOADING_SCREEN,
|
SHOW_LOADING_SCREEN,
|
||||||
FADE_LOADING_SCREEN,
|
FADE_LOADING_SCREEN,
|
||||||
SHOW_MENU
|
SHOW_MENU
|
||||||
@@ -39,7 +48,7 @@ class Title {
|
|||||||
static constexpr float MARQUEE_Y = 184.0F; // Posición Y
|
static constexpr float MARQUEE_Y = 184.0F; // Posición Y
|
||||||
static constexpr float MARQUEE_LETTER_SPACING = 1.0F; // Espaciado entre letras
|
static constexpr float MARQUEE_LETTER_SPACING = 1.0F; // Espaciado entre letras
|
||||||
|
|
||||||
// Objetos y punteros
|
// --- Objetos y punteros ---
|
||||||
std::shared_ptr<Surface> title_logo_surface_; // Textura con los graficos
|
std::shared_ptr<Surface> title_logo_surface_; // Textura con los graficos
|
||||||
std::shared_ptr<SurfaceSprite> title_logo_sprite_; // SSprite para manejar la surface
|
std::shared_ptr<SurfaceSprite> title_logo_sprite_; // SSprite para manejar la surface
|
||||||
std::shared_ptr<Surface> loading_screen_surface_; // Surface con los gráficos de la pantalla de carga
|
std::shared_ptr<Surface> loading_screen_surface_; // Surface con los gráficos de la pantalla de carga
|
||||||
@@ -52,12 +61,12 @@ class Title {
|
|||||||
std::unique_ptr<DeltaTimer> delta_timer_; // Timer para delta time
|
std::unique_ptr<DeltaTimer> delta_timer_; // Timer para delta time
|
||||||
std::shared_ptr<Text> marquee_text_; // Cache del texto para marquesina
|
std::shared_ptr<Text> marquee_text_; // Cache del texto para marquesina
|
||||||
std::string long_text_; // Texto que aparece en la parte inferior del titulo
|
std::string long_text_; // Texto que aparece en la parte inferior del titulo
|
||||||
std::vector<TitleLetter> letters_; // Vector con las letras de la marquesina
|
std::vector<Glyph> letters_; // Vector con las letras de la marquesina
|
||||||
int first_active_letter_; // Primera letra activa (optimización)
|
int first_active_letter_; // Primera letra activa (optimización)
|
||||||
int last_active_letter_; // Última letra activa (optimización)
|
int last_active_letter_; // Última letra activa (optimización)
|
||||||
bool show_cheevos_ = false; // Indica si se muestra por pantalla el listado de logros
|
bool show_cheevos_ = false; // Indica si se muestra por pantalla el listado de logros
|
||||||
SDL_FRect cheevos_surface_view_; // Zona visible de la surface con el listado de logros
|
SDL_FRect cheevos_surface_view_; // Zona visible de la surface con el listado de logros
|
||||||
TitleState state_; // Estado en el que se encuentra el bucle principal
|
State state_; // Estado en el que se encuentra el bucle principal
|
||||||
float state_time_; // Tiempo acumulado en el estado actual
|
float state_time_; // Tiempo acumulado en el estado actual
|
||||||
float fade_accumulator_; // Acumulador para controlar el fade por tiempo
|
float fade_accumulator_; // Acumulador para controlar el fade por tiempo
|
||||||
float current_delta_; // Delta time del frame actual
|
float current_delta_; // Delta time del frame actual
|
||||||
@@ -68,28 +77,12 @@ class Title {
|
|||||||
void checkEvents(); // Comprueba el manejador de eventos
|
void checkEvents(); // Comprueba el manejador de eventos
|
||||||
void checkInput(); // Comprueba las entradas
|
void checkInput(); // Comprueba las entradas
|
||||||
void updateState(float delta_time); // Actualiza el estado actual
|
void updateState(float delta_time); // Actualiza el estado actual
|
||||||
void transitionToState(TitleState new_state); // Transiciona a un nuevo estado
|
void transitionToState(State new_state); // Transiciona a un nuevo estado
|
||||||
void initMarquee(); // Inicializa la marquesina
|
void initMarquee(); // Inicializa la marquesina
|
||||||
void updateMarquee(float delta_time); // Actualiza la marquesina (time-based)
|
void updateMarquee(float delta_time); // Actualiza la marquesina (time-based)
|
||||||
void renderMarquee(); // Dibuja la marquesina
|
void renderMarquee(); // Dibuja la marquesina
|
||||||
void moveCheevosList(int direction, float delta_time); // Desplaza la lista de logros (time-based)
|
void moveCheevosList(int direction, float delta_time); // Desplaza la lista de logros (time-based)
|
||||||
|
void fillSurface(); // Rellena la surface de fondo con todos los gráficos
|
||||||
// Rellena la surface de fondo con todos los gráficos
|
void createCheevosTexture(); // Crea y rellena la surface para mostrar los logros
|
||||||
void fillSurface();
|
void hideCheevosList(); // Oculta la lista de logros
|
||||||
|
|
||||||
// Crea y rellena la surface para mostrar los logros
|
|
||||||
void createCheevosTexture();
|
|
||||||
|
|
||||||
// Oculta la lista de logros
|
|
||||||
void hideCheevosList();
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Constructor
|
|
||||||
Title();
|
|
||||||
|
|
||||||
// Destructor
|
|
||||||
~Title() = default;
|
|
||||||
|
|
||||||
// Bucle principal
|
|
||||||
void run();
|
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user