Merge branch 'main' of https://gitea.sustancia.synology.me/JailDesigner/coffee_crisis_arcade_edition
This commit is contained in:
@@ -54,7 +54,7 @@ Director::Director(int argc, const char *argv[])
|
||||
section::name = section::Name::GAME;
|
||||
section::options = section::Options::GAME_PLAY_1P;
|
||||
#elif DEBUG
|
||||
section::name = section::Name::GAME;
|
||||
section::name = section::Name::LOGO;
|
||||
#else // NORMAL GAME
|
||||
section::name = section::Name::LOGO;
|
||||
section::attract_mode = section::AttractMode::TITLE_TO_DEMO;
|
||||
|
||||
@@ -68,11 +68,9 @@ Game::Game(int player_id, int current_stage, bool demo)
|
||||
|
||||
fade_in_->setColor(fade_color.r, fade_color.g, fade_color.b);
|
||||
fade_in_->setPost(0);
|
||||
fade_in_->setType(FadeType::VENETIAN);
|
||||
fade_in_->setType(FadeType::RANDOM_SQUARE);
|
||||
fade_in_->setMode(FadeMode::IN);
|
||||
fade_in_->activate();
|
||||
// JA_PlaySound(Resource::get()->getSound("fade_in.wav"));
|
||||
// playMusic();
|
||||
|
||||
fade_out_->setColor(fade_color.r, fade_color.g, fade_color.b);
|
||||
fade_out_->setPost(param.fade.post_duration);
|
||||
@@ -943,15 +941,12 @@ void Game::fillCanvas()
|
||||
background_->render();
|
||||
renderItems();
|
||||
renderSmartSprites();
|
||||
tabe_->render();
|
||||
balloon_manager_->render();
|
||||
tabe_->render();
|
||||
renderBullets();
|
||||
renderPathSprites();
|
||||
renderPlayers();
|
||||
|
||||
auto sprite = std::make_unique<Sprite>(Resource::get()->getTexture("game_text_game_over"));
|
||||
sprite->render();
|
||||
|
||||
// Deja el renderizador apuntando donde estaba
|
||||
SDL_SetRenderTarget(renderer_, temp);
|
||||
}
|
||||
|
||||
@@ -416,7 +416,6 @@ void Intro::render()
|
||||
void Intro::run()
|
||||
{
|
||||
JA_PlayMusic(Resource::get()->getMusic("intro.ogg"), 0);
|
||||
|
||||
while (section::name == section::Name::INTRO)
|
||||
{
|
||||
checkInput();
|
||||
|
||||
@@ -234,7 +234,7 @@ void Logo::render()
|
||||
void Logo::run()
|
||||
{
|
||||
// Detiene la música
|
||||
JA_FadeOutMusic(500);
|
||||
JA_FadeOutMusic(300);
|
||||
|
||||
while (section::name == section::Name::LOGO)
|
||||
{
|
||||
|
||||
@@ -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,30 +90,28 @@ 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;
|
||||
|
||||
// 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"));
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza el logo con el título del juego
|
||||
game_logo_->update();
|
||||
@@ -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);
|
||||
|
||||
// 'PRESS TO PLAY'
|
||||
if (counter_ % 50 > 14 && !define_buttons_->isEnabled())
|
||||
if (state_ != TitleState::LOGO_ANIMATING)
|
||||
{
|
||||
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 (!fade_->isEnabled())
|
||||
if (state_ == TitleState::LOGO_FINISHED || ALLOW_TITLE_ANIMATION_SKIP)
|
||||
{
|
||||
JA_PlaySound(Resource::get()->getSound("game_start.wav"));
|
||||
JA_FadeOutMusic(1500);
|
||||
fade_->activate();
|
||||
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)});
|
||||
}
|
||||
|
||||
@@ -27,9 +27,10 @@ constexpr bool ALLOW_TITLE_ANIMATION_SKIP = false;
|
||||
- Dibujar el tileado de fondo
|
||||
- Redifinir los botones de los mandos de juego
|
||||
|
||||
Esta clase tiene dos estados:
|
||||
Esta clase tiene tres estados:
|
||||
- El titulo está animandose, con el fondo estático
|
||||
- El titulo ya está en su sitio y el fondo se está animando
|
||||
- Se ha pulsado el botón de start
|
||||
|
||||
Por razones de diseño, no se permite saltarse la animación del titulo, aunque es
|
||||
configurable mediante un define
|
||||
@@ -39,6 +40,14 @@ constexpr bool ALLOW_TITLE_ANIMATION_SKIP = false;
|
||||
class Title
|
||||
{
|
||||
private:
|
||||
// Enumeraciones
|
||||
enum class TitleState
|
||||
{
|
||||
LOGO_ANIMATING,
|
||||
LOGO_FINISHED,
|
||||
START_HAS_BEEN_PRESSED,
|
||||
};
|
||||
|
||||
// Objetos y punteros
|
||||
std::shared_ptr<Text> text_; // Objeto de texto para poder escribir textos en pantalla
|
||||
std::unique_ptr<Fade> fade_; // Objeto para realizar fundidos en pantalla
|
||||
@@ -53,6 +62,7 @@ private:
|
||||
section::Name next_section_; // Indica cual es la siguiente sección a cargar cuando termine el contador del titulo
|
||||
int post_fade_ = 0; // Opción a realizar cuando termina el fundido
|
||||
int num_controllers_; // Número de mandos conectados
|
||||
TitleState state_; // Estado en el que se encuentra la sección
|
||||
|
||||
// Actualiza las variables del objeto
|
||||
void update();
|
||||
|
||||
Reference in New Issue
Block a user