Commit ed9c6bb2 authored by DIDON Maya's avatar DIDON Maya

Ajout de musique de fond

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