revisat logo.cpp
This commit is contained in:
@@ -82,7 +82,7 @@ void Logo::checkInput() {
|
||||
void Logo::handleSound() {
|
||||
static bool sound_triggered = false;
|
||||
|
||||
if (!sound_triggered && elapsed_time_ms_ >= SOUND_TRIGGER_TIME_MS) {
|
||||
if (!sound_triggered && elapsed_time_s_ >= SOUND_TRIGGER_TIME_S) {
|
||||
Audio::get()->playSound("logo.wav");
|
||||
sound_triggered = true;
|
||||
}
|
||||
@@ -90,8 +90,8 @@ void Logo::handleSound() {
|
||||
|
||||
// Gestiona el logo de JAILGAMES
|
||||
void Logo::updateJAILGAMES(float delta_time) {
|
||||
if (elapsed_time_ms_ > SOUND_TRIGGER_TIME_MS) {
|
||||
const float PIXELS_TO_MOVE = LOGO_SPEED_PX_PER_MS * delta_time;
|
||||
if (elapsed_time_s_ > SOUND_TRIGGER_TIME_S) {
|
||||
const float PIXELS_TO_MOVE = LOGO_SPEED_PX_PER_S * delta_time;
|
||||
|
||||
for (size_t i = 0; i < jail_sprite_.size(); ++i) {
|
||||
if (jail_sprite_[i]->getX() != dest_.x) {
|
||||
@@ -111,7 +111,7 @@ void Logo::updateJAILGAMES(float delta_time) {
|
||||
}
|
||||
|
||||
// Comprueba si ha terminado el logo
|
||||
if (elapsed_time_ms_ >= END_LOGO_TIME_MS + POST_LOGO_DURATION_MS) {
|
||||
if (elapsed_time_s_ >= END_LOGO_TIME_S + POST_LOGO_DURATION_S) {
|
||||
Section::name = Section::Name::INTRO;
|
||||
}
|
||||
}
|
||||
@@ -120,16 +120,16 @@ void Logo::updateJAILGAMES(float delta_time) {
|
||||
void Logo::updateTextureColors(float delta_time) {
|
||||
// Manejo de 'sinceTexture'
|
||||
for (int i = 0; i <= MAX_SINCE_COLOR_INDEX; ++i) {
|
||||
const float target_time = SHOW_SINCE_SPRITE_TIME_MS + COLOR_CHANGE_INTERVAL_MS * i;
|
||||
if (elapsed_time_ms_ >= target_time && elapsed_time_ms_ - delta_time < target_time) {
|
||||
const float target_time = SHOW_SINCE_SPRITE_TIME_S + COLOR_CHANGE_INTERVAL_S * i;
|
||||
if (elapsed_time_s_ >= target_time && elapsed_time_s_ - delta_time < target_time) {
|
||||
since_texture_->setColor(color_[i].r, color_[i].g, color_[i].b);
|
||||
}
|
||||
}
|
||||
|
||||
// Manejo de 'jailTexture' y 'sinceTexture' en el fade
|
||||
for (int i = 0; i <= MAX_FADE_COLOR_INDEX; ++i) {
|
||||
const float target_time = INIT_FADE_TIME_MS + COLOR_CHANGE_INTERVAL_MS * i;
|
||||
if (elapsed_time_ms_ >= target_time && elapsed_time_ms_ - delta_time < target_time) {
|
||||
const float target_time = INIT_FADE_TIME_S + COLOR_CHANGE_INTERVAL_S * i;
|
||||
if (elapsed_time_s_ >= target_time && elapsed_time_s_ - delta_time < target_time) {
|
||||
jail_texture_->setColor(color_[MAX_FADE_COLOR_INDEX - i].r, color_[MAX_FADE_COLOR_INDEX - i].g, color_[MAX_FADE_COLOR_INDEX - i].b);
|
||||
since_texture_->setColor(color_[MAX_FADE_COLOR_INDEX - i].r, color_[MAX_FADE_COLOR_INDEX - i].g, color_[MAX_FADE_COLOR_INDEX - i].b);
|
||||
}
|
||||
@@ -138,7 +138,7 @@ void Logo::updateTextureColors(float delta_time) {
|
||||
|
||||
// Actualiza las variables
|
||||
void Logo::update(float delta_time) {
|
||||
elapsed_time_ms_ += delta_time; // Acumula el tiempo transcurrido
|
||||
elapsed_time_s_ += delta_time; // Acumula el tiempo transcurrido
|
||||
|
||||
Screen::get()->update(); // Actualiza el objeto screen
|
||||
Audio::update(); // Actualiza el objeto audio
|
||||
@@ -163,7 +163,7 @@ void Logo::render() {
|
||||
// Calcula el tiempo transcurrido desde el último frame
|
||||
float Logo::calculateDeltaTime() {
|
||||
const Uint64 current_time = SDL_GetTicks();
|
||||
const float delta_time = static_cast<float>(current_time - last_time_);
|
||||
const float delta_time = static_cast<float>(current_time - last_time_) / 1000.0f; // Convertir ms a segundos
|
||||
last_time_ = current_time;
|
||||
return delta_time;
|
||||
}
|
||||
@@ -189,7 +189,7 @@ void Logo::renderJAILGAMES() {
|
||||
sprite->render();
|
||||
}
|
||||
|
||||
if (elapsed_time_ms_ >= SHOW_SINCE_SPRITE_TIME_MS) {
|
||||
if (elapsed_time_s_ >= SHOW_SINCE_SPRITE_TIME_S) {
|
||||
since_sprite_->render();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user