Añadida música al titulo

This commit is contained in:
2022-08-23 17:03:10 +02:00
parent 87f6ec39ea
commit 2425ab5142
6 changed files with 25 additions and 19 deletions

View File

@@ -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()
{