Commit per a vore qué està passant amb la música
This commit is contained in:
103
source/title.cpp
103
source/title.cpp
@@ -33,7 +33,8 @@ Title::Title()
|
||||
game_logo_(std::make_unique<GameLogo>(param.game.game_area.center_x, param.title.title_c_c_position)),
|
||||
mini_logo_sprite_(std::make_unique<Sprite>(Resource::get()->getTexture("logo_jailgames_mini.png"))),
|
||||
define_buttons_(std::make_unique<DefineButtons>()),
|
||||
num_controllers_(Input::get()->getNumControllers())
|
||||
num_controllers_(Input::get()->getNumControllers()),
|
||||
state_(TitleState::LOGO_ANIMATING)
|
||||
{
|
||||
// Configura objetos
|
||||
game_logo_->enable();
|
||||
@@ -73,9 +74,8 @@ void Title::update()
|
||||
// Actualiza las variables de globalInputs
|
||||
globalInputs::update();
|
||||
|
||||
// Comprueba el fundido y si se ha acabado
|
||||
// Comprueba el fundido
|
||||
fade_->update();
|
||||
// JA_SetMusicVolume(100 - fade_->getValue());
|
||||
if (fade_->hasEnded())
|
||||
{
|
||||
if (post_fade_ == -1)
|
||||
@@ -90,18 +90,19 @@ void Title::update()
|
||||
}
|
||||
}
|
||||
|
||||
// Sección 1 - Titulo animandose
|
||||
if (section::options == section::Options::TITLE_1)
|
||||
// Establece la lógica según el estado
|
||||
switch (state_)
|
||||
{
|
||||
case TitleState::LOGO_ANIMATING:
|
||||
{
|
||||
game_logo_->update();
|
||||
if (game_logo_->hasFinished())
|
||||
{
|
||||
section::options = section::Options::TITLE_2;
|
||||
state_ = TitleState::LOGO_FINISHED;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Sección 2 - La pantalla con el titulo, el fondo animado y la música
|
||||
else if (section::options == section::Options::TITLE_2)
|
||||
case TitleState::LOGO_FINISHED:
|
||||
{
|
||||
// El contador solo sube si no estamos definiendo botones
|
||||
counter_ = define_buttons_->isEnabled() ? 0 : counter_ + 1;
|
||||
@@ -109,10 +110,7 @@ void Title::update()
|
||||
// Reproduce la música
|
||||
if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED))
|
||||
{
|
||||
if (!fade_->isEnabled())
|
||||
{
|
||||
JA_PlayMusic(Resource::get()->getMusic("title.ogg"));
|
||||
}
|
||||
JA_PlayMusic(Resource::get()->getMusic("title.ogg"));
|
||||
}
|
||||
|
||||
// Actualiza el logo con el título del juego
|
||||
@@ -126,6 +124,27 @@ void Title::update()
|
||||
fade_->activate();
|
||||
post_fade_ = -1;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case TitleState::START_HAS_BEEN_PRESSED:
|
||||
{
|
||||
// Actualiza el logo con el título del juego
|
||||
game_logo_->update();
|
||||
|
||||
// Actualiza el mosaico de fondo
|
||||
tiled_bg_->update();
|
||||
|
||||
if (counter_ == 100)
|
||||
{
|
||||
fade_->activate();
|
||||
}
|
||||
++counter_;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -145,16 +164,10 @@ void Title::render()
|
||||
// Dibuja el logo con el título del juego
|
||||
game_logo_->render();
|
||||
|
||||
if (section::options == section::Options::TITLE_2)
|
||||
constexpr Color shadow = Color(0x14, 0x87, 0xc4);
|
||||
|
||||
if (state_ != TitleState::LOGO_ANIMATING)
|
||||
{
|
||||
constexpr Color shadow = Color(0x14, 0x87, 0xc4);
|
||||
|
||||
// 'PRESS TO PLAY'
|
||||
if (counter_ % 50 > 14 && !define_buttons_->isEnabled())
|
||||
{
|
||||
text_->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, param.title.press_start_position, lang::getText(23), 1, no_color, 1, shadow);
|
||||
}
|
||||
|
||||
// Mini logo
|
||||
const int pos1 = (param.game.height / 5 * 4) + BLOCK;
|
||||
const int pos2 = pos1 + mini_logo_sprite_->getHeight() + 3;
|
||||
@@ -165,6 +178,24 @@ void Title::render()
|
||||
text_->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, pos2, TEXT_COPYRIGHT, 1, no_color, 1, shadow);
|
||||
}
|
||||
|
||||
if (state_ == TitleState::LOGO_FINISHED)
|
||||
{
|
||||
// 'PRESS TO PLAY'
|
||||
if (counter_ % 50 > 14 && !define_buttons_->isEnabled())
|
||||
{
|
||||
text_->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, param.title.press_start_position, lang::getText(23), 1, no_color, 1, shadow);
|
||||
}
|
||||
}
|
||||
|
||||
if (state_ == TitleState::START_HAS_BEEN_PRESSED)
|
||||
{
|
||||
// 'PRESS TO PLAY'
|
||||
if (counter_ % 10 > 4 && !define_buttons_->isEnabled())
|
||||
{
|
||||
text_->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, param.title.press_start_position, lang::getText(23), 1, no_color, 1, shadow);
|
||||
}
|
||||
}
|
||||
|
||||
// Define Buttons
|
||||
define_buttons_->render();
|
||||
|
||||
@@ -246,29 +277,28 @@ void Title::checkEvents()
|
||||
// Comprueba las entradas
|
||||
void Title::checkInput()
|
||||
{
|
||||
// Comprueba los controladores solo si no se estan definiendo los botones
|
||||
// Comprueba las entradas solo si no se estan definiendo los botones
|
||||
if (!define_buttons_->isEnabled())
|
||||
{
|
||||
// Comprueba los métodos de control
|
||||
// Comprueba todos los métodos de control
|
||||
for (const auto &controller : options.controllers)
|
||||
{
|
||||
// START
|
||||
if (Input::get()->checkInput(InputType::START, INPUT_DO_NOT_ALLOW_REPEAT, controller.type, controller.index) &&
|
||||
!Input::get()->checkInput(InputType::SERVICE, INPUT_DO_NOT_ALLOW_REPEAT, controller.type, controller.index))
|
||||
{
|
||||
if (section::options == section::Options::TITLE_2 || ALLOW_TITLE_ANIMATION_SKIP)
|
||||
if (state_ == TitleState::LOGO_FINISHED || ALLOW_TITLE_ANIMATION_SKIP)
|
||||
{
|
||||
if (!fade_->isEnabled())
|
||||
{
|
||||
JA_PlaySound(Resource::get()->getSound("game_start.wav"));
|
||||
JA_FadeOutMusic(1500);
|
||||
fade_->activate();
|
||||
post_fade_ = controller.player_id;
|
||||
return;
|
||||
}
|
||||
JA_PlaySound(Resource::get()->getSound("game_start.wav"));
|
||||
JA_FadeOutMusic(1500);
|
||||
post_fade_ = controller.player_id;
|
||||
state_ = TitleState::START_HAS_BEEN_PRESSED;
|
||||
counter_ = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba si se va a intercambiar la asignación de mandos a jugadores
|
||||
// SWAP_CONTROLLERS
|
||||
if (Input::get()->checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, controller.type, controller.index) &&
|
||||
Input::get()->checkInput(InputType::SWAP_CONTROLLERS, INPUT_DO_NOT_ALLOW_REPEAT, controller.type, controller.index))
|
||||
{
|
||||
@@ -276,7 +306,7 @@ void Title::checkInput()
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba si algun mando quiere ser configurado
|
||||
// CONFIG
|
||||
if (Input::get()->checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, controller.type, controller.index) &&
|
||||
Input::get()->checkInput(InputType::CONFIG, INPUT_DO_NOT_ALLOW_REPEAT, controller.type, controller.index))
|
||||
{
|
||||
@@ -355,7 +385,6 @@ void Title::showControllers()
|
||||
}
|
||||
}
|
||||
|
||||
// std::string spaces(lang::getText(100).length() + 3, ' ');
|
||||
// std::string kb_text = spaces + lang::getText(69);
|
||||
// Muestra la notificación
|
||||
Notifier::get()->showText({text.at(0), text.at(1)});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user