Commit 3432c1c6 authored by Lila NICKLER's avatar Lila NICKLER

Ajout music de fond

parent 933ba8b1
File added
...@@ -75,6 +75,8 @@ typedef struct Item{ ...@@ -75,6 +75,8 @@ typedef struct Item{
static const int screenWidth = 800; static const int screenWidth = 800;
static const int screenHeight = 450; static const int screenHeight = 450;
static Music music;
static bool gameOver = false; static bool gameOver = false;
static bool pause = false; static bool pause = false;
static int score = 0; static int score = 0;
...@@ -112,6 +114,10 @@ int main(void) ...@@ -112,6 +114,10 @@ int main(void)
// Initialization (Note windowTitle is unused on Android) // Initialization (Note windowTitle is unused on Android)
//--------------------------------------------------------- //---------------------------------------------------------
InitWindow(screenWidth, screenHeight, "sample game: space invaders"); InitWindow(screenWidth, screenHeight, "sample game: space invaders");
InitAudioDevice();
music = LoadMusicStream("music.mp3");
PlayMusicStream(music);
InitGame(); InitGame();
...@@ -133,6 +139,8 @@ int main(void) ...@@ -133,6 +139,8 @@ int main(void)
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadGame(); // Unload loaded data (textures, sounds, models...) UnloadGame(); // Unload loaded data (textures, sounds, models...)
UnloadMusicStream(music); // Unload music stream buffers from RAM
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
...@@ -159,6 +167,7 @@ void InitGame(void) ...@@ -159,6 +167,7 @@ void InitGame(void)
score = 0; score = 0;
alpha = 0; alpha = 0;
highscore =LoadStorageValue(0); highscore =LoadStorageValue(0);
PlayMusicStream(music);
// Initialize player // Initialize player
player.rec.x = 20; player.rec.x = 20;
...@@ -236,6 +245,8 @@ void UpdateGame(void) ...@@ -236,6 +245,8 @@ void UpdateGame(void)
{ {
if (!gameOver) if (!gameOver)
{ {
UpdateMusicStream(music);
if (IsKeyPressed('P')) pause = !pause; if (IsKeyPressed('P')) pause = !pause;
if (!pause) if (!pause)
...@@ -407,8 +418,7 @@ void UpdateGame(void) ...@@ -407,8 +418,7 @@ void UpdateGame(void)
enemy[i].rec.x = GetRandomValue(screenWidth, screenWidth + 1000); enemy[i].rec.x = GetRandomValue(screenWidth, screenWidth + 1000);
enemy[i].rec.y = GetRandomValue(0, screenHeight - enemy[i].rec.height); enemy[i].rec.y = GetRandomValue(0, screenHeight - enemy[i].rec.height);
player.life--; player.life--;
} }
// Perte du bonus // Perte du bonus
player.speed.x= 5; player.speed.x= 5;
......
File added
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