Commit 96275e65 authored by DIDON Maya's avatar DIDON Maya

Ajout d'une grille de couleur

parent b0272bc9
63443
\ No newline at end of file
1473379
\ No newline at end of file
......@@ -106,13 +106,13 @@ static void CheckDetection();
static void CheckCompletion();
static int DeleteCompleteLines();
static unsigned int ReadHighScore();
static Color GiveLinesColors(int);
// High score variable
static int highScore = 0;
// Music variables
// Music and sound variables
Music soundtrack;
Sound losing;
Sound fading;
//------------------------------------------------------------------------------------
......@@ -128,10 +128,8 @@ int main(void)
InitAudioDevice();
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();
......@@ -329,12 +327,10 @@ void UpdateGame(void)
else
{
StopMusicStream(soundtrack);
PlaySound(losing);
if (IsKeyPressed(KEY_ENTER))
{
InitGame();
gameOver = false;
StopSound(losing);
PlayMusicStream(soundtrack);
}
}
......@@ -373,7 +369,7 @@ void DrawGame(void)
}
else if (grid[i][j] == FULL)
{
DrawRectangle(offset.x, offset.y, SQUARE_SIZE, SQUARE_SIZE, GRAY);
DrawRectangle(offset.x, offset.y, SQUARE_SIZE, SQUARE_SIZE, GiveLinesColors(j));
offset.x += SQUARE_SIZE;
}
else if (grid[i][j] == MOVING)
......@@ -446,7 +442,6 @@ void UnloadGame(void)
{
UnloadMusicStream(soundtrack);
UnloadSound(fading);
UnloadSound(losing);
}
// Update and Draw (one frame)
......@@ -852,4 +847,30 @@ static unsigned int ReadHighScore(){
fscanf(dataFile,"%u", &highScore);
fclose(dataFile);
return(highScore);
}
// Allocates colors to differents lines
static Color GiveLinesColors(int i){
switch(i){
case 18: return(PINK); break;
case 17: return(RED); break;
case 16: return(ORANGE); break;
case 15: return(GOLD); break;
case 14: return(YELLOW); break;
case 13: return(GREEN); break;
case 12: return(LIME); break;
case 11: return(DARKGREEN); break;
case 10: return(DARKBLUE); break;
case 9: return(BLUE); break;
case 8: return(SKYBLUE); break;
case 7: return(PURPLE); break;
case 6: return(VIOLET); break;
case 5: return(DARKPURPLE); break;
case 4: return(BROWN); break;
case 3: return(BROWN); break;
case 2: return(DARKBROWN); break;
case 1: return(BLACK); break;
case 0: return(BLACK); break;
default: return(WHITE);
}
}
\ 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