diff --git a/Makefile b/Makefile index f159be9..e77ace1 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ CC = gcc CFLAGS = -Wall -Wextra -LIBFLAGS = $(shell pkg-config --cflags --libs sdl2 SDL2_image SDL2_ttf) +LIBFLAGS = $(shell pkg-config --cflags --libs sdl2 SDL2_image SDL2_ttf SDL2_mixer) TARGET = sokoban SRCDIR = script OBJDIR = obj diff --git a/script/main.c b/script/main.c index 397e9c7..349441d 100644 --- a/script/main.c +++ b/script/main.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -46,6 +47,46 @@ int main () nullScore(&score_user); SDL_RenderClear(display_user.renderer); SDL_Event event; + + //mixeur audio + // Initialisation de SDL_mixer + if (Mix_Init(MIX_INIT_MP3) == 0) { + printf("Erreur Mix_Init : %s\n", Mix_GetError()); + SDL_Quit(); + return -1; + } + + // Ouverture du mixeur audio + if (Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 2, 4096) < 0) { + printf("Erreur Mix_OpenAudio : %s\n", Mix_GetError()); + Mix_Quit(); + SDL_Quit(); + return -1; + } + + // Charger un fichier son + Mix_Chunk* son = Mix_LoadWAV("sfx/win.mp3"); + if (!son) { + printf("Erreur Mix_LoadWAV : %s\n", Mix_GetError()); + Mix_CloseAudio(); + Mix_Quit(); + SDL_Quit(); + return -1; + } + + // Charger une musique + Mix_Music* musique = Mix_LoadMUS("musique.mp3"); + if (!musique) { + printf("Erreur Mix_LoadMUS : %s\n", Mix_GetError()); + Mix_FreeChunk(son); + Mix_CloseAudio(); + Mix_Quit(); + SDL_Quit(); + return -1; + } + + // Jouer le son une seule fois + Mix_PlayChannel(-1, son, 0); // Loop pour le jeu entier menu et les jeux. while(output != 0) @@ -125,6 +166,8 @@ int main () if (tab2d != NULL)free2D (tab2d, SIZE_PLAY); if (playerPos != NULL)free (playerPos); if (targets != NULL)free (targets); + Mix_FreeChunk(son); + Mix_CloseAudio(); SDL_Quit (); return 0; diff --git a/sfx/blockontarget.wav b/sfx/blockontarget.wav new file mode 100644 index 0000000..121f121 --- /dev/null +++ b/sfx/blockontarget.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:89afb1335ff2621e53e725ad3c178a95e797ddc3604e23ee64acc4e6f1396588 +size 12512 diff --git a/sfx/cantmove.wav b/sfx/cantmove.wav new file mode 100644 index 0000000..d6e897c --- /dev/null +++ b/sfx/cantmove.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c758d044bd3e81b59c2ee8982d4d89126f11b4ee5fb00c4466ec8463251e0ed3 +size 8132 diff --git a/sfx/editor.mp3 b/sfx/editor.mp3 new file mode 100644 index 0000000..0ae8178 --- /dev/null +++ b/sfx/editor.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e5ea04f38ee5e47eaf463560b41be31c8c4923b2dff564841f289eb5c71f2aef +size 2214484 diff --git a/sfx/levelPlay.mp3 b/sfx/levelPlay.mp3 new file mode 100644 index 0000000..0d97474 --- /dev/null +++ b/sfx/levelPlay.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:da18e13d06c95c2e063def13b44258caf8566e5edbdf5b8b20dad11394806437 +size 3232633 diff --git a/sfx/lose.wav b/sfx/lose.wav new file mode 100644 index 0000000..5c9e3b3 --- /dev/null +++ b/sfx/lose.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4912ab2e95522feafa71bb978b7bfdde43681c38ae7129bf00338041f7c2c138 +size 22197 diff --git a/sfx/move.mp3 b/sfx/move.mp3 new file mode 100644 index 0000000..fa708be --- /dev/null +++ b/sfx/move.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:07c5c92eee53cb3b311b14189ce68c3eb524e0d6077b9ee0c01edf4d74b8e9bf +size 60186 diff --git a/sfx/moveblock.wav b/sfx/moveblock.wav new file mode 100644 index 0000000..92a4012 --- /dev/null +++ b/sfx/moveblock.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ac1f6557b1608c67167485fb11806ee6e0e44295495ebd6e74f566585f7587fb +size 5389 diff --git a/sfx/musicMenu.mp3 b/sfx/musicMenu.mp3 new file mode 100644 index 0000000..b44765c --- /dev/null +++ b/sfx/musicMenu.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:47c62a0772c78d9ecc2f83423e00b1ca03622ef7b501566c0ad4c54bfdbd387c +size 2712901 diff --git a/sfx/win.wav b/sfx/win.wav new file mode 100644 index 0000000..bc0890e --- /dev/null +++ b/sfx/win.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:43bc0664d91cbcd8fe875b82c9113635acfa7174888d9a91b731f48539bfa503 +size 15601