Title: optimitzat render()
This commit is contained in:
@@ -50,6 +50,11 @@ Title::Title()
|
||||
const bool IS_TITLE_TO_DEMO = (Section::attract_mode == Section::AttractMode::TITLE_TO_DEMO);
|
||||
next_section_ = IS_TITLE_TO_DEMO ? Section::Name::GAME_DEMO : Section::Name::LOGO;
|
||||
Section::attract_mode = IS_TITLE_TO_DEMO ? Section::AttractMode::TITLE_TO_LOGO : Section::AttractMode::TITLE_TO_DEMO;
|
||||
|
||||
// Define los anclajes de los elementos
|
||||
anchor_.mini_logo = (param.game.height / 5 * 4) + BLOCK;
|
||||
mini_logo_sprite_->setY(anchor_.mini_logo);
|
||||
anchor_.copyright_text = anchor_.mini_logo + mini_logo_sprite_->getHeight() + 3;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
@@ -80,20 +85,9 @@ void Title::render()
|
||||
|
||||
tiled_bg_->render();
|
||||
game_logo_->render();
|
||||
|
||||
if (state_ != TitleState::LOGO_ANIMATING)
|
||||
{
|
||||
// Mini logo
|
||||
const int pos1 = (param.game.height / 5 * 4) + BLOCK;
|
||||
const int pos2 = pos1 + mini_logo_sprite_->getHeight() + 3;
|
||||
mini_logo_sprite_->setY(pos1);
|
||||
mini_logo_sprite_->render();
|
||||
|
||||
// Texto con el copyright
|
||||
text_->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, pos2, TEXT_COPYRIGHT, 1, NO_TEXT_COLOR, 1, TITLE_SHADOW_TEXT_COLOR);
|
||||
}
|
||||
|
||||
renderStartPrompt();
|
||||
renderCopyright();
|
||||
|
||||
define_buttons_->render();
|
||||
fade_->render();
|
||||
|
||||
@@ -378,3 +372,22 @@ void Title::renderStartPrompt()
|
||||
TITLE_SHADOW_TEXT_COLOR);
|
||||
}
|
||||
}
|
||||
|
||||
void Title::renderCopyright()
|
||||
{
|
||||
if (state_ != TitleState::LOGO_ANIMATING)
|
||||
{
|
||||
// Mini logo
|
||||
mini_logo_sprite_->render();
|
||||
|
||||
// Texto con el copyright
|
||||
text_->writeDX(TEXT_CENTER | TEXT_SHADOW,
|
||||
param.game.game_area.center_x,
|
||||
anchor_.copyright_text,
|
||||
TEXT_COPYRIGHT,
|
||||
1,
|
||||
NO_TEXT_COLOR,
|
||||
1,
|
||||
TITLE_SHADOW_TEXT_COLOR);
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,13 @@ private:
|
||||
START_HAS_BEEN_PRESSED, // Se ha pulsado el botón de start
|
||||
};
|
||||
|
||||
// --- Estructura para definir anclas ---
|
||||
struct Anchor
|
||||
{
|
||||
int mini_logo;
|
||||
int copyright_text;
|
||||
};
|
||||
|
||||
// --- Objetos y punteros ---
|
||||
std::shared_ptr<Text> text_; // Objeto de texto para escribir en pantalla
|
||||
std::unique_ptr<Fade> fade_; // Fundido en pantalla
|
||||
@@ -60,6 +67,9 @@ private:
|
||||
TitleState state_; // Estado actual de la sección
|
||||
bool should_render_start_prompt = false; // Indica si se muestra o no el texto de PRESS START BUTTON TO PLAY
|
||||
|
||||
// -- Variables de diseño ---
|
||||
Anchor anchor_; // Anclas para definir la posición de los elementos del titulo
|
||||
|
||||
// --- Métodos internos ---
|
||||
void update(); // Actualiza las variables del objeto
|
||||
void render(); // Dibuja el objeto en pantalla
|
||||
@@ -73,4 +83,5 @@ private:
|
||||
void updateState(); // Actualiza el estado
|
||||
void updateStartPrompt();
|
||||
void renderStartPrompt();
|
||||
void renderCopyright();
|
||||
};
|
||||
Reference in New Issue
Block a user