FINAL VERSION

Dependencies:   mbed

Revision:
112:26961473eae8
Parent:
111:4848c399fae0
Child:
113:d180342ac017
--- a/main.cpp	Wed May 08 02:50:07 2019 +0000
+++ b/main.cpp	Wed May 08 03:26:42 2019 +0000
@@ -400,7 +400,7 @@
     title_screen();
 }
 
-void victory_screen()
+void victory_screen() // victory screen when all bricks are destroyed
 {
     int bonus = NULL;
     
@@ -408,7 +408,7 @@
         bonus = breakout.get_score()/2 - ((breakout.get_score()/2) * number_of_frames)/720;
     }
     else {
-        bonus = 0; // else u get no bonus
+        bonus = 0; // else you get no bonus
     }
     
     if (compare_to_hi_score(bonus+breakout.get_score()) == true) {   // little hi-score sequence if current score is higher than prev
@@ -463,11 +463,11 @@
   
     char buffer2[14];
     sprintf(buffer2,"%2d",bonus);
-    lcd.printString(buffer2,WIDTH/2 + 10,3);
-    lcd.printString(" BONUS: ",2,3);
+    lcd.printString(buffer2,WIDTH/2 + 14,3);
+    lcd.printString("  BONUS: ",2,3);
     
     lcd.printString("   VICTORY! ",2,0);
-    lcd.printString(" CONT = START ",0,4);  // print score here
+    lcd.printString(" CONT = START ",0,4);  
     lcd.printString("  MENU = BACK ",0,5);
     lcd.refresh();
     pad.tone(2500.0,0.1);
@@ -492,14 +492,9 @@
 
         lcd.clear();
 
-        char buffer1[14];
-        sprintf(buffer1,"%2d",breakout.get_score());
         lcd.printString(buffer1,WIDTH/2 - 12,2);
-      
-        char buffer2[14];
-        sprintf(buffer2,"%2d",bonus);
-        lcd.printString(buffer2,WIDTH/2 + 10,3);
-        lcd.printString(" BONUS:",2,3);
+        lcd.printString(buffer2,WIDTH/2 + 14,3);
+        lcd.printString("  BONUS:",2,3);
         
         lcd.printString("   VICTORY! ",2,0);
         lcd.printString(" CONT = START ",0,4);  
@@ -514,13 +509,13 @@
 
         if (pad.check_event(Gamepad::START_PRESSED)) {
             breakout.set_prev_score(breakout.get_score() + bonus);
-            number_of_frames = 0;
+            number_of_frames = 0;  // reset the number of frames
             breakout.inc_mult();  // increment multiplier
             breakout.reset_game(); // return game to initial positions 
             main_game();
         } else if (pad.check_event(Gamepad::BACK_PRESSED)) {
             breakout.set_prev_score(0);   // resets prev score to 0
-            number_of_frames = 0;
+            number_of_frames = 0;  // reset the number of frames
             breakout.set_mult_zero(); // reset multiplier
             breakout.reset_game(); // return game to initial positions 
             title_screen();
@@ -528,7 +523,7 @@
     }
 }
 
-void flash_screen(N5110 &lcd)   // move to engine
+void flash_screen(N5110 &lcd)   // flash the screen when a life is lost
 {
     lcd.setBrightness(0);
     wait(0.1);
@@ -547,7 +542,7 @@
     lcd.setBrightness(1);
 }
 
-void countdown()
+void countdown()       // draw the countdown
 {
     lcd.setBrightness(1); // stops the game from dimming (bug)
     
@@ -574,7 +569,7 @@
     wait(1);     // wait 1 second
 }
 
-void save_hi_score(int hi_score)
+void save_hi_score(int hi_score)  // save score to SD card
 {
     serial.baud(115200);  // max speed
     FILE *fp; // file pointer
@@ -589,7 +584,7 @@
     }
 }
 
-int get_hi_score()
+int get_hi_score()  // retrieve score from SD card
 {
     serial.baud(115200); // max speed
     FILE *fp;
@@ -617,7 +612,7 @@
     }
 }
 
-void print_hi_score(int col,int row)
+void print_hi_score(int col,int row)  // print hi score to lcd at specified location
 {
     char buffer[14];  // creates buffer
     sprintf(buffer,"%2d",get_hi_score()); // puts hi-score in buffer