linter: varios
This commit is contained in:
@@ -409,8 +409,8 @@ void Credits::initPlayers() {
|
||||
|
||||
// Actualiza los rectangulos negros (time-based)
|
||||
void Credits::updateBlackRects(float delta_time) {
|
||||
if (!initialized_) return;
|
||||
if (delta_time < 0.0f) delta_time = 0.0f;
|
||||
if (!initialized_) { return; }
|
||||
delta_time = std::max(delta_time, 0.0F);
|
||||
|
||||
// Fase vertical: hasta que ambos rects verticales estén exactos en su target
|
||||
if (!vertical_done_) {
|
||||
@@ -420,15 +420,15 @@ void Credits::updateBlackRects(float delta_time) {
|
||||
|
||||
// top
|
||||
int prev_top_h = static_cast<int>(top_black_rect_.h);
|
||||
top_black_rect_.h = std::min(top_black_rect_.h + 1.0f,
|
||||
top_black_rect_.h = std::min(top_black_rect_.h + 1.0F,
|
||||
static_cast<float>(param.game.game_area.center_y - 1));
|
||||
int top_delta = static_cast<int>(top_black_rect_.h) - prev_top_h;
|
||||
|
||||
// bottom
|
||||
int prev_bottom_h = static_cast<int>(bottom_black_rect_.h);
|
||||
int prev_bottom_y = static_cast<int>(bottom_black_rect_.y);
|
||||
bottom_black_rect_.h = bottom_black_rect_.h + 1.0f;
|
||||
bottom_black_rect_.y = std::max(bottom_black_rect_.y - 1.0f,
|
||||
bottom_black_rect_.h = bottom_black_rect_.h + 1.0F;
|
||||
bottom_black_rect_.y = std::max(bottom_black_rect_.y - 1.0F,
|
||||
static_cast<float>(param.game.game_area.center_y + 1));
|
||||
int bottom_steps_by_h = static_cast<int>(bottom_black_rect_.h) - prev_bottom_h;
|
||||
int bottom_steps_by_y = prev_bottom_y - static_cast<int>(bottom_black_rect_.y);
|
||||
@@ -436,18 +436,18 @@ void Credits::updateBlackRects(float delta_time) {
|
||||
|
||||
int steps_done = top_delta + bottom_steps;
|
||||
if (steps_done > 0) {
|
||||
current_step_ = std::max(0.0f, current_step_ - static_cast<float>(steps_done));
|
||||
current_step_ = std::max(0.0F, current_step_ - static_cast<float>(steps_done));
|
||||
float vol_f = initial_volume_ * (current_step_ / static_cast<float>(total_steps_));
|
||||
int vol_i = static_cast<int>(std::clamp(vol_f, 0.0f, static_cast<float>(initial_volume_)));
|
||||
int vol_i = static_cast<int>(std::clamp(vol_f, 0.0F, static_cast<float>(initial_volume_)));
|
||||
Audio::get()->setMusicVolume(vol_i); // usa tu API de audio aquí
|
||||
}
|
||||
|
||||
// Si han alcanzado los objetivos, fijarlos exactamente y marcar done
|
||||
bool top_at_target = static_cast<int>(top_black_rect_.h) == param.game.game_area.center_y - 1;
|
||||
bool bottom_at_target = static_cast<int>(bottom_black_rect_.y) == param.game.game_area.center_y + 1;
|
||||
bool top_at_target = static_cast<int>(top_black_rect_.h) == param.game.game_area.center_y - 1.0F;
|
||||
bool bottom_at_target = static_cast<int>(bottom_black_rect_.y) == param.game.game_area.center_y + 1.0F;
|
||||
if (top_at_target && bottom_at_target) {
|
||||
top_black_rect_.h = static_cast<float>(param.game.game_area.center_y - 1);
|
||||
bottom_black_rect_.y = static_cast<float>(param.game.game_area.center_y + 1);
|
||||
top_black_rect_.h = param.game.game_area.center_y - 1.0F;
|
||||
bottom_black_rect_.y = param.game.game_area.center_y + 1.0F;
|
||||
vertical_done_ = true;
|
||||
}
|
||||
}
|
||||
@@ -480,8 +480,8 @@ void Credits::updateBlackRects(float delta_time) {
|
||||
bool left_at_target = static_cast<int>(left_black_rect_.w) == param.game.game_area.center_x;
|
||||
bool right_at_target = static_cast<int>(right_black_rect_.x) == param.game.game_area.center_x;
|
||||
if (left_at_target && right_at_target) {
|
||||
left_black_rect_.w = static_cast<float>(param.game.game_area.center_x);
|
||||
right_black_rect_.x = static_cast<float>(param.game.game_area.center_x);
|
||||
left_black_rect_.w = param.game.game_area.center_x;
|
||||
right_black_rect_.x = param.game.game_area.center_x;
|
||||
horizontal_done_ = true;
|
||||
}
|
||||
|
||||
@@ -504,13 +504,13 @@ void Credits::updateBlackRects(float delta_time) {
|
||||
// Actualiza el rectangulo del borde
|
||||
void Credits::updateBorderRect() {
|
||||
border_rect_.x = left_black_rect_.x + left_black_rect_.w;
|
||||
border_rect_.y = top_black_rect_.y + top_black_rect_.h - 1;
|
||||
border_rect_.y = top_black_rect_.y + top_black_rect_.h - 1.0F;
|
||||
|
||||
float raw_w = right_black_rect_.x - border_rect_.x;
|
||||
float raw_h = bottom_black_rect_.y - border_rect_.y + 1.0f;
|
||||
float raw_h = bottom_black_rect_.y - border_rect_.y + 1.0F;
|
||||
|
||||
border_rect_.w = std::max(0.0f, raw_w);
|
||||
border_rect_.h = std::max(0.0f, raw_h);
|
||||
border_rect_.w = std::max(0.0F, raw_w);
|
||||
border_rect_.h = std::max(0.0F, raw_h);
|
||||
}
|
||||
|
||||
// Actualiza el estado de fade (time-based)
|
||||
@@ -612,25 +612,25 @@ void Credits::renderPlayers() {
|
||||
void Credits::initVars() {
|
||||
// Inicialización segura de rects tal y como los mostraste
|
||||
top_black_rect_ = {
|
||||
play_area_.x,
|
||||
param.game.game_area.rect.y,
|
||||
play_area_.w,
|
||||
black_bars_size_};
|
||||
.x = play_area_.x,
|
||||
.y = param.game.game_area.rect.y,
|
||||
.w = play_area_.w,
|
||||
.h = black_bars_size_};
|
||||
bottom_black_rect_ = {
|
||||
play_area_.x,
|
||||
param.game.game_area.rect.h - black_bars_size_,
|
||||
play_area_.w,
|
||||
black_bars_size_};
|
||||
.x = play_area_.x,
|
||||
.y = param.game.game_area.rect.h - black_bars_size_,
|
||||
.w = play_area_.w,
|
||||
.h = black_bars_size_};
|
||||
left_black_rect_ = {
|
||||
play_area_.x,
|
||||
param.game.game_area.center_y - 1,
|
||||
0,
|
||||
2};
|
||||
.x = play_area_.x,
|
||||
.y = param.game.game_area.center_y - 1.0F,
|
||||
.w = 0.0F,
|
||||
.h = 2.0F};
|
||||
right_black_rect_ = {
|
||||
play_area_.x + play_area_.w,
|
||||
param.game.game_area.center_y - 1,
|
||||
0,
|
||||
2};
|
||||
.x = play_area_.x + play_area_.w,
|
||||
.y = param.game.game_area.center_y - 1.0F,
|
||||
.w = 0.0F,
|
||||
.h = 2.0F};
|
||||
|
||||
initialized_ = false;
|
||||
|
||||
@@ -659,10 +659,10 @@ void Credits::initVars() {
|
||||
|
||||
void Credits::startCredits() {
|
||||
// Guardar iniciales (enteros para contar "pasos" por píxel)
|
||||
init_top_h = static_cast<int>(top_black_rect_.h);
|
||||
init_bottom_y = static_cast<int>(bottom_black_rect_.y);
|
||||
init_left_w = static_cast<int>(left_black_rect_.w);
|
||||
init_right_x = static_cast<int>(right_black_rect_.x);
|
||||
init_top_h_ = static_cast<int>(top_black_rect_.h);
|
||||
init_bottom_y_ = static_cast<int>(bottom_black_rect_.y);
|
||||
init_left_w_ = static_cast<int>(left_black_rect_.w);
|
||||
init_right_x_ = static_cast<int>(right_black_rect_.x);
|
||||
|
||||
// Objetivos
|
||||
int top_target_h = param.game.game_area.center_y - 1;
|
||||
@@ -671,12 +671,12 @@ void Credits::startCredits() {
|
||||
int right_target_x = param.game.game_area.center_x;
|
||||
|
||||
// Pasos verticales
|
||||
int pasos_top = std::max(0, top_target_h - init_top_h);
|
||||
int pasos_bottom = std::max(0, init_bottom_y - bottom_target_y);
|
||||
int pasos_top = std::max(0, top_target_h - init_top_h_);
|
||||
int pasos_bottom = std::max(0, init_bottom_y_ - bottom_target_y);
|
||||
|
||||
// Pasos horizontales. right se mueve a velocidad HORIZONTAL_SPEED, contamos pasos como unidades de movimiento equivalentes
|
||||
int pasos_left = std::max(0, left_target_w - init_left_w);
|
||||
int dx_right = std::max(0, init_right_x - right_target_x);
|
||||
int pasos_left = std::max(0, left_target_w - init_left_w_);
|
||||
int dx_right = std::max(0, init_right_x_ - right_target_x);
|
||||
int pasos_right = (dx_right + (HORIZONTAL_SPEED - 1)) / HORIZONTAL_SPEED; // ceil
|
||||
|
||||
total_steps_ = pasos_top + pasos_bottom + pasos_left + pasos_right;
|
||||
@@ -685,20 +685,20 @@ void Credits::startCredits() {
|
||||
current_step_ = static_cast<float>(total_steps_);
|
||||
|
||||
// Reiniciar contadores y estado
|
||||
credits_state_.black_rect_accumulator = 0.0f;
|
||||
counter_pre_fade_ = 0.0f;
|
||||
credits_state_.black_rect_accumulator = 0.0F;
|
||||
counter_pre_fade_ = 0.0F;
|
||||
initialized_ = true;
|
||||
|
||||
// Asegurar volumen inicial consistente
|
||||
if (steps_ <= 0) steps_ = 1;
|
||||
float vol_f = initial_volume_ * (current_step_ / static_cast<float>(total_steps_));
|
||||
setVolume(static_cast<int>(std::clamp(vol_f, 0.0f, static_cast<float>(initial_volume_))));
|
||||
setVolume(static_cast<int>(std::clamp(vol_f, 0.0F, static_cast<float>(initial_volume_))));
|
||||
}
|
||||
|
||||
// Dibuja el rectángulo del borde si es visible
|
||||
void Credits::drawBorderRect() {
|
||||
// Umbral: cualquier valor menor que 1 píxel no se considera visible
|
||||
constexpr float VISIBLE_THRESHOLD = 1.0f;
|
||||
constexpr float VISIBLE_THRESHOLD = 1.0F;
|
||||
if (border_rect_.w < VISIBLE_THRESHOLD || border_rect_.h < VISIBLE_THRESHOLD) {
|
||||
return; // no dibujar
|
||||
}
|
||||
@@ -709,10 +709,10 @@ void Credits::drawBorderRect() {
|
||||
|
||||
// Convertir a enteros de forma conservadora para evitar líneas de 1px por redondeo extraño
|
||||
SDL_Rect r;
|
||||
r.x = static_cast<int>(std::floor(border_rect_.x + 0.5f));
|
||||
r.y = static_cast<int>(std::floor(border_rect_.y + 0.5f));
|
||||
r.w = static_cast<int>(std::max(0.0f, std::floor(border_rect_.w + 0.5f)));
|
||||
r.h = static_cast<int>(std::max(0.0f, std::floor(border_rect_.h + 0.5f)));
|
||||
r.x = static_cast<int>(std::floor(border_rect_.x + 0.5F));
|
||||
r.y = static_cast<int>(std::floor(border_rect_.y + 0.5F));
|
||||
r.w = static_cast<int>(std::max(0.0f, std::floor(border_rect_.w + 0.5F)));
|
||||
r.h = static_cast<int>(std::max(0.0f, std::floor(border_rect_.h + 0.5F)));
|
||||
|
||||
if (r.w > 0 && r.h > 0) {
|
||||
SDL_RenderRect(Screen::get()->getRenderer(), &border_rect_);
|
||||
|
||||
Reference in New Issue
Block a user