Commit e2285cd3 authored by Benjamin LEROUX's avatar Benjamin LEROUX

gestion highscore

parent 15e6d0a8
...@@ -65,6 +65,7 @@ static Food goldenFruit = {0}; ...@@ -65,6 +65,7 @@ static Food goldenFruit = {0};
static Food deadFruit = {0}; static Food deadFruit = {0};
static Rectangle recTab[NUMBEROFWALL]; static Rectangle recTab[NUMBEROFWALL];
static int highscore;
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Module Functions Declaration (local) // Module Functions Declaration (local)
...@@ -195,6 +196,8 @@ void InitGame(void) ...@@ -195,6 +196,8 @@ void InitGame(void)
recTab[7].y=screenHeight-(offset.y/2)-(3*SQUARE_SIZE); recTab[7].y=screenHeight-(offset.y/2)-(3*SQUARE_SIZE);
recTab[7].width=(SQUARE_SIZE*3)-0.1; recTab[7].width=(SQUARE_SIZE*3)-0.1;
recTab[7].height=(SQUARE_SIZE)-0.1; recTab[7].height=(SQUARE_SIZE)-0.1;
highscore=LoadStorageValue(0);
} }
void drawWalls(){ void drawWalls(){
...@@ -423,6 +426,12 @@ void DrawGame(void) ...@@ -423,6 +426,12 @@ void DrawGame(void)
DrawText("PRESS [ENTER] TO PLAY AGAIN", screenWidth/2 - MeasureText("PRESS [ENTER] TO PLAY AGAIN", 40)/2, screenHeight - 200, 40, BLACK); DrawText("PRESS [ENTER] TO PLAY AGAIN", screenWidth/2 - MeasureText("PRESS [ENTER] TO PLAY AGAIN", 40)/2, screenHeight - 200, 40, BLACK);
DrawText(TextFormat("TIME: %.02f", (float)framesCounter/60), screenWidth/2 - MeasureText("TIME: 00.00", 60)/2, screenHeight/2 - 120, 60, BLUE); DrawText(TextFormat("TIME: %.02f", (float)framesCounter/60), screenWidth/2 - MeasureText("TIME: 00.00", 60)/2, screenHeight/2 - 120, 60, BLUE);
DrawText(TextFormat("SCORE: %04i",snake[0].score ), screenWidth/2 - MeasureText("SCORE: 0000", 60)/2, screenHeight/2 - 180, 60, BLUE); DrawText(TextFormat("SCORE: %04i",snake[0].score ), screenWidth/2 - MeasureText("SCORE: 0000", 60)/2, screenHeight/2 - 180, 60, BLUE);
if(highscore<snake[0].score){
SaveStorageValue(0,snake[0].score);
highscore=LoadStorageValue(0);
}
DrawText(TextFormat("HIGHSCORE: %04i",highscore ), screenWidth/2 - MeasureText("HIGHSCORE: 0000", 60)/2, screenHeight - 100, 60, RED);
} }
EndDrawing(); EndDrawing();
} }
......
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