forked from jaildesigner-jailgames/jaildoctors_dilemma
linter
This commit is contained in:
@@ -24,9 +24,9 @@ LoadingScreen::LoadingScreen()
|
||||
screen_surface_(std::make_shared<Surface>(Options::game.width, Options::game.height)),
|
||||
delta_timer_(std::make_unique<DeltaTimer>()),
|
||||
state_(LoadingState::SILENT1),
|
||||
state_time_(0.0f),
|
||||
state_time_(0.0F),
|
||||
current_border_type_(BorderType::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
|
||||
screen_surface_->clear(static_cast<Uint8>(PaletteColor::WHITE));
|
||||
|
||||
@@ -51,13 +51,13 @@ LoadingScreen::~LoadingScreen() {
|
||||
void LoadingScreen::checkEvents() {
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
globalEvents::check(event);
|
||||
GlobalEvents::check(event);
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba las entradas
|
||||
void LoadingScreen::checkInput() {
|
||||
globalInputs::check();
|
||||
GlobalInputs::check();
|
||||
}
|
||||
|
||||
// Inicializa el array de índices de líneas (imita el direccionamiento de memoria del Spectrum)
|
||||
@@ -76,7 +76,7 @@ void LoadingScreen::initLineIndexArray() {
|
||||
// Transiciona a un nuevo estado
|
||||
void LoadingScreen::transitionToState(LoadingState new_state) {
|
||||
state_ = new_state;
|
||||
state_time_ = 0.0f;
|
||||
state_time_ = 0.0F;
|
||||
|
||||
// Acciones específicas al entrar en cada estado
|
||||
switch (new_state) {
|
||||
@@ -172,31 +172,31 @@ void LoadingScreen::updateState(float delta_time) {
|
||||
void LoadingScreen::updateMonoLoad(float delta_time) {
|
||||
// Calcular progreso lineal (0.0 - 1.0)
|
||||
float progress = state_time_ / LOADING_MONO_DURATION;
|
||||
progress = std::min(progress, 1.0f);
|
||||
progress = std::min(progress, 1.0F);
|
||||
|
||||
// Calcular paso total actual (0-959)
|
||||
const int total_steps = MONO_TOTAL_LINES * MONO_STEPS_PER_LINE; // 192 * 5 = 960
|
||||
const int current_step = static_cast<int>(progress * total_steps);
|
||||
const int TOTAL_STEPS = MONO_TOTAL_LINES * MONO_STEPS_PER_LINE; // 192 * 5 = 960
|
||||
const int CURRENT_STEP = static_cast<int>(progress * TOTAL_STEPS);
|
||||
|
||||
// Calcular línea y sub-paso
|
||||
const int current_line = current_step / MONO_STEPS_PER_LINE; // 0-191
|
||||
const int current_substep = current_step % MONO_STEPS_PER_LINE; // 0-4
|
||||
const int CURRENT_LINE = CURRENT_STEP / MONO_STEPS_PER_LINE; // 0-191
|
||||
const int CURRENT_SUBSTEP = CURRENT_STEP % MONO_STEPS_PER_LINE; // 0-4
|
||||
|
||||
// Verificar si ha completado todas las líneas
|
||||
if (current_line >= MONO_TOTAL_LINES) {
|
||||
if (CURRENT_LINE >= MONO_TOTAL_LINES) {
|
||||
transitionToState(LoadingState::LOADING_COLOR);
|
||||
return;
|
||||
}
|
||||
|
||||
// Calcular rectángulo de clip (con floats para mayor precisión)
|
||||
const float texture_width = static_cast<float>(mono_loading_screen_surface_->getWidth());
|
||||
const float clip_width = texture_width / MONO_STEPS_PER_LINE;
|
||||
const float clip_x = current_substep * clip_width;
|
||||
const float TEXTURE_WIDTH = mono_loading_screen_surface_->getWidth();
|
||||
const float CLIP_WIDTH = TEXTURE_WIDTH / MONO_STEPS_PER_LINE;
|
||||
const float CLIP_X = CURRENT_SUBSTEP * CLIP_WIDTH;
|
||||
|
||||
load_rect_.x = clip_x;
|
||||
load_rect_.y = static_cast<float>(line_index_[current_line]);
|
||||
load_rect_.w = clip_width;
|
||||
load_rect_.h = 1.0f;
|
||||
load_rect_.x = CLIP_X;
|
||||
load_rect_.y = static_cast<float>(line_index_[CURRENT_LINE]);
|
||||
load_rect_.w = CLIP_WIDTH;
|
||||
load_rect_.h = 1.0F;
|
||||
|
||||
// Configurar y dibujar sobre screen_surface_
|
||||
mono_loading_screen_sprite_->setClip(load_rect_);
|
||||
@@ -212,24 +212,24 @@ void LoadingScreen::updateMonoLoad(float delta_time) {
|
||||
void LoadingScreen::updateColorLoad(float delta_time) {
|
||||
// Calcular progreso lineal (0.0 - 1.0)
|
||||
float progress = state_time_ / LOADING_COLOR_DURATION;
|
||||
progress = std::min(progress, 1.0f);
|
||||
progress = std::min(progress, 1.0F);
|
||||
|
||||
// Calcular iteración actual (el código original incrementaba de 2 en 2)
|
||||
const int total_iterations = COLOR_TOTAL_BLOCKS / 2; // 768 / 2 = 384 iteraciones
|
||||
const int current_iteration = static_cast<int>(progress * total_iterations);
|
||||
const int TOTAL_ITERATIONS = COLOR_TOTAL_BLOCKS / 2; // 768 / 2 = 384 iteraciones
|
||||
const int CURRENT_ITERATION = static_cast<int>(progress * TOTAL_ITERATIONS);
|
||||
|
||||
// Convertir a bloque (incrementa de 2 en 2, empezando en 0)
|
||||
const int current_block = current_iteration * 2;
|
||||
const int CURRENT_BLOCK = CURRENT_ITERATION * 2;
|
||||
|
||||
// Verificar si ha completado todos los bloques
|
||||
if (current_block >= COLOR_TOTAL_BLOCKS) {
|
||||
if (CURRENT_BLOCK >= COLOR_TOTAL_BLOCKS) {
|
||||
transitionToState(LoadingState::BYTES2);
|
||||
return;
|
||||
}
|
||||
|
||||
// Calcular posición del bloque
|
||||
load_rect_.x = static_cast<float>((current_block * COLOR_BLOCK_SPACING) % 256);
|
||||
load_rect_.y = static_cast<float>((current_block / COLOR_BLOCKS_PER_ROW) * COLOR_BLOCK_SPACING);
|
||||
load_rect_.x = static_cast<float>((CURRENT_BLOCK * COLOR_BLOCK_SPACING) % 256);
|
||||
load_rect_.y = static_cast<float>((CURRENT_BLOCK / COLOR_BLOCKS_PER_ROW) * COLOR_BLOCK_SPACING);
|
||||
load_rect_.w = static_cast<float>(COLOR_BLOCK_WIDTH);
|
||||
load_rect_.h = static_cast<float>(COLOR_BLOCK_HEIGHT);
|
||||
|
||||
@@ -255,7 +255,7 @@ void LoadingScreen::renderYellowBorder() {
|
||||
const Uint8 COLOR = static_cast<Uint8>(PaletteColor::YELLOW);
|
||||
const int WIDTH = Options::game.width + (Options::video.border.width * 2);
|
||||
const int HEIGHT = Options::game.height + (Options::video.border.height * 2);
|
||||
bool draw_enabled = rand() % 2 == 0 ? true : false;
|
||||
bool draw_enabled = rand() % 2 == 0;
|
||||
|
||||
int row = 0;
|
||||
while (row < HEIGHT) {
|
||||
@@ -320,10 +320,10 @@ void LoadingScreen::renderWhiteBorder() {
|
||||
// Actualiza las variables
|
||||
void LoadingScreen::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
|
||||
updateState(DELTA_TIME); // Actualiza el estado y gestiona transiciones
|
||||
|
||||
// Actualizar la carga según el estado actual
|
||||
switch (state_) {
|
||||
@@ -338,11 +338,11 @@ void LoadingScreen::update() {
|
||||
break;
|
||||
|
||||
case LoadingState::LOADING_MONO:
|
||||
updateMonoLoad(delta_time);
|
||||
updateMonoLoad(DELTA_TIME);
|
||||
break;
|
||||
|
||||
case LoadingState::LOADING_COLOR:
|
||||
updateColorLoad(delta_time);
|
||||
updateColorLoad(DELTA_TIME);
|
||||
break;
|
||||
|
||||
case LoadingState::COMPLETE:
|
||||
|
||||
Reference in New Issue
Block a user