#include "setup.h"
/*global variable*/
-bool use_sound; /* handle sound on/off menu and command-line option */
-bool use_music; /* handle music on/off menu and command-line option */
-bool audio_device; /* != 0: available and initialized */
-int current_music;
+bool use_sound = true; /* handle sound on/off menu and command-line option */
+bool use_music = true; /* handle music on/off menu and command-line option */
+bool audio_device = true; /* != 0: available and initialized */
char * soundfilenames[NUM_SOUNDS] = {
"/sounds/jump.wav",
"/sounds/shoot.wav",
"/sounds/lifeup.wav",
"/sounds/stomp.wav",
- "/sounds/kick.wav"
+ "/sounds/kick.wav",
+ "/sounds/explode.wav"
};
#include <SDL_mixer.h>
Mix_Chunk * sounds[NUM_SOUNDS];
-Mix_Music * herring_song = 0;
-Mix_Music * current_song = 0;
/* --- OPEN THE AUDIO DEVICE --- */
snd = Mix_LoadWAV(file.c_str());
- /* printf message and abort if there is an initialized audio device */
if ((snd == NULL) && audio_device)
st_abort("Can't load", file);
Mix_Music * load_song(const std::string& file)
{
if(!audio_device)
- return 0;
+ return (Mix_Music*) ~0;
- Mix_Music * sng;
-
- sng = Mix_LoadMUS(file.c_str());
-
- /* printf message and abort if there is an initialized audio device */
- if (sng == NULL)
- st_abort("Can't load", file);
-
- return (sng);
+ Mix_Music* song = Mix_LoadMUS(file.c_str());
+ return song;
}
{
if (chunk != NULL)
{
- DEBUG_MSG( __PRETTY_FUNCTION__ );
Mix_FreeChunk( chunk );
chunk = NULL;
}
}
-void halt_music(void)
-{
- if (!use_music || !audio_device)
- return;
-
- Mix_HaltMusic();
- current_song = 0;
-}
-
-
-void play_music(Mix_Music *music)
-{
- if (!audio_device)
- return;
-
- if (use_music && Mix_PlayMusic(music, -1) < 0)
- st_abort("Couldn't play music: ", Mix_GetError());
-
- current_song = music;
-}
-
-
-void free_music(Mix_Music *music)
-{
- Mix_FreeMusic( music );
-}
-
-void enable_music(bool enable)
-{
- if(!audio_device)
- return;
-
- use_music = enable;
- if(!use_music)
- Mix_HaltMusic();
- else
- Mix_PlayMusic(current_song, -1);
-}
-