Simple fish eat program

Dependencies:   mbed mbed-rtos N5110 ShiftReg Tone

Revision:
11:7c1e2a9303d3
Parent:
10:e221bd1ce3ec
Child:
12:20ac766b3175
diff -r e221bd1ce3ec -r 7c1e2a9303d3 classes/FishEngine.cpp
--- a/classes/FishEngine.cpp	Tue Apr 20 15:35:00 2021 +0000
+++ b/classes/FishEngine.cpp	Wed Apr 21 11:08:02 2021 +0000
@@ -8,6 +8,7 @@
 Game game;
 Settings settings;
 Graphics graphics;
+HighScore highscore;
 
 int ButtonA;
 int ButtonB; 
@@ -36,8 +37,25 @@
     do{
         DIRECTION direction = {joystick.get_direction()};
         game.gamePlay(lcd, direction);
+        playerScore = game.Score(lcd);
         
     }while(game.Lives() != 0);
+    
+    fileValue = highscore.read_File();
+    
+    if(playerScore > fileValue){
+        highscore.write_File(playerScore);
+        lcd.clear();
+        lcd.printString("New Score", 5, 1);
+        lcd.refresh();
+        wait_ms(1000);    
+    }
+}
+
+void FishEngine::highScore(N5110 &lcd){
+    do{
+        highscore.display_File(lcd);   
+    }while(settings.buttonB_state(ButtonB) == false);
 }
 
 void FishEngine::Instructions(N5110 &lcd){
@@ -145,6 +163,8 @@
             //case for HighScore
             case 1:
                 if(settings.buttonA_state(ButtonA)){
+                    graphics.screenFlash(lcd);
+                    highScore(lcd);
                 }
                 switch(direction) {
                     case UP: