"Gilbert and the doors"
I compiled it but when i run i have in debugger (gdb) :
Program received signal SIGSEGV, Segmentation fault.
#0 0x400a2994 in Mix_VolumeChunk()
from /mnt/utmp/codeblocks/usr/lib/libSDL_mixer-1.2-so.0
#1 0x000119d4 in main (argc=1, argv=0xbeffe874) at Gilbert.c:94
Where the code in Gilbert.c at line 94 is:
Mix_VolumeChunk(jump, MIX_MAX_VOLUME);
here in spoiler the code that initialize the SDL at file Gilbert.c:
int main(int argc,char *argv[]){
MainBoot();//initialisation des variable public au demarage
//FreeConsole(); //efface le terminal pour windows
if ((SDL_Init(SDL_INIT_EVERYTHING)) == -1 ){
fprintf(stderr,"Erreur SDL\n");return -1;}
//Joystick variable
SDL_Joystick* Joyst=NULL;
NumberofJoystick=SDL_NumJoysticks();
SDL_WM_SetCaption("Gilbert and the Doors v1.0 (2016-2017)", NULL);
// debut Configuration du son
if (Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, MIX_DEFAULT_CHANNELS,2048) == -1) //Mixer init music
{
printf("%s", Mix_GetError());
}
//definition du nombre de canaux et du volume
Mix_AllocateChannels(12);
Mix_Volume(1, MIX_MAX_VOLUME/2);
Mix_VolumeMusic(MUSICVOLUME);
Mix_Music *music;
music=Mix_LoadMUS("MUSIC/intro.wav");
//Créer les pointeurs pour stocker les .WAV
Mix_Chunk *jump;
Mix_Chunk *jump2;
Mix_Chunk *key;
Mix_Chunk *bump;
Mix_Chunk *outch;
Mix_Chunk *coin;
Mix_Chunk *explose;
Mix_Chunk *gameover;
Mix_Chunk *switchon;
Mix_Chunk *switchoff;
Mix_Chunk *opendoor;
Mix_Chunk *badaboum;
Mix_Chunk *vital;
//Charge les wav dans les pointeurs
jump = Mix_LoadWAV("SND/jump.wav");
jump2 = Mix_LoadWAV("SND/jump2.wav");
key = Mix_LoadWAV("SND/key.wav");
bump = Mix_LoadWAV("SND/bump.wav");
outch = Mix_LoadWAV("SND/outch.wav");
coin = Mix_LoadWAV("SND/coin.wav");
explose = Mix_LoadWAV("SND/explose.wav");
gameover = Mix_LoadWAV("SND/game over.wav");
switchon = Mix_LoadWAV("SND/switchon.wav");
switchoff = Mix_LoadWAV("SND/switchoff.wav");
opendoor = Mix_LoadWAV("SND/opendoor.wav");
vital = Mix_LoadWAV("SND/vital.wav");
badaboum = Mix_LoadWAV("SND/badaboum.wav");
//attribuer les volumes pour les wav
Mix_VolumeChunk(jump, MIX_MAX_VOLUME);
Mix_VolumeChunk(jump2, MIX_MAX_VOLUME);
Mix_VolumeChunk(key, MIX_MAX_VOLUME/2);
Mix_VolumeChunk(bump, MIX_MAX_VOLUME/2);
Mix_VolumeChunk(outch, MIX_MAX_VOLUME/4);
Mix_VolumeChunk(coin, MIX_MAX_VOLUME);
Mix_VolumeChunk(explose, MIX_MAX_VOLUME);
Mix_VolumeChunk(gameover, MIX_MAX_VOLUME);
Mix_VolumeChunk(switchon, MIX_MAX_VOLUME/2);
Mix_VolumeChunk(switchoff, MIX_MAX_VOLUME/2);
Mix_VolumeChunk(opendoor, MIX_MAX_VOLUME/8);
Mix_VolumeChunk(badaboum, MIX_MAX_VOLUME);
Mix_VolumeChunk(vital, MIX_MAX_VOLUME/2);
// fin Configuration du son
MainBoot();//initialisation des variable public au demarage
//FreeConsole(); //efface le terminal pour windows
if ((SDL_Init(SDL_INIT_EVERYTHING)) == -1 ){
fprintf(stderr,"Erreur SDL\n");return -1;}
//Joystick variable
SDL_Joystick* Joyst=NULL;
NumberofJoystick=SDL_NumJoysticks();
SDL_WM_SetCaption("Gilbert and the Doors v1.0 (2016-2017)", NULL);
// debut Configuration du son
if (Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, MIX_DEFAULT_CHANNELS,2048) == -1) //Mixer init music
{
printf("%s", Mix_GetError());
}
//definition du nombre de canaux et du volume
Mix_AllocateChannels(12);
Mix_Volume(1, MIX_MAX_VOLUME/2);
Mix_VolumeMusic(MUSICVOLUME);
Mix_Music *music;
music=Mix_LoadMUS("MUSIC/intro.wav");
//Créer les pointeurs pour stocker les .WAV
Mix_Chunk *jump;
Mix_Chunk *jump2;
Mix_Chunk *key;
Mix_Chunk *bump;
Mix_Chunk *outch;
Mix_Chunk *coin;
Mix_Chunk *explose;
Mix_Chunk *gameover;
Mix_Chunk *switchon;
Mix_Chunk *switchoff;
Mix_Chunk *opendoor;
Mix_Chunk *badaboum;
Mix_Chunk *vital;
//Charge les wav dans les pointeurs
jump = Mix_LoadWAV("SND/jump.wav");
jump2 = Mix_LoadWAV("SND/jump2.wav");
key = Mix_LoadWAV("SND/key.wav");
bump = Mix_LoadWAV("SND/bump.wav");
outch = Mix_LoadWAV("SND/outch.wav");
coin = Mix_LoadWAV("SND/coin.wav");
explose = Mix_LoadWAV("SND/explose.wav");
gameover = Mix_LoadWAV("SND/game over.wav");
switchon = Mix_LoadWAV("SND/switchon.wav");
switchoff = Mix_LoadWAV("SND/switchoff.wav");
opendoor = Mix_LoadWAV("SND/opendoor.wav");
vital = Mix_LoadWAV("SND/vital.wav");
badaboum = Mix_LoadWAV("SND/badaboum.wav");
//attribuer les volumes pour les wav
Mix_VolumeChunk(jump, MIX_MAX_VOLUME);
Mix_VolumeChunk(jump2, MIX_MAX_VOLUME);
Mix_VolumeChunk(key, MIX_MAX_VOLUME/2);
Mix_VolumeChunk(bump, MIX_MAX_VOLUME/2);
Mix_VolumeChunk(outch, MIX_MAX_VOLUME/4);
Mix_VolumeChunk(coin, MIX_MAX_VOLUME);
Mix_VolumeChunk(explose, MIX_MAX_VOLUME);
Mix_VolumeChunk(gameover, MIX_MAX_VOLUME);
Mix_VolumeChunk(switchon, MIX_MAX_VOLUME/2);
Mix_VolumeChunk(switchoff, MIX_MAX_VOLUME/2);
Mix_VolumeChunk(opendoor, MIX_MAX_VOLUME/8);
Mix_VolumeChunk(badaboum, MIX_MAX_VOLUME);
Mix_VolumeChunk(vital, MIX_MAX_VOLUME/2);
// fin Configuration du son