corregit: flags estatics en credits.cpp i title.cpp
This commit is contained in:
@@ -293,11 +293,10 @@ void Credits::fillCanvas() {
|
||||
// Actualiza el destino de los rectangulos de las texturas (time-based)
|
||||
void Credits::updateTextureDstRects(float deltaTime) {
|
||||
constexpr float TEXTURE_UPDATE_INTERVAL_S = 10.0f / 60.0f; // ~0.167s (cada 10 frames)
|
||||
static float texture_accumulator = 0.0f;
|
||||
texture_accumulator += deltaTime;
|
||||
credits_state_.texture_accumulator += deltaTime;
|
||||
|
||||
if (texture_accumulator >= TEXTURE_UPDATE_INTERVAL_S) {
|
||||
texture_accumulator -= TEXTURE_UPDATE_INTERVAL_S;
|
||||
if (credits_state_.texture_accumulator >= TEXTURE_UPDATE_INTERVAL_S) {
|
||||
credits_state_.texture_accumulator -= TEXTURE_UPDATE_INTERVAL_S;
|
||||
|
||||
// Comprueba la posición de la textura con los titulos de credito
|
||||
if (credits_rect_dst_.y + credits_rect_dst_.h > play_area_.y) {
|
||||
@@ -336,20 +335,17 @@ void Credits::throwBalloons(float deltaTime) {
|
||||
return;
|
||||
}
|
||||
|
||||
static float balloon_accumulator = 0.0f;
|
||||
static float powerball_accumulator = 0.0f;
|
||||
credits_state_.balloon_accumulator += deltaTime;
|
||||
credits_state_.powerball_accumulator += deltaTime;
|
||||
|
||||
balloon_accumulator += deltaTime;
|
||||
powerball_accumulator += deltaTime;
|
||||
|
||||
if (balloon_accumulator >= BALLOON_INTERVAL_S) {
|
||||
balloon_accumulator -= BALLOON_INTERVAL_S;
|
||||
if (credits_state_.balloon_accumulator >= BALLOON_INTERVAL_S) {
|
||||
credits_state_.balloon_accumulator -= BALLOON_INTERVAL_S;
|
||||
const int INDEX = (static_cast<int>(counter_ / SPEED)) % SETS.size();
|
||||
balloon_manager_->deployFormation(SETS.at(INDEX), -60);
|
||||
}
|
||||
|
||||
if (powerball_accumulator >= POWERBALL_INTERVAL_S && counter_ > 0) {
|
||||
powerball_accumulator -= POWERBALL_INTERVAL_S;
|
||||
if (credits_state_.powerball_accumulator >= POWERBALL_INTERVAL_S && counter_ > 0) {
|
||||
credits_state_.powerball_accumulator -= POWERBALL_INTERVAL_S;
|
||||
balloon_manager_->createPowerBall();
|
||||
}
|
||||
}
|
||||
@@ -425,13 +421,11 @@ void Credits::initPlayers() {
|
||||
void Credits::updateBlackRects(float deltaTime) {
|
||||
static float current_step_ = static_cast<float>(steps_);
|
||||
constexpr float BLACK_RECT_INTERVAL_S = 4.0f / 60.0f; // ~0.067s (cada 4 frames)
|
||||
static float black_rect_accumulator = 0.0f;
|
||||
|
||||
if (top_black_rect_.h != param.game.game_area.center_y - 1 && bottom_black_rect_.y != param.game.game_area.center_y + 1) {
|
||||
// Si los rectangulos superior e inferior no han llegado al centro
|
||||
black_rect_accumulator += deltaTime;
|
||||
if (black_rect_accumulator >= BLACK_RECT_INTERVAL_S) {
|
||||
black_rect_accumulator -= BLACK_RECT_INTERVAL_S;
|
||||
credits_state_.black_rect_accumulator += deltaTime;
|
||||
if (credits_state_.black_rect_accumulator >= BLACK_RECT_INTERVAL_S) {
|
||||
credits_state_.black_rect_accumulator -= BLACK_RECT_INTERVAL_S;
|
||||
|
||||
// Incrementa la altura del rectangulo superior
|
||||
top_black_rect_.h = std::min(top_black_rect_.h + 1, param.game.game_area.center_y - 1);
|
||||
@@ -515,33 +509,33 @@ void Credits::cycleColors() {
|
||||
constexpr int UPPER_LIMIT = 140; // Límite superior
|
||||
constexpr int LOWER_LIMIT = 30; // Límite inferior
|
||||
|
||||
static auto r_ = static_cast<float>(UPPER_LIMIT);
|
||||
static auto g_ = static_cast<float>(LOWER_LIMIT);
|
||||
static auto b_ = static_cast<float>(LOWER_LIMIT);
|
||||
static float step_r_ = -0.5F; // Paso flotante para transiciones suaves
|
||||
static float step_g_ = 0.3F;
|
||||
static float step_b_ = 0.1F;
|
||||
// Inicializar valores RGB si es la primera vez
|
||||
if (credits_state_.r == 255.0f && credits_state_.g == 0.0f && credits_state_.b == 0.0f && credits_state_.step_r == -0.5f) {
|
||||
credits_state_.r = static_cast<float>(UPPER_LIMIT);
|
||||
credits_state_.g = static_cast<float>(LOWER_LIMIT);
|
||||
credits_state_.b = static_cast<float>(LOWER_LIMIT);
|
||||
}
|
||||
|
||||
// Ajustar valores de R
|
||||
r_ += step_r_;
|
||||
if (r_ >= UPPER_LIMIT || r_ <= LOWER_LIMIT) {
|
||||
step_r_ = -step_r_; // Cambia de dirección al alcanzar los límites
|
||||
credits_state_.r += credits_state_.step_r;
|
||||
if (credits_state_.r >= UPPER_LIMIT || credits_state_.r <= LOWER_LIMIT) {
|
||||
credits_state_.step_r = -credits_state_.step_r; // Cambia de dirección al alcanzar los límites
|
||||
}
|
||||
|
||||
// Ajustar valores de G
|
||||
g_ += step_g_;
|
||||
if (g_ >= UPPER_LIMIT || g_ <= LOWER_LIMIT) {
|
||||
step_g_ = -step_g_; // Cambia de dirección al alcanzar los límites
|
||||
credits_state_.g += credits_state_.step_g;
|
||||
if (credits_state_.g >= UPPER_LIMIT || credits_state_.g <= LOWER_LIMIT) {
|
||||
credits_state_.step_g = -credits_state_.step_g; // Cambia de dirección al alcanzar los límites
|
||||
}
|
||||
|
||||
// Ajustar valores de B
|
||||
b_ += step_b_;
|
||||
if (b_ >= UPPER_LIMIT || b_ <= LOWER_LIMIT) {
|
||||
step_b_ = -step_b_; // Cambia de dirección al alcanzar los límites
|
||||
credits_state_.b += credits_state_.step_b;
|
||||
if (credits_state_.b >= UPPER_LIMIT || credits_state_.b <= LOWER_LIMIT) {
|
||||
credits_state_.step_b = -credits_state_.step_b; // Cambia de dirección al alcanzar los límites
|
||||
}
|
||||
|
||||
// Aplicar el color, redondeando a enteros antes de usar
|
||||
color_ = Color(static_cast<int>(r_), static_cast<int>(g_), static_cast<int>(b_));
|
||||
color_ = Color(static_cast<int>(credits_state_.r), static_cast<int>(credits_state_.g), static_cast<int>(credits_state_.b));
|
||||
tiled_bg_->setColor(color_);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user