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:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user