Kostadin Chakarov / Mbed 2 deprecated el17kec

Dependencies:   mbed

Revision:
9:f720f5d87420
Parent:
8:9b77eea95088
Child:
10:da5743dfb137
diff -r 9b77eea95088 -r f720f5d87420 main.cpp
--- a/main.cpp	Wed May 08 13:49:01 2019 +0000
+++ b/main.cpp	Wed May 08 23:09:43 2019 +0000
@@ -71,7 +71,7 @@
     lcd.printString("for Controls ",11,5);
     lcd.refresh();   
     
-    /** Flash the LEDs until start button is pressed */
+    /** Wait to move to next menu */
     while (pad.check_event(Gamepad::A_PRESSED) == false) 
     {
 
@@ -84,6 +84,7 @@
     lcd.printString("Press Start ",9,4);
     lcd.printString("to begin ",16,5);
     lcd.refresh();  
+    /** Flash LEDs until start button is pressed */
     while (pad.check_event(Gamepad::START_PRESSED) == false) 
     {
         for (int i = 1; i < 7; i++) 
@@ -101,6 +102,7 @@
     paddle.reset(); /** Reset paddle */
     ball.reset();   /** Reset ball */
     map.reset();    /** Reset map */
+    map.score = 0;  /** Reset score */
 }
 
 /** Checks if game is lost */
@@ -112,8 +114,11 @@
     {
         while (1) 
         {
-            /** Prints a simple 'lost' message and a restart prompt */
+            /** Prints a simple 'lost' message and score and asks if you want to restart */
             lcd.clear();
+            char finalscore[14];
+            sprintf(finalscore,"Score = %d",map.score);
+            lcd.printString(finalscore,0,0);
             lcd.printString("You Lost",17,2);
             lcd.printString("Press A",20,3);
             lcd.printString("to restart",12,4);
@@ -141,8 +146,11 @@
              /** We have cleared all levels */
              while (1) 
             {   
-                /** Prints a win message and asks if you want to restart */
+                /** Prints win message and score and asks if you want to restart */
                 lcd.clear();
+                char finalscore[14];
+                sprintf(finalscore,"Score = %d",map.score);
+                lcd.printString(finalscore,0,0);
                 lcd.printString("You WON!",17,2);
                 lcd.printString("Press A",20,3);
                 lcd.printString("to restart",12,4);