ajout de la librairie sdl mixer plus changement dans le makefile
This commit is contained in:
2
Makefile
2
Makefile
@@ -1,6 +1,6 @@
|
|||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -Wall -Wextra
|
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
|
TARGET = sokoban
|
||||||
SRCDIR = script
|
SRCDIR = script
|
||||||
OBJDIR = obj
|
OBJDIR = obj
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include <SDL2/SDL_image.h>
|
#include <SDL2/SDL_image.h>
|
||||||
#include <SDL2/SDL_render.h>
|
#include <SDL2/SDL_render.h>
|
||||||
|
#include <SDL2/SDL_mixer.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -46,6 +47,46 @@ int main ()
|
|||||||
nullScore(&score_user);
|
nullScore(&score_user);
|
||||||
SDL_RenderClear(display_user.renderer);
|
SDL_RenderClear(display_user.renderer);
|
||||||
SDL_Event event;
|
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.
|
// Loop pour le jeu entier menu et les jeux.
|
||||||
while(output != 0)
|
while(output != 0)
|
||||||
@@ -125,6 +166,8 @@ int main ()
|
|||||||
if (tab2d != NULL)free2D (tab2d, SIZE_PLAY);
|
if (tab2d != NULL)free2D (tab2d, SIZE_PLAY);
|
||||||
if (playerPos != NULL)free (playerPos);
|
if (playerPos != NULL)free (playerPos);
|
||||||
if (targets != NULL)free (targets);
|
if (targets != NULL)free (targets);
|
||||||
|
Mix_FreeChunk(son);
|
||||||
|
Mix_CloseAudio();
|
||||||
SDL_Quit ();
|
SDL_Quit ();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
BIN
sfx/blockontarget.wav
LFS
Normal file
BIN
sfx/blockontarget.wav
LFS
Normal file
Binary file not shown.
BIN
sfx/cantmove.wav
LFS
Normal file
BIN
sfx/cantmove.wav
LFS
Normal file
Binary file not shown.
BIN
sfx/editor.mp3
LFS
Normal file
BIN
sfx/editor.mp3
LFS
Normal file
Binary file not shown.
BIN
sfx/levelPlay.mp3
LFS
Normal file
BIN
sfx/levelPlay.mp3
LFS
Normal file
Binary file not shown.
BIN
sfx/lose.wav
LFS
Normal file
BIN
sfx/lose.wav
LFS
Normal file
Binary file not shown.
BIN
sfx/move.mp3
LFS
Normal file
BIN
sfx/move.mp3
LFS
Normal file
Binary file not shown.
BIN
sfx/moveblock.wav
LFS
Normal file
BIN
sfx/moveblock.wav
LFS
Normal file
Binary file not shown.
BIN
sfx/musicMenu.mp3
LFS
Normal file
BIN
sfx/musicMenu.mp3
LFS
Normal file
Binary file not shown.
BIN
sfx/win.wav
LFS
Normal file
BIN
sfx/win.wav
LFS
Normal file
Binary file not shown.
Reference in New Issue
Block a user