Compare commits

..

5 Commits

7 changed files with 45 additions and 24 deletions

View File

@@ -24,7 +24,7 @@
#include "lang.h" #include "lang.h"
// Textos // Textos
constexpr const char TEXT_COPYRIGHT[] = "@2020,2024 JailDesigner"; constexpr const char TEXT_COPYRIGHT[] = "@2020,2025 JailDesigner";
// Constructor // Constructor
Credits::Credits() Credits::Credits()

View File

@@ -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));
} }

View File

@@ -35,6 +35,7 @@
#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
#include <iostream>
struct JA_Sound_t; // lines 37-37 struct JA_Sound_t; // lines 37-37
// Constructor // Constructor
@@ -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));
} }
} }
@@ -1035,8 +1044,7 @@ void Game::disableTimeStopItem()
void Game::checkMusicStatus() void Game::checkMusicStatus()
{ {
// Si se ha completado el juego o los jugadores han terminado, detiene la música // Si se ha completado el juego o los jugadores han terminado, detiene la música
// if (state_ != GameState::COMPLETED && !allPlayersAreGameOver()) if (state_ == GameState::PLAYING || state_ == GameState::SHOWING_GET_READY_MESSAGE)
if (state_ == GameState::PLAYING)
{ {
playMusic(); playMusic();
} }
@@ -1863,7 +1871,7 @@ void Game::updateGameStateEnteringPlayer()
{ {
state_ = GameState::SHOWING_GET_READY_MESSAGE; state_ = GameState::SHOWING_GET_READY_MESSAGE;
createMessage({paths_.at(0), paths_.at(1)}, Resource::get()->getTexture("game_text_get_ready")); createMessage({paths_.at(0), paths_.at(1)}, Resource::get()->getTexture("game_text_get_ready"));
JA_PlaySound(Resource::get()->getSound("voice_get_ready.wav")); //JA_PlaySound(Resource::get()->getSound("voice_get_ready.wav"));
} }
} }
} }
@@ -1882,6 +1890,10 @@ void Game::updateGameStateShowingGetReadyMessage()
{ {
state_ = GameState::PLAYING; state_ = GameState::PLAYING;
} }
else
{
path_sprites_.front()->getCurrentPath()
}
} }
// Actualiza las variables durante el transcurso normal del juego // Actualiza las variables durante el transcurso normal del juego

View File

@@ -245,7 +245,15 @@ bool Input::discoverGameControllers()
} }
std::cout << "\n** LOOKING FOR GAME CONTROLLERS" << std::endl; std::cout << "\n** LOOKING FOR GAME CONTROLLERS" << std::endl;
if (num_joysticks_ != num_gamepads_)
{
std::cout << "Joysticks found: " << num_joysticks_ << std::endl;
std::cout << "Gamepads found : " << num_gamepads_ << std::endl; std::cout << "Gamepads found : " << num_gamepads_ << std::endl;
}
else
{
std::cout << "Gamepads found: " << num_gamepads_ << std::endl;
}
if (num_gamepads_ > 0) if (num_gamepads_ > 0)
{ {

View File

@@ -96,24 +96,12 @@ void audioCallback(void * userdata, uint8_t * stream, int len) {
void JA_Init(const int freq, const SDL_AudioFormat format, const int channels) void JA_Init(const int freq, const SDL_AudioFormat format, const int channels)
{ {
#ifdef DEBUG
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG);
#endif
SDL_Log("Iniciant JailAudio...");
JA_freq = freq; JA_freq = freq;
JA_format = format; JA_format = format;
JA_channels = channels; JA_channels = channels;
SDL_AudioSpec audioSpec{JA_freq, JA_format, JA_channels, 0, 1024, 0, 0, audioCallback, NULL}; SDL_AudioSpec audioSpec{JA_freq, JA_format, JA_channels, 0, 1024, 0, 0, audioCallback, NULL};
if (sdlAudioDevice != 0) SDL_CloseAudioDevice(sdlAudioDevice); if (sdlAudioDevice != 0) SDL_CloseAudioDevice(sdlAudioDevice);
sdlAudioDevice = SDL_OpenAudioDevice(NULL, 0, &audioSpec, NULL, 0); sdlAudioDevice = SDL_OpenAudioDevice(NULL, 0, &audioSpec, NULL, 0);
if (sdlAudioDevice==0)
{
SDL_Log("FAILED!\n");
SDL_Log("Failed to initialize SDL audio!\n");
} else {
SDL_Log("OK!\n");
}
SDL_PauseAudioDevice(sdlAudioDevice, 0); SDL_PauseAudioDevice(sdlAudioDevice, 0);
} }

View File

@@ -73,4 +73,7 @@ public:
// Indica si ha terminado todos los recorridos // Indica si ha terminado todos los recorridos
bool hasFinished(); bool hasFinished();
// Getters
int getCurrentPath() const { return current_path_; }
}; };

View File

@@ -15,7 +15,7 @@ namespace section
} }
// Textos // Textos
constexpr const char TEXT_COPYRIGHT[] = "@2020,2024 JailDesigner"; constexpr const char TEXT_COPYRIGHT[] = "@2020,2025 JailDesigner";
// Parámetros // Parámetros
constexpr bool ALLOW_TITLE_ANIMATION_SKIP = false; constexpr bool ALLOW_TITLE_ANIMATION_SKIP = false;