Eliminado sdl_mixer
This commit is contained in:
@@ -50,16 +50,20 @@ GameDirector::GameDirector(SDL_Renderer *gRenderer)
|
|||||||
GameDirector::~GameDirector()
|
GameDirector::~GameDirector()
|
||||||
{
|
{
|
||||||
// Libera los efectos de sonido
|
// Libera los efectos de sonido
|
||||||
Mix_FreeChunk(gPopBalloonFX);
|
// Mix_FreeChunk(gPopBalloonFX);
|
||||||
Mix_FreeChunk(gBulletFX);
|
// Mix_FreeChunk(gBulletFX);
|
||||||
gPopBalloonFX = NULL;
|
// gPopBalloonFX = NULL;
|
||||||
gBulletFX = NULL;
|
// gBulletFX = NULL;
|
||||||
|
JA_DeleteSound(gPopBalloonFX);
|
||||||
|
JA_DeleteSound(gBulletFX);
|
||||||
|
|
||||||
// Libra la música
|
// Libra la música
|
||||||
Mix_FreeMusic(gTitleMusic);
|
// Mix_FreeMusic(gTitleMusic);
|
||||||
gTitleMusic = NULL;
|
// gTitleMusic = NULL;
|
||||||
Mix_FreeMusic(gPlayingMusic);
|
// Mix_FreeMusic(gPlayingMusic);
|
||||||
gPlayingMusic = NULL;
|
// gPlayingMusic = NULL;
|
||||||
|
JA_DeleteMusic(gTitleMusic);
|
||||||
|
JA_DeleteMusic(gPlayingMusic);
|
||||||
|
|
||||||
// Libera el mando
|
// Libera el mando
|
||||||
SDL_JoystickClose(gGameController);
|
SDL_JoystickClose(gGameController);
|
||||||
@@ -92,32 +96,37 @@ GameDirector::~GameDirector()
|
|||||||
void GameDirector::init()
|
void GameDirector::init()
|
||||||
{
|
{
|
||||||
// Carga la música del titulo
|
// Carga la música del titulo
|
||||||
gTitleMusic = Mix_LoadMUS("media/music/title.ogg");
|
// gTitleMusic = Mix_LoadMUS("media/music/title.ogg");
|
||||||
if (gTitleMusic == NULL)
|
// if (gTitleMusic == NULL)
|
||||||
{
|
//{
|
||||||
printf("Failed to load title music! SDL_mixer Error: %s\n", Mix_GetError());
|
// printf("Failed to load title music! SDL_mixer Error: %s\n", Mix_GetError());
|
||||||
}
|
//}
|
||||||
|
|
||||||
// Carga la música del juego
|
// Carga la música del juego
|
||||||
gPlayingMusic = Mix_LoadMUS("media/music/playing.ogg");
|
// gPlayingMusic = Mix_LoadMUS("media/music/playing.ogg");
|
||||||
if (gPlayingMusic == NULL)
|
// if (gPlayingMusic == NULL)
|
||||||
{
|
//{
|
||||||
printf("Failed to load playing music! SDL_mixer Error: %s\n", Mix_GetError());
|
// 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
|
// Carga los efectos de sonido para la explosión de los globos
|
||||||
gPopBalloonFX = Mix_LoadWAV("media/sound/balloon.wav");
|
// gPopBalloonFX = Mix_LoadWAV("media/sound/balloon.wav");
|
||||||
if (gPopBalloonFX == NULL)
|
// if (gPopBalloonFX == NULL)
|
||||||
{
|
//{
|
||||||
printf("Failed to load balloon sound effect! SDL_mixer Error: %s\n", Mix_GetError());
|
// printf("Failed to load balloon sound effect! SDL_mixer Error: %s\n", Mix_GetError());
|
||||||
}
|
//}
|
||||||
|
|
||||||
// Carga los efectos de sonido para los disparos del jugador
|
// Carga los efectos de sonido para los disparos del jugador
|
||||||
gBulletFX = Mix_LoadWAV("media/sound/bullet.wav");
|
// gBulletFX = Mix_LoadWAV("media/sound/bullet.wav");
|
||||||
if (gBulletFX == NULL)
|
// if (gBulletFX == NULL)
|
||||||
{
|
//{
|
||||||
printf("Failed to load bullet sound effect! SDL_mixer Error: %s\n", Mix_GetError());
|
// 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);
|
gGameBackgroundTexture = new LTexture(gRenderer);
|
||||||
// Carga los gráficos del fondo del juego
|
// Carga los gráficos del fondo del juego
|
||||||
@@ -471,7 +480,7 @@ void GameDirector::processBulletBallonCollision()
|
|||||||
setScore(player->getScore());
|
setScore(player->getScore());
|
||||||
updateHiScore();
|
updateHiScore();
|
||||||
popBalloon(i);
|
popBalloon(i);
|
||||||
Mix_PlayChannel(-1, gPopBalloonFX, 0);
|
JA_PlaySound(gPopBalloonFX);
|
||||||
bullet[j]->erase();
|
bullet[j]->erase();
|
||||||
calculateMenaceLevel();
|
calculateMenaceLevel();
|
||||||
break;
|
break;
|
||||||
@@ -636,7 +645,7 @@ void GameDirector::checkGameInput()
|
|||||||
player->setFireCooldown(10);
|
player->setFireCooldown(10);
|
||||||
|
|
||||||
// Reproduce el sonido de disparo
|
// Reproduce el sonido de disparo
|
||||||
Mix_PlayChannel(-1, gBulletFX, 0);
|
JA_PlaySound(gBulletFX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -649,7 +658,7 @@ void GameDirector::checkGameInput()
|
|||||||
player->setFireCooldown(10);
|
player->setFireCooldown(10);
|
||||||
|
|
||||||
// Reproduce el sonido de disparo
|
// Reproduce el sonido de disparo
|
||||||
Mix_PlayChannel(-1, gBulletFX, 0);
|
JA_PlaySound(gBulletFX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -662,7 +671,7 @@ void GameDirector::checkGameInput()
|
|||||||
player->setFireCooldown(10);
|
player->setFireCooldown(10);
|
||||||
|
|
||||||
// Reproduce el sonido de disparo
|
// Reproduce el sonido de disparo
|
||||||
Mix_PlayChannel(-1, gBulletFX, 0);
|
JA_PlaySound(gBulletFX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -672,7 +681,8 @@ void GameDirector::checkGameInput()
|
|||||||
setGameStatus(GAME_STATE_PAUSED);
|
setGameStatus(GAME_STATE_PAUSED);
|
||||||
|
|
||||||
// Detiene la música
|
// Detiene la música
|
||||||
Mix_HaltMusic();
|
//Mix_HaltMusic();
|
||||||
|
JA_StopMusic();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -888,10 +898,12 @@ void GameDirector::renderGetReady()
|
|||||||
void GameDirector::runTitle()
|
void GameDirector::runTitle()
|
||||||
{
|
{
|
||||||
// Si la música no está sonando
|
// 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
|
// Reproduce la música
|
||||||
Mix_PlayMusic(gTitleMusic, -1);
|
//Mix_PlayMusic(gTitleMusic, -1);
|
||||||
|
JA_PlayMusic(gTitleMusic);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba los eventos que hay en la cola
|
// Comprueba los eventos que hay en la cola
|
||||||
@@ -925,14 +937,16 @@ void GameDirector::runTitle()
|
|||||||
setGameStatus(GAME_STATE_PLAYING);
|
setGameStatus(GAME_STATE_PLAYING);
|
||||||
menuTitle->resetMenu();
|
menuTitle->resetMenu();
|
||||||
renderTransition(1);
|
renderTransition(1);
|
||||||
Mix_HaltMusic();
|
//Mix_HaltMusic();
|
||||||
|
JA_StopMusic();
|
||||||
SDL_Delay(1200);
|
SDL_Delay(1200);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
setGameStatus(GAME_STATE_QUIT);
|
setGameStatus(GAME_STATE_QUIT);
|
||||||
menuTitle->resetMenu();
|
menuTitle->resetMenu();
|
||||||
renderTransition(1);
|
renderTransition(1);
|
||||||
Mix_HaltMusic();
|
//Mix_HaltMusic();
|
||||||
|
JA_StopMusic();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -943,10 +957,12 @@ void GameDirector::runTitle()
|
|||||||
void GameDirector::runGame()
|
void GameDirector::runGame()
|
||||||
{
|
{
|
||||||
// Si la música no está sonando
|
// 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
|
// Reproduce la música
|
||||||
Mix_PlayMusic(gPlayingMusic, -1);
|
//Mix_PlayMusic(gPlayingMusic, -1);
|
||||||
|
JA_PlayMusic(gPlayingMusic);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lógica del juego
|
// Lógica del juego
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
|
#include "jail_audio.h"
|
||||||
|
|
||||||
#ifndef GAMEDIRECTOR_H
|
#ifndef GAMEDIRECTOR_H
|
||||||
#define GAMEDIRECTOR_H
|
#define GAMEDIRECTOR_H
|
||||||
@@ -133,12 +134,16 @@ private:
|
|||||||
SDL_Renderer *gRenderer = NULL;
|
SDL_Renderer *gRenderer = NULL;
|
||||||
|
|
||||||
// Objetos con la música del juego
|
// Objetos con la música del juego
|
||||||
Mix_Music *gTitleMusic = NULL;
|
//Mix_Music *gTitleMusic = NULL;
|
||||||
Mix_Music *gPlayingMusic = NULL;
|
//Mix_Music *gPlayingMusic = NULL;
|
||||||
|
JA_Music gTitleMusic;
|
||||||
|
JA_Music gPlayingMusic;
|
||||||
|
|
||||||
// Objetos con los efectos de sonido del juego
|
// Objetos con los efectos de sonido del juego
|
||||||
Mix_Chunk *gPopBalloonFX = NULL;
|
//Mix_Chunk *gPopBalloonFX = NULL;
|
||||||
Mix_Chunk *gBulletFX = NULL;
|
//Mix_Chunk *gBulletFX = NULL;
|
||||||
|
JA_Sound gPopBalloonFX;
|
||||||
|
JA_Sound gBulletFX;
|
||||||
|
|
||||||
// Manejador para el mando 1
|
// Manejador para el mando 1
|
||||||
SDL_Joystick *gGameController = NULL;
|
SDL_Joystick *gGameController = NULL;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
//#include <SDL2/SDL_image.h>
|
//#include <SDL2/SDL_image.h>
|
||||||
#include <SDL2/SDL_mixer.h>
|
//#include <SDL2/SDL_mixer.h>
|
||||||
|
|
||||||
#ifndef GLOBALS_H
|
#ifndef GLOBALS_H
|
||||||
#define GLOBALS_H
|
#define GLOBALS_H
|
||||||
|
|||||||
@@ -74,6 +74,9 @@ bool init()
|
|||||||
// Indicador de inicialización
|
// Indicador de inicialización
|
||||||
bool success = true;
|
bool success = true;
|
||||||
|
|
||||||
|
// Inicializa JailAudio
|
||||||
|
JA_Init(44100, AUDIO_S16, 2);
|
||||||
|
|
||||||
// Inicializa SDL
|
// Inicializa SDL
|
||||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO) < 0)
|
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO) < 0)
|
||||||
{
|
{
|
||||||
@@ -89,11 +92,11 @@ bool init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa SDL_mixer
|
// Inicializa SDL_mixer
|
||||||
if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048) < 0)
|
//if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048) < 0)
|
||||||
{
|
//{
|
||||||
printf("SDL_mixer could not initialize! SDL_mixer Error: %s\n", Mix_GetError());
|
// printf("SDL_mixer could not initialize! SDL_mixer Error: %s\n", Mix_GetError());
|
||||||
success = false;
|
// success = false;
|
||||||
}
|
//}
|
||||||
|
|
||||||
// Crea la ventana
|
// Crea la ventana
|
||||||
gWindow = SDL_CreateWindow("Super Popping (Like Loc) in Jailers World", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, VIEW_WIDTH, VIEW_HEIGHT, SDL_WINDOW_SHOWN);
|
gWindow = SDL_CreateWindow("Super Popping (Like Loc) in Jailers World", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, VIEW_WIDTH, VIEW_HEIGHT, SDL_WINDOW_SHOWN);
|
||||||
|
|||||||
Reference in New Issue
Block a user