Commit 61af3c7b authored by Benjamin LEROUX's avatar Benjamin LEROUX

ajout bande son

parent 4ebd12c1
......@@ -69,6 +69,9 @@ static int highscore;
static Sound fruitSound ;
static Sound goldenFruitSound;
static Sound deathSound;
static Music music;
//------------------------------------------------------------------------------------
// Module Functions Declaration (local)
......@@ -89,7 +92,11 @@ int main(void)
InitWindow(screenWidth, screenHeight, "sample game: snake");
InitGame();
InitAudioDevice(); // Initialize audio device
InitAudioDevice(); // Initialize audio device
StopMusicStream(music);
PlayMusicStream(music);
#if defined(PLATFORM_WEB)
emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
......@@ -150,6 +157,7 @@ void InitGame(void)
snakePosition[i] = (Vector2){ 0.0f, 0.0f };
}
//fruits
fruit.size = (Vector2){ SQUARE_SIZE, SQUARE_SIZE };
fruit.color = GREEN;
fruit.active = false;
......@@ -162,6 +170,7 @@ void InitGame(void)
deadFruit.color=BLACK;
deadFruit.active=false;
//murs
recTab[0].x=2*SQUARE_SIZE + offset.x/2; //mur haut gauche
recTab[0].y=2*SQUARE_SIZE + offset.y/2;
recTab[0].width=(SQUARE_SIZE)-0.1;
......@@ -204,9 +213,11 @@ void InitGame(void)
highscore=LoadStorageValue(0);
//sons
fruitSound = LoadSound("SnakeSounds\\coin.wav"); // Load audio files
goldenFruitSound = LoadSound("SnakeSounds\\sound.wav");
deathSound = LoadSound("SnakeSounds\\tanatana.ogg");
deathSound = LoadSound("SnakeSounds\\tanatana.ogg");
music = LoadMusicStream("SnakeSounds\\mini1111.xm");
}
void drawWalls(){
......@@ -245,6 +256,8 @@ void UpdateGame(void)
if (!pause)
{
UpdateMusicStream(music);
// Player control
if (IsKeyPressed(KEY_RIGHT) && (snake[0].speed.x == 0) && allowMove)
{
......@@ -400,6 +413,8 @@ void UpdateGame(void)
if (IsKeyPressed(KEY_ENTER))
{
InitGame();
StopMusicStream(music);
PlayMusicStream(music);
gameOver = false;
}
}
......@@ -467,6 +482,7 @@ void UnloadGame(void)
UnloadSound(fruitSound);
UnloadSound(goldenFruitSound);
UnloadSound(deathSound);
CloseAudioDevice();
}
// Update and Draw (one frame)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment