Afegit custom fadeout de so sincronitzat amb el fadeout de video per a quan acaba la partida
This commit is contained in:
@@ -151,7 +151,7 @@ void Fade::update()
|
|||||||
|
|
||||||
case FadeType::VENETIAN:
|
case FadeType::VENETIAN:
|
||||||
{
|
{
|
||||||
// Counter debe ir de 0 a 150
|
// Counter debe ir de 0 a 150 <-- comprobar si esto es aún cierto
|
||||||
if (square_.back().h < param.fade.venetian_size)
|
if (square_.back().h < param.fade.venetian_size)
|
||||||
{
|
{
|
||||||
// Dibuja sobre el backbuffer_
|
// Dibuja sobre el backbuffer_
|
||||||
@@ -176,6 +176,16 @@ void Fade::update()
|
|||||||
// A partir del segundo rectangulo se pinta en función del anterior
|
// A partir del segundo rectangulo se pinta en función del anterior
|
||||||
square_.at(i).h = i == 0 ? h : std::max(square_.at(i - 1).h - 2, 0);
|
square_.at(i).h = i == 0 ? h : std::max(square_.at(i - 1).h - 2, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int completed = 0;
|
||||||
|
for (const auto &square : square_)
|
||||||
|
{
|
||||||
|
if (square.h >= param.fade.venetian_size)
|
||||||
|
{
|
||||||
|
++completed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
value_ = calculateValue(0, square_.size() - 1, completed);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -315,9 +325,9 @@ void Fade::cleanBackbuffer(Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
|||||||
// Calcula el valor del estado del fade
|
// Calcula el valor del estado del fade
|
||||||
int Fade::calculateValue(int min, int max, int current)
|
int Fade::calculateValue(int min, int max, int current)
|
||||||
{
|
{
|
||||||
if (max == 0)
|
if (current < min)
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
if (current > max)
|
||||||
return std::clamp(current * 100 / max, 0, 100);
|
return 100;
|
||||||
|
return static_cast<int>(100.0 * (current - min) / (max - min));
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,8 @@
|
|||||||
#include "tabe.h" // Para Tabe
|
#include "tabe.h" // Para Tabe
|
||||||
#include "text.h" // Para Text
|
#include "text.h" // Para Text
|
||||||
#include "texture.h" // Para Texture
|
#include "texture.h" // Para Texture
|
||||||
struct JA_Sound_t; // lines 37-37
|
#include <iostream>
|
||||||
|
struct JA_Sound_t; // lines 37-37
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Game::Game(int player_id, int current_stage, bool demo)
|
Game::Game(int player_id, int current_stage, bool demo)
|
||||||
@@ -319,6 +320,12 @@ void Game::updateGameStateGameOver()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fade_out_->isEnabled())
|
||||||
|
{
|
||||||
|
const float vol = static_cast<float>(64 * (100 - fade_out_->getValue())) / 100.0f;
|
||||||
|
JA_SetSoundVolume(to_JA_volume(static_cast<int>(vol)));
|
||||||
|
}
|
||||||
|
|
||||||
if (fade_out_->hasEnded())
|
if (fade_out_->hasEnded())
|
||||||
{
|
{
|
||||||
if (game_completed_counter_ > 0)
|
if (game_completed_counter_ > 0)
|
||||||
@@ -331,6 +338,8 @@ void Game::updateGameStateGameOver()
|
|||||||
// La partida ha terminado con la derrota de los jugadores
|
// La partida ha terminado con la derrota de los jugadores
|
||||||
section::name = section::Name::HI_SCORE_TABLE;
|
section::name = section::Name::HI_SCORE_TABLE;
|
||||||
}
|
}
|
||||||
|
JA_StopChannel(-1);
|
||||||
|
JA_SetSoundVolume(to_JA_volume(options.audio.sound.volume));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user