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