Commit 2e75d74a authored by Pierre MARQUE's avatar Pierre MARQUE

Tout est fini mais les bruitages.wav ne marchent pas

parent a0796251
Mon projet est un projet de jeu de type "Air defense", avec une ou deux tourelles au sol qui doivent empecher les avions de faire trop dégats :
Mon projet est un projet de jeu de type "Air defense", avec deux tourelles au sol qui doivent abattre le maximum d'avions et laisser tomber le minimum de parachutistes.
- idee à approfondir :(une tourelle détruirait les avions tandis que l'autre détruirait les parachutistes)
Pour compiler : à l'aide de notepadd++ for raylib en faisant f6.
Pour lancer : cliquer sur l'éxécutable.
Vérifiiez que le fichiers musiques est dans le même répertoire que l'éxécuatble si vous souhaitez le son.
\ No newline at end of file
......@@ -49,9 +49,9 @@ double shoot_rate;
static bool gameOver = false;
static bool pause = false;
int score = 0;
int life = 5;
int NUMBER_OF_AIRCRAFTS =5;
int score ;
int life ;
int NUMBER_OF_AIRCRAFTS ;
const float bulletSpeed = 10;
const float bombshellSpeed = 6;
......@@ -77,6 +77,25 @@ Bullet bullet[NUMBER_OF_BULLETS] ;
Bombshell bombshells[NUMBER_OF_BOMBSHELLS] ;
Paratrooper paratrooper[NUMBER_MAX_OF_PARATROOPERS] ;
//--------------------------------------------------------------------------------------
// Music and sound
//--------------------------------------------------------------------------------------
const char* crystals = "Musiques/moon-crystals-hotline-miami-soundtrack.mp3";
const char* beams = "Musiques/Beams.mp3";
const char* Dust = "Musiques/MOON - Dust Synthwave.mp3";
Music gameMusic;
Music gameOverMusic;
Music gamePauseMusic;
const char* explosion = "Musiques/explosion.wav";
const char* alert = "Musiques/Alerte.wav";
const char* bombshellC = "Musiques/Missile-launch-Sound-effect.wav";
const char* bulletC = "Musiques/APC.wav";
Sound soundExplosion;
Sound soundAlert;
Sound soundBombshell ;
Sound soundBullet;
//------------------------------------------------------------------------------------
// Program main entry point
......@@ -89,18 +108,40 @@ int main(void)
InitWindow(screenWidth, screenHeight, "Air defense");
InitGame();
HideCursor();
InitAudioDevice();
LoadAudio();
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
if (!gameOver && !pause)
{
PlayMusicStream(gameMusic);
UpdateMusicStream(gameMusic);
}
else if (gameOver)
{
PlayMusicStream(gameOverMusic);
UpdateMusicStream(gameOverMusic);
}
else if (pause)
{
PlayMusicStream(gamePauseMusic);
UpdateMusicStream(gamePauseMusic);
}
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
UpdateGame();
//----------------------------------------------------------------------------------
......@@ -111,11 +152,14 @@ int main(void)
}
// De-Initialization
//--------------------------------------------------------------------------------------
//UnloadGame();
UnloadAudio();
CloseAudioDevice();
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
//return 0;
}
//-----------------------------------------------------------------------------------------
......@@ -128,7 +172,8 @@ void InitGame(void)
life = 5;
gameOver = false;
pause = false;
jalon = 100;
jalon = 1000;
NUMBER_OF_AIRCRAFTS = 5;
//Initialize paratroopers
for (int k=0; k < NUMBER_MAX_OF_PARATROOPERS; k++)
......@@ -167,15 +212,17 @@ void UpdateGame(void)
{
if (!gameOver)
{
if (IsKeyPressed('P')) pause = !pause;
if (IsKeyPressed('P'))
{
pause = !pause;
}
if (!pause)
{
framesCounter++;
if((score > jalon) && (NUMBER_OF_AIRCRAFTS< NUMBER_MAX_OF_AIRCRAFTS)){
NUMBER_OF_AIRCRAFTS+=5;
jalon+=1000;
life +=5 ;
life +=1 ;
}
//Moves
......@@ -262,6 +309,7 @@ void UpdateGame(void)
bombshells[i].position.y = antiAircraftCanon.position.y;
bombshells[i].speed.x = bombshellSpeed*antiAircraftCanon.cos;
bombshells[i].speed.y = bombshellSpeed*antiAircraftCanon.sin;
PlaySound(soundBombshell);
break;
}
}
......@@ -278,6 +326,7 @@ void UpdateGame(void)
bullet[i].position.y = antiParaCanon.position.y;
bullet[i].speed.x = bulletSpeed*antiParaCanon.cos;
bullet[i].speed.y = bulletSpeed*antiParaCanon.sin;
PlaySound(soundBullet);
break;
}
}
......@@ -336,6 +385,7 @@ void UpdateGame(void)
DrawCircle(bombshells[j].position.x,bombshells[j].position.y, 15, RED);
DrawCircle(bombshells[j].position.x+4,bombshells[j].position.y, 10, YELLOW);
aircraft[i].life = aircraft[i].life - 1;
PlaySound(soundExplosion);
//Kill aircrafts
if(aircraft[i].life == 0)
{
......@@ -393,13 +443,20 @@ void UpdateGame(void)
}
}
}
else
{
StopMusicStream(gameMusic);
}
}
else
{
StopMusicStream(gameMusic);
if (IsKeyPressed(KEY_ENTER))
{
InitGame();
gameOver = false;
}
}
}
......@@ -502,6 +559,30 @@ void DrawGame(void)
EndDrawing();
}
void LoadAudio(void)
{
//Musics
gameMusic = LoadMusicStream(crystals);
gameOverMusic = LoadMusicStream(beams);
gamePauseMusic = LoadMusicStream(Dust);
//Sounds
soundExplosion = LoadSound(explosion);
soundBullet = LoadSound(bulletC);
soundBombshell = LoadSound(bombshellC);
soundAlert = LoadSound(alert);
}
void UnloadAudio()
{
UnloadMusicStream(gameMusic);
UnloadMusicStream(gameOverMusic);
UnloadMusicStream(gamePauseMusic);
UnloadSound(soundAlert);
UnloadSound(soundBombshell);
UnloadSound(soundBullet);
UnloadSound(soundExplosion);
}
//------------------------------------------------------------------------------------
// Other Functions
......
No preview for this file type
......@@ -85,7 +85,8 @@ typedef struct Viewfinder
static void InitGame(void); // Initialize game
static void UpdateGame(void); // Update game (one frame)
static void DrawGame(void); // Draw game (one frame)
static void UnloadGame(void); // Unload game
static void LoadAudio(void);
static void UnloadAudio(void); // Unload game
//------------------------------------------------------------------------------------
// Other Functions
......
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