Au, paca casa. M'he quedat a mitjes fent un fade de audio sincronitzat amb el fade de video en el titol

This commit is contained in:
2024-12-23 13:56:11 +01:00
parent fb4d0d12db
commit ca2c48ea17
6 changed files with 45 additions and 25 deletions

View File

@@ -100,6 +100,8 @@ void Fade::update()
SDL_RenderFillRect(renderer_, &rect1_);
SDL_RenderFillRect(renderer_, &rect2_);
value_ = calculateValue(0, counter_, i);
}
// Deja el renderizador como estaba
@@ -139,6 +141,8 @@ void Fade::update()
SDL_SetRenderTarget(renderer_, temp);
}
value_ = calculateValue(0, static_cast<int>(num_squares_width_ * num_squares_height_), static_cast<int>(counter_ * fade_random_squares_mult_ / fade_random_squares_delay_));
// Comprueba si ha terminado
if (counter_ * fade_random_squares_mult_ / fade_random_squares_delay_ >= num_squares_width_ * num_squares_height_)
{
@@ -337,4 +341,12 @@ void Fade::cleanBackbuffer(Uint8 r, Uint8 g, Uint8 b, Uint8 a)
// Vuelve a dejar el renderizador como estaba
SDL_SetRenderTarget(renderer_, temp);
}
// Calcula el valor del estado del fade
int Fade::calculateValue(int min, int max, int current)
{
if (max == 0)
return 0;
return std::clamp(current * 100 / max, 0, 100);
}