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