Commit ed9c6bb2 authored by DIDON Maya's avatar DIDON Maya

Ajout de musique de fond

parent 013caf42
...@@ -6,4 +6,5 @@ Les améliorations majeures proposées sont : ...@@ -6,4 +6,5 @@ Les améliorations majeures proposées sont :
* coloration des blocs * coloration des blocs
* ajout d'une musique de fond * ajout d'une musique de fond
* ajout de bruitages * ajout de bruitages
* possibilité de gagner un bonus qui met le jeu en pause 5 secondes * possibilité de gagner un bonus qui met le jeu en pause 5 secondes
\ No newline at end of file * ajout d'une fonctionnalité score ainsi que l'affichage du meilleur score enregistré
\ No newline at end of file
9 63443
\ No newline at end of file \ No newline at end of file
...@@ -110,6 +110,9 @@ static unsigned int ReadHighScore(); ...@@ -110,6 +110,9 @@ static unsigned int ReadHighScore();
// High score variable // High score variable
static int highScore = 0; static int highScore = 0;
// Music variables
Music soundtrack;
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Program main entry point // Program main entry point
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
...@@ -119,6 +122,11 @@ int main(void) ...@@ -119,6 +122,11 @@ int main(void)
//--------------------------------------------------------- //---------------------------------------------------------
InitWindow(screenWidth, screenHeight, "tetris - revamped"); InitWindow(screenWidth, screenHeight, "tetris - revamped");
InitAudioDevice();
char *filename = "tetris-soundtrack.mp3";
soundtrack = LoadMusicStream(filename);
PlayMusicStream(soundtrack);
InitGame(); InitGame();
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
...@@ -133,12 +141,14 @@ int main(void) ...@@ -133,12 +141,14 @@ int main(void)
// Update and Draw // Update and Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateDrawFrame(); UpdateDrawFrame();
UpdateMusicStream(soundtrack);
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
#endif #endif
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadGame(); // Unload loaded data (textures, sounds, models...) UnloadGame(); // Unload loaded data (textures, sounds, models...)
CloseAudioDevice();
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
...@@ -318,17 +328,6 @@ void UpdateGame(void) ...@@ -318,17 +328,6 @@ void UpdateGame(void)
} }
} }
// Reads high score in text document
static unsigned int ReadHighScore(){
char *filename = "high-score.txt";
FILE* dataFile;
dataFile = fopen(filename,"r");
unsigned int highScore;
fscanf(dataFile,"%u", &highScore);
fclose(dataFile);
return(highScore);
}
// Draw game (one frame) // Draw game (one frame)
void DrawGame(void) void DrawGame(void)
{ {
...@@ -433,7 +432,7 @@ void DrawGame(void) ...@@ -433,7 +432,7 @@ void DrawGame(void)
// Unload game variables // Unload game variables
void UnloadGame(void) void UnloadGame(void)
{ {
// TODO: Unload all dynamic loaded data (textures, sounds, models...) UnloadMusicStream(soundtrack);
} }
// Update and Draw (one frame) // Update and Draw (one frame)
...@@ -829,3 +828,14 @@ static int DeleteCompleteLines() ...@@ -829,3 +828,14 @@ static int DeleteCompleteLines()
} }
return(nbDel); return(nbDel);
} }
// Reads high score in text document
static unsigned int ReadHighScore(){
char *filename = "high-score.txt";
FILE* dataFile;
dataFile = fopen(filename,"r");
unsigned int highScore;
fscanf(dataFile,"%u", &highScore);
fclose(dataFile);
return(highScore);
}
\ No newline at end of file
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