Añadida música al titulo
This commit is contained in:
@@ -3,16 +3,27 @@
|
||||
// Constructor
|
||||
Game::Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input)
|
||||
{
|
||||
// Copia punteros
|
||||
this->renderer = renderer;
|
||||
this->asset = asset;
|
||||
this->screen = screen;
|
||||
this->input = input;
|
||||
|
||||
// Reserva memoria para los objetos
|
||||
eventHandler = new SDL_Event();
|
||||
map = new Map(asset->get("01.map"), renderer, asset);
|
||||
player = new Player(renderer, asset, input, map);
|
||||
debugText = new Text(asset->get("debug.png"), asset->get("debug.txt"), renderer);
|
||||
music = JA_LoadMusic(asset->get("music_surface.ogg").c_str());
|
||||
|
||||
// Inicializa variables
|
||||
ticks = 0;
|
||||
ticksSpeed = 15;
|
||||
|
||||
section.name = SECTION_PROG_GAME;
|
||||
section.subsection = SUBSECTION_GAME_PLAY;
|
||||
|
||||
debug = false;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
@@ -28,8 +39,6 @@ Game::~Game()
|
||||
// Bucle para el juego
|
||||
section_t Game::run()
|
||||
{
|
||||
init();
|
||||
|
||||
JA_PlayMusic(music);
|
||||
|
||||
while (section.name == SECTION_PROG_GAME)
|
||||
@@ -47,18 +56,6 @@ section_t Game::run()
|
||||
return section;
|
||||
}
|
||||
|
||||
// Inicializa las variables necesarias para la sección 'Game'
|
||||
void Game::init()
|
||||
{
|
||||
ticks = 0;
|
||||
ticksSpeed = 15;
|
||||
|
||||
section.name = SECTION_PROG_GAME;
|
||||
section.subsection = SUBSECTION_GAME_PLAY;
|
||||
|
||||
debug = true;
|
||||
}
|
||||
|
||||
// Actualiza el juego, las variables, comprueba la entrada, etc.
|
||||
void Game::update()
|
||||
{
|
||||
|
||||
@@ -35,9 +35,6 @@ private:
|
||||
// Pinta los objetos en pantalla
|
||||
void render();
|
||||
|
||||
// Inicializa las variables necesarias para la sección 'Game'
|
||||
void init();
|
||||
|
||||
// Comprueba la entrada
|
||||
void checkInput();
|
||||
|
||||
|
||||
@@ -164,13 +164,15 @@ bool Prog::setFileList()
|
||||
asset->add("/data/sound/sound_menu_start.wav", sound);
|
||||
|
||||
// Ficheros con musica
|
||||
asset->add("/data/music/music_menu.ogg", music);
|
||||
asset->add("/data/music/music_title.ogg", music);
|
||||
asset->add("/data/music/music_surface.ogg", music);
|
||||
asset->add("/data/music/music_volcano.ogg", music);
|
||||
|
||||
// Ficheros de fuentes de texto
|
||||
asset->add("/data/font/debug.png", font);
|
||||
asset->add("/data/font/debug.txt", font);
|
||||
asset->add("/data/font/dogica.png", font);
|
||||
asset->add("/data/font/dogica.txt", font);
|
||||
|
||||
// Ficheros de enemigos
|
||||
asset->add("/data/actors/enemies/walking_eye.png", bitmap);
|
||||
|
||||
@@ -16,6 +16,7 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input)
|
||||
sprite = new AnimatedSprite(texture, renderer, asset->get("intro.ani"));
|
||||
sprite->setCurrentAnimation("menu");
|
||||
text = new Text(asset->get("debug.png"), asset->get("debug.txt"), renderer);
|
||||
music = JA_LoadMusic(asset->get("music_title.ogg").c_str());
|
||||
|
||||
// Inicializa variables
|
||||
section = {SECTION_PROG_TITLE, 0};
|
||||
@@ -42,6 +43,8 @@ Title::~Title()
|
||||
|
||||
delete text;
|
||||
text = nullptr;
|
||||
|
||||
JA_DeleteMusic(music);
|
||||
}
|
||||
|
||||
// Actualiza las variables
|
||||
@@ -85,7 +88,9 @@ void Title::render()
|
||||
|
||||
// Dibuja los objetos
|
||||
sprite->render();
|
||||
text->writeCentered(160, 200, "@2016,2022 JailDesigner (v0.6)", -1);
|
||||
//text->writeCentered(160, 200, "@2016,2022 JAILDESIGNER & JAILBROTHER (v0.6)", -1);
|
||||
const color_t color = {179,83,71};
|
||||
text->writeDX(TXT_CENTER|TXT_COLOR,160, 200, "@2016,2022 JAILDESIGNER & JAILBROTHER (v0.6)", -1, color);
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
screen->blit();
|
||||
@@ -94,6 +99,8 @@ void Title::render()
|
||||
// Bucle principal
|
||||
section_t Title::run()
|
||||
{
|
||||
JA_PlayMusic(music);
|
||||
|
||||
while (section.name == SECTION_PROG_TITLE)
|
||||
{
|
||||
update();
|
||||
@@ -101,4 +108,6 @@ section_t Title::run()
|
||||
}
|
||||
|
||||
return section;
|
||||
|
||||
JA_StopMusic();
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ private:
|
||||
Input *input; // Objeto para gestionar las entradas
|
||||
Text *text; // Objeto para escribir texto en pantalla
|
||||
AnimatedSprite *sprite; // Sprite para dibujar los graficos de la intro
|
||||
JA_Music music; // Musica del titulo del juego
|
||||
section_t section; // Estado del bucle principal para saber si continua o se sale
|
||||
int ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||
int ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||
|
||||
Reference in New Issue
Block a user