Commit b0272bc9 authored by DIDON Maya's avatar DIDON Maya

Ajout d'effets sonores

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