Commit b0272bc9 authored by DIDON Maya's avatar DIDON Maya

Ajout d'effets sonores

parent ed9c6bb2
...@@ -112,6 +112,8 @@ static int highScore = 0; ...@@ -112,6 +112,8 @@ static int highScore = 0;
// Music variables // Music variables
Music soundtrack; Music soundtrack;
Sound losing;
Sound fading;
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Program main entry point // Program main entry point
...@@ -122,9 +124,14 @@ int main(void) ...@@ -122,9 +124,14 @@ int main(void)
//--------------------------------------------------------- //---------------------------------------------------------
InitWindow(screenWidth, screenHeight, "tetris - revamped"); InitWindow(screenWidth, screenHeight, "tetris - revamped");
// Initializing sound system
InitAudioDevice(); InitAudioDevice();
char *filename = "tetris-soundtrack.mp3"; char *music = "tetris-soundtrack.mp3";
soundtrack = LoadMusicStream(filename); char *fade = "fading-sound.mp3";
char *lose = "losing-sound.mp3";
soundtrack = LoadMusicStream(music);
fading = LoadSound(fade);
losing = LoadSound(lose);
PlayMusicStream(soundtrack); PlayMusicStream(soundtrack);
InitGame(); InitGame();
...@@ -301,6 +308,7 @@ void UpdateGame(void) ...@@ -301,6 +308,7 @@ void UpdateGame(void)
{ {
// Animation when deleting lines // Animation when deleting lines
fadeLineCounter++; fadeLineCounter++;
PlaySound(fading);
if (fadeLineCounter%8 < 4) fadingColor = MAROON; if (fadeLineCounter%8 < 4) fadingColor = MAROON;
else fadingColor = GRAY; else fadingColor = GRAY;
...@@ -320,10 +328,14 @@ void UpdateGame(void) ...@@ -320,10 +328,14 @@ void UpdateGame(void)
} }
else else
{ {
StopMusicStream(soundtrack);
PlaySound(losing);
if (IsKeyPressed(KEY_ENTER)) if (IsKeyPressed(KEY_ENTER))
{ {
InitGame(); InitGame();
gameOver = false; gameOver = false;
StopSound(losing);
PlayMusicStream(soundtrack);
} }
} }
} }
...@@ -415,8 +427,8 @@ void DrawGame(void) ...@@ -415,8 +427,8 @@ void DrawGame(void)
} }
DrawText("INCOMING:", offset.x, offset.y - 100, 10, GRAY); DrawText("INCOMING:", offset.x, offset.y - 100, 10, GRAY);
DrawText(TextFormat("LINES: %04i", lines), offset.x, offset.y + 20, 10, GRAY); DrawText(TextFormat("LINES: %04i", lines), offset.x, offset.y + 20, 15, GRAY);
DrawText(TextFormat("SCORE: %04i", score), offset.x, offset.y + 30, 10, RED); DrawText(TextFormat("SCORE: %04i", score), offset.x, offset.y + 50, 15, RED);
if (pause) DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY); if (pause) DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY);
} }
...@@ -433,6 +445,8 @@ void DrawGame(void) ...@@ -433,6 +445,8 @@ void DrawGame(void)
void UnloadGame(void) void UnloadGame(void)
{ {
UnloadMusicStream(soundtrack); UnloadMusicStream(soundtrack);
UnloadSound(fading);
UnloadSound(losing);
} }
// Update and Draw (one frame) // Update and Draw (one frame)
......
No preview for this file type
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