This commit is contained in:
2025-10-19 22:01:31 +02:00
parent 16306f2325
commit 2b4523d644
101 changed files with 2058 additions and 1564 deletions

View File

@@ -90,19 +90,19 @@ void Instructions::updateSprites() {
SDL_FRect src_rect = {0, 0, Item::WIDTH, Item::HEIGHT};
// Disquito (desplazamiento 12/60 = 0.2s)
src_rect.y = Item::HEIGHT * (static_cast<int>((elapsed_time_ + 0.2f) / SPRITE_ANIMATION_CYCLE_S) % 2);
src_rect.y = Item::HEIGHT * (static_cast<int>((elapsed_time_ + 0.2F) / SPRITE_ANIMATION_CYCLE_S) % 2);
sprites_[0]->setSpriteClip(src_rect);
// Gavina (desplazamiento 9/60 = 0.15s)
src_rect.y = Item::HEIGHT * (static_cast<int>((elapsed_time_ + 0.15f) / SPRITE_ANIMATION_CYCLE_S) % 2);
src_rect.y = Item::HEIGHT * (static_cast<int>((elapsed_time_ + 0.15F) / SPRITE_ANIMATION_CYCLE_S) % 2);
sprites_[1]->setSpriteClip(src_rect);
// Pacmar (desplazamiento 6/60 = 0.1s)
src_rect.y = Item::HEIGHT * (static_cast<int>((elapsed_time_ + 0.1f) / SPRITE_ANIMATION_CYCLE_S) % 2);
src_rect.y = Item::HEIGHT * (static_cast<int>((elapsed_time_ + 0.1F) / SPRITE_ANIMATION_CYCLE_S) % 2);
sprites_[2]->setSpriteClip(src_rect);
// Time Stopper (desplazamiento 3/60 = 0.05s)
src_rect.y = Item::HEIGHT * (static_cast<int>((elapsed_time_ + 0.05f) / SPRITE_ANIMATION_CYCLE_S) % 2);
src_rect.y = Item::HEIGHT * (static_cast<int>((elapsed_time_ + 0.05F) / SPRITE_ANIMATION_CYCLE_S) % 2);
sprites_[3]->setSpriteClip(src_rect);
// Coffee (sin desplazamiento)
@@ -255,11 +255,11 @@ void Instructions::checkInput() {
}
// Calcula el tiempo transcurrido desde el último frame
float Instructions::calculateDeltaTime() {
const Uint64 current_time = SDL_GetTicks();
const float delta_time = static_cast<float>(current_time - last_time_) / 1000.0f; // Convertir ms a segundos
last_time_ = current_time;
return delta_time;
auto Instructions::calculateDeltaTime() -> float {
const Uint64 CURRENT_TIME = SDL_GetTicks();
const float DELTA_TIME = static_cast<float>(CURRENT_TIME - last_time_) / 1000.0F; // Convertir ms a segundos
last_time_ = CURRENT_TIME;
return DELTA_TIME;
}
// Bucle para la pantalla de instrucciones
@@ -268,10 +268,10 @@ void Instructions::run() {
Audio::get()->playMusic("title.ogg");
while (Section::name == Section::Name::INSTRUCTIONS) {
const float delta_time = calculateDeltaTime();
const float DELTA_TIME = calculateDeltaTime();
checkInput();
update(delta_time);
update(DELTA_TIME);
checkEvents(); // Tiene que ir antes del render
render();
}
@@ -328,7 +328,7 @@ void Instructions::renderLines(SDL_Renderer* renderer, SDL_Texture* texture, con
// Gestiona la textura con los graficos
void Instructions::updateBackbuffer(float delta_time) {
// Establece la ventana del backbuffer (convertir elapsed_time_ a equivalente de counter)
float counter_equivalent = elapsed_time_ * 60.0f; // Convertir segundos a equivalente frame para UI
float counter_equivalent = elapsed_time_ * 60.0F; // Convertir segundos a equivalente frame para UI
view_.y = std::max(0.0F, param.game.height - counter_equivalent + 100);
// Verifica si view_.y == 0 y gestiona el temporizador
@@ -336,7 +336,7 @@ void Instructions::updateBackbuffer(float delta_time) {
if (!start_delay_triggered_) {
// Activa el temporizador si no ha sido activado
start_delay_triggered_ = true;
start_delay_timer_ = 0.0f;
start_delay_timer_ = 0.0F;
} else {
start_delay_timer_ += delta_time;
if (start_delay_timer_ >= START_DELAY_S) {