Creada la classe Resource
Afegida la musica i els sons a Resource
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include "notifier.h" // for Notifier
|
||||
#include "options.h" // for options
|
||||
#include "param.h" // for param
|
||||
#include "resource.h" // for Resource
|
||||
#include "screen.h" // for Screen
|
||||
#include "section.h" // for Options, options, Name, name
|
||||
#include "texture.h" // for Texture
|
||||
@@ -22,13 +23,10 @@
|
||||
struct JA_Music_t; // lines 17-17
|
||||
|
||||
// Constructor
|
||||
Title::Title(JA_Music_t *music)
|
||||
: music_(music)
|
||||
Title::Title()
|
||||
{
|
||||
// Copia las direcciones de los punteros y objetos
|
||||
input_ = Input::get();
|
||||
screen_ = Screen::get();
|
||||
SDL_Renderer *renderer = screen_->getRenderer();
|
||||
SDL_Renderer *renderer = Screen::get()->getRenderer();
|
||||
|
||||
// Reserva memoria y crea los objetos
|
||||
fade_ = std::make_unique<Fade>(renderer);
|
||||
@@ -66,7 +64,7 @@ void Title::init()
|
||||
fade_->setType(FadeType::RANDOM_SQUARE);
|
||||
fade_->setPost(param.fade.post_duration);
|
||||
demo_ = true;
|
||||
num_controllers_ = input_->getNumControllers();
|
||||
num_controllers_ = Input::get()->getNumControllers();
|
||||
}
|
||||
|
||||
// Actualiza las variables del objeto
|
||||
@@ -79,7 +77,7 @@ void Title::update()
|
||||
ticks_ = SDL_GetTicks();
|
||||
|
||||
// Actualiza el objeto screen
|
||||
screen_->update();
|
||||
Screen::get()->update();
|
||||
|
||||
// Comprueba el fade_ y si se ha acabado
|
||||
fade_->update();
|
||||
@@ -116,7 +114,7 @@ void Title::update()
|
||||
// Reproduce la música
|
||||
if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED))
|
||||
{
|
||||
JA_PlayMusic(music_);
|
||||
JA_PlayMusic(Resource::get()->getMusic("title.ogg"));
|
||||
}
|
||||
|
||||
// Actualiza el logo con el título del juego
|
||||
@@ -138,10 +136,10 @@ void Title::update()
|
||||
void Title::render()
|
||||
{
|
||||
// Prepara para empezar a dibujar en la textura de juego
|
||||
screen_->start();
|
||||
Screen::get()->start();
|
||||
|
||||
// Limpia la pantalla
|
||||
screen_->clean(bg_color);
|
||||
Screen::get()->clean(bg_color);
|
||||
|
||||
// Dibuja el mosacico de fondo
|
||||
tiled_bg_->render();
|
||||
@@ -176,7 +174,7 @@ void Title::render()
|
||||
fade_->render();
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
screen_->blit();
|
||||
Screen::get()->blit();
|
||||
}
|
||||
|
||||
// Comprueba los eventos
|
||||
@@ -241,7 +239,7 @@ void Title::checkInput()
|
||||
if (!define_buttons_->isEnabled())
|
||||
{
|
||||
// Comprueba el teclado para empezar a jugar
|
||||
if (input_->checkInput(InputType::START, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
|
||||
if (Input::get()->checkInput(InputType::START, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
|
||||
{
|
||||
if (section::options == section::Options::TITLE_2 || ALLOW_TITLE_ANIMATION_SKIP)
|
||||
{
|
||||
@@ -251,27 +249,27 @@ void Title::checkInput()
|
||||
}
|
||||
|
||||
// Comprueba los mandos
|
||||
for (int i = 0; i < input_->getNumControllers(); ++i)
|
||||
for (int i = 0; i < Input::get()->getNumControllers(); ++i)
|
||||
{
|
||||
// Comprueba si se va a intercambiar la asignación de mandos a jugadores
|
||||
if (input_->checkModInput(InputType::SERVICE, InputType::SWAP_CONTROLLERS, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
if (Input::get()->checkModInput(InputType::SERVICE, InputType::SWAP_CONTROLLERS, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
{
|
||||
swapControllers();
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba si algun mando quiere ser configurado
|
||||
if (input_->checkModInput(InputType::SERVICE, InputType::CONFIG, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
if (Input::get()->checkModInput(InputType::SERVICE, InputType::CONFIG, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
{
|
||||
define_buttons_->enable(i);
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba el botón de START de los mandos
|
||||
if (input_->checkInput(InputType::START, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
if (Input::get()->checkInput(InputType::START, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
{
|
||||
// Si no está el botón de servicio activo
|
||||
if (!input_->checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
if (!Input::get()->checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
{
|
||||
if (section::options == section::Options::TITLE_2 || ALLOW_TITLE_ANIMATION_SKIP)
|
||||
{
|
||||
@@ -285,7 +283,7 @@ void Title::checkInput()
|
||||
}
|
||||
|
||||
// Comprueba el input para el resto de objetos
|
||||
screen_->checkInput();
|
||||
Screen::get()->checkInput();
|
||||
define_buttons_->checkInput();
|
||||
|
||||
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
|
||||
@@ -320,7 +318,7 @@ void Title::resetCounter()
|
||||
// Intercambia la asignación de mandos a los jugadores
|
||||
void Title::swapControllers()
|
||||
{
|
||||
const auto num_controllers = input_->getNumControllers();
|
||||
const auto num_controllers = Input::get()->getNumControllers();
|
||||
|
||||
if (num_controllers == 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user