Eliminado sdl_mixer

This commit is contained in:
2022-10-21 16:48:21 +02:00
parent fd1fc0b582
commit 58f9841f71
4 changed files with 73 additions and 49 deletions

View File

@@ -50,16 +50,20 @@ GameDirector::GameDirector(SDL_Renderer *gRenderer)
GameDirector::~GameDirector()
{
// Libera los efectos de sonido
Mix_FreeChunk(gPopBalloonFX);
Mix_FreeChunk(gBulletFX);
gPopBalloonFX = NULL;
gBulletFX = NULL;
// Mix_FreeChunk(gPopBalloonFX);
// Mix_FreeChunk(gBulletFX);
// gPopBalloonFX = NULL;
// gBulletFX = NULL;
JA_DeleteSound(gPopBalloonFX);
JA_DeleteSound(gBulletFX);
// Libra la música
Mix_FreeMusic(gTitleMusic);
gTitleMusic = NULL;
Mix_FreeMusic(gPlayingMusic);
gPlayingMusic = NULL;
// Mix_FreeMusic(gTitleMusic);
// gTitleMusic = NULL;
// Mix_FreeMusic(gPlayingMusic);
// gPlayingMusic = NULL;
JA_DeleteMusic(gTitleMusic);
JA_DeleteMusic(gPlayingMusic);
// Libera el mando
SDL_JoystickClose(gGameController);
@@ -92,32 +96,37 @@ GameDirector::~GameDirector()
void GameDirector::init()
{
// Carga la música del titulo
gTitleMusic = Mix_LoadMUS("media/music/title.ogg");
if (gTitleMusic == NULL)
{
printf("Failed to load title music! SDL_mixer Error: %s\n", Mix_GetError());
}
// gTitleMusic = Mix_LoadMUS("media/music/title.ogg");
// if (gTitleMusic == NULL)
//{
// printf("Failed to load title music! SDL_mixer Error: %s\n", Mix_GetError());
//}
// Carga la música del juego
gPlayingMusic = Mix_LoadMUS("media/music/playing.ogg");
if (gPlayingMusic == NULL)
{
printf("Failed to load playing music! SDL_mixer Error: %s\n", Mix_GetError());
}
// gPlayingMusic = Mix_LoadMUS("media/music/playing.ogg");
// if (gPlayingMusic == NULL)
//{
// printf("Failed to load playing music! SDL_mixer Error: %s\n", Mix_GetError());
//}
// Carga los efectos de sonido para la explosión de los globos
gPopBalloonFX = Mix_LoadWAV("media/sound/balloon.wav");
if (gPopBalloonFX == NULL)
{
printf("Failed to load balloon sound effect! SDL_mixer Error: %s\n", Mix_GetError());
}
// gPopBalloonFX = Mix_LoadWAV("media/sound/balloon.wav");
// if (gPopBalloonFX == NULL)
//{
// printf("Failed to load balloon sound effect! SDL_mixer Error: %s\n", Mix_GetError());
//}
// Carga los efectos de sonido para los disparos del jugador
gBulletFX = Mix_LoadWAV("media/sound/bullet.wav");
if (gBulletFX == NULL)
{
printf("Failed to load bullet sound effect! SDL_mixer Error: %s\n", Mix_GetError());
}
// gBulletFX = Mix_LoadWAV("media/sound/bullet.wav");
// if (gBulletFX == NULL)
//{
// printf("Failed to load bullet sound effect! SDL_mixer Error: %s\n", Mix_GetError());
//}
gTitleMusic = JA_LoadMusic("media/music/title.ogg");
gPlayingMusic = JA_LoadMusic("media/music/playing.ogg");
gPopBalloonFX = JA_LoadSound("media/sound/balloon.wav");
gBulletFX = JA_LoadSound("media/sound/bullet.wav");
gGameBackgroundTexture = new LTexture(gRenderer);
// Carga los gráficos del fondo del juego
@@ -471,7 +480,7 @@ void GameDirector::processBulletBallonCollision()
setScore(player->getScore());
updateHiScore();
popBalloon(i);
Mix_PlayChannel(-1, gPopBalloonFX, 0);
JA_PlaySound(gPopBalloonFX);
bullet[j]->erase();
calculateMenaceLevel();
break;
@@ -636,7 +645,7 @@ void GameDirector::checkGameInput()
player->setFireCooldown(10);
// Reproduce el sonido de disparo
Mix_PlayChannel(-1, gBulletFX, 0);
JA_PlaySound(gBulletFX);
}
}
@@ -649,7 +658,7 @@ void GameDirector::checkGameInput()
player->setFireCooldown(10);
// Reproduce el sonido de disparo
Mix_PlayChannel(-1, gBulletFX, 0);
JA_PlaySound(gBulletFX);
}
}
@@ -662,7 +671,7 @@ void GameDirector::checkGameInput()
player->setFireCooldown(10);
// Reproduce el sonido de disparo
Mix_PlayChannel(-1, gBulletFX, 0);
JA_PlaySound(gBulletFX);
}
}
@@ -672,7 +681,8 @@ void GameDirector::checkGameInput()
setGameStatus(GAME_STATE_PAUSED);
// Detiene la música
Mix_HaltMusic();
//Mix_HaltMusic();
JA_StopMusic();
}
}
@@ -888,10 +898,12 @@ void GameDirector::renderGetReady()
void GameDirector::runTitle()
{
// Si la música no está sonando
if (Mix_PlayingMusic() == 0)
//if (Mix_PlayingMusic() == 0)
if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED))
{
// Reproduce la música
Mix_PlayMusic(gTitleMusic, -1);
//Mix_PlayMusic(gTitleMusic, -1);
JA_PlayMusic(gTitleMusic);
}
// Comprueba los eventos que hay en la cola
@@ -925,14 +937,16 @@ void GameDirector::runTitle()
setGameStatus(GAME_STATE_PLAYING);
menuTitle->resetMenu();
renderTransition(1);
Mix_HaltMusic();
//Mix_HaltMusic();
JA_StopMusic();
SDL_Delay(1200);
break;
case 1:
setGameStatus(GAME_STATE_QUIT);
menuTitle->resetMenu();
renderTransition(1);
Mix_HaltMusic();
//Mix_HaltMusic();
JA_StopMusic();
break;
default:
break;
@@ -943,10 +957,12 @@ void GameDirector::runTitle()
void GameDirector::runGame()
{
// Si la música no está sonando
if (Mix_PlayingMusic() == 0)
//if (Mix_PlayingMusic() == 0)
if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED))
{
// Reproduce la música
Mix_PlayMusic(gPlayingMusic, -1);
//Mix_PlayMusic(gPlayingMusic, -1);
JA_PlayMusic(gPlayingMusic);
}
// Lógica del juego