forked from jaildesigner-jailgames/jaildoctors_dilemma
linter
This commit is contained in:
@@ -22,7 +22,7 @@ Logo::Logo()
|
||||
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>()),
|
||||
state_(LogoState::INITIAL),
|
||||
state_time_(0.0f) {
|
||||
state_time_(0.0F) {
|
||||
// Configura variables
|
||||
since_1998_sprite_->setClip(0, 0, since_1998_surface_->getWidth(), since_1998_surface_->getHeight());
|
||||
since_1998_color_ = static_cast<Uint8>(PaletteColor::BLACK);
|
||||
@@ -42,13 +42,13 @@ Logo::Logo()
|
||||
void Logo::checkEvents() {
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
globalEvents::check(event);
|
||||
GlobalEvents::check(event);
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba las entradas
|
||||
void Logo::checkInput() {
|
||||
globalInputs::check();
|
||||
GlobalInputs::check();
|
||||
}
|
||||
|
||||
// Gestiona el logo de JAILGAME (time-based)
|
||||
@@ -59,24 +59,24 @@ void Logo::updateJAILGAMES(float delta_time) {
|
||||
}
|
||||
|
||||
// Calcular el desplazamiento basado en velocidad y delta time
|
||||
const float displacement = JAILGAMES_SLIDE_SPEED * delta_time;
|
||||
const float DISPLACEMENT = JAILGAMES_SLIDE_SPEED * delta_time;
|
||||
|
||||
// Actualizar cada línea del sprite JAILGAMES
|
||||
for (size_t i = 1; i < jailgames_sprite_.size(); ++i) {
|
||||
const int current_x = jailgames_sprite_[i]->getX();
|
||||
const int CURRENT_X = jailgames_sprite_[i]->getX();
|
||||
|
||||
// Las líneas pares se mueven desde la derecha, las impares desde la izquierda
|
||||
if (i % 2 == 0) {
|
||||
// Mover hacia la izquierda
|
||||
if (current_x > JAILGAMES_DEST_X) {
|
||||
const int new_x = static_cast<int>(current_x - displacement);
|
||||
jailgames_sprite_[i]->setX(new_x < JAILGAMES_DEST_X ? JAILGAMES_DEST_X : new_x);
|
||||
if (CURRENT_X > JAILGAMES_DEST_X) {
|
||||
const int NEW_X = static_cast<int>(CURRENT_X - DISPLACEMENT);
|
||||
jailgames_sprite_[i]->setX(NEW_X < JAILGAMES_DEST_X ? JAILGAMES_DEST_X : NEW_X);
|
||||
}
|
||||
} else {
|
||||
// Mover hacia la derecha
|
||||
if (current_x < JAILGAMES_DEST_X) {
|
||||
const int new_x = static_cast<int>(current_x + displacement);
|
||||
jailgames_sprite_[i]->setX(new_x > JAILGAMES_DEST_X ? JAILGAMES_DEST_X : new_x);
|
||||
if (CURRENT_X < JAILGAMES_DEST_X) {
|
||||
const int NEW_X = static_cast<int>(CURRENT_X + DISPLACEMENT);
|
||||
jailgames_sprite_[i]->setX(NEW_X > JAILGAMES_DEST_X ? JAILGAMES_DEST_X : NEW_X);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,13 +85,13 @@ void Logo::updateJAILGAMES(float delta_time) {
|
||||
// Calcula el índice de color según el progreso (0.0-1.0)
|
||||
int Logo::getColorIndex(float progress) const {
|
||||
// Asegurar que progress esté en el rango [0.0, 1.0]
|
||||
progress = std::clamp(progress, 0.0f, 1.0f);
|
||||
progress = std::clamp(progress, 0.0F, 1.0F);
|
||||
|
||||
// Mapear el progreso al índice de color (0-7)
|
||||
const int max_index = static_cast<int>(color_.size()) - 1;
|
||||
const int index = static_cast<int>(progress * max_index);
|
||||
const int MAX_INDEX = static_cast<int>(color_.size()) - 1;
|
||||
const int INDEX = static_cast<int>(progress * MAX_INDEX);
|
||||
|
||||
return index;
|
||||
return INDEX;
|
||||
}
|
||||
|
||||
// Gestiona el color de las texturas
|
||||
@@ -99,8 +99,8 @@ void Logo::updateTextureColors() {
|
||||
switch (state_) {
|
||||
case LogoState::SINCE_1998_FADE_IN: {
|
||||
// Fade-in de "Since 1998" de negro a blanco
|
||||
const float progress = state_time_ / SINCE_1998_FADE_DURATION;
|
||||
since_1998_color_ = color_[getColorIndex(progress)];
|
||||
const float PROGRESS = state_time_ / SINCE_1998_FADE_DURATION;
|
||||
since_1998_color_ = color_[getColorIndex(PROGRESS)];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -113,10 +113,10 @@ void Logo::updateTextureColors() {
|
||||
|
||||
case LogoState::FADE_OUT: {
|
||||
// Fade-out de ambos logos de blanco a negro
|
||||
const float progress = 1.0f - (state_time_ / FADE_OUT_DURATION);
|
||||
const int color_index = getColorIndex(progress);
|
||||
jailgames_color_ = color_[color_index];
|
||||
since_1998_color_ = color_[color_index];
|
||||
const float PROGRESS = 1.0F - (state_time_ / FADE_OUT_DURATION);
|
||||
const int COLOR_INDEX = getColorIndex(PROGRESS);
|
||||
jailgames_color_ = color_[COLOR_INDEX];
|
||||
since_1998_color_ = color_[COLOR_INDEX];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ void Logo::updateTextureColors() {
|
||||
// Transiciona a un nuevo estado
|
||||
void Logo::transitionToState(LogoState new_state) {
|
||||
state_ = new_state;
|
||||
state_time_ = 0.0f;
|
||||
state_time_ = 0.0F;
|
||||
}
|
||||
|
||||
// Actualiza el estado actual
|
||||
@@ -178,11 +178,11 @@ void Logo::updateState(float delta_time) {
|
||||
// Actualiza las variables
|
||||
void Logo::update() {
|
||||
// Obtener delta time desde el último frame
|
||||
const float delta_time = delta_timer_->tick();
|
||||
const float DELTA_TIME = delta_timer_->tick();
|
||||
|
||||
checkInput(); // Comprueba las entradas
|
||||
updateState(delta_time); // Actualiza el estado y gestiona transiciones
|
||||
updateJAILGAMES(delta_time); // Gestiona el logo de JAILGAME
|
||||
updateState(DELTA_TIME); // Actualiza el estado y gestiona transiciones
|
||||
updateJAILGAMES(DELTA_TIME); // Gestiona el logo de JAILGAME
|
||||
updateTextureColors(); // Gestiona el color de las texturas
|
||||
Screen::get()->update(); // Actualiza el objeto Screen
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user