James Cummins / Mbed 2 deprecated el17jnc

Dependencies:   mbed

Revision:
32:eff573ad8e42
Parent:
31:c95f1b1d6423
Child:
33:c2dbad3dd805
--- a/main.cpp	Sat Apr 27 18:57:06 2019 +0000
+++ b/main.cpp	Sun Apr 28 10:20:52 2019 +0000
@@ -150,12 +150,12 @@
     classic.init(ball, map);
     bool collision = false;
     while(!(collision)){
-        if(classic.finished()){ 
+        if(classic.finished()){         //check if the game has been completed
             classic.mode_complete(lcd, gamepad, fps);
             break;
         }
-        if(map.check_wall_collision(gamepad, ball)){
-            collision = classic.mode_failed(lcd, gamepad, ball, map);
+        if(map.check_wall_collision(gamepad, ball)){    //end the game if collision with wall
+            collision = classic.mode_failed(lcd, gamepad, ball, map);   //gives the option to restart the game (and stay in while loop) or quit
             if(!(collision)){ classic.init(ball, map); }
         }
         classic.classic_update(ball, accelerometer, map);
@@ -163,11 +163,11 @@
         classic.classic_draw(lcd, map, ball);
         lcd.refresh();
         wait(1/fps);
-        if(gamepad.check_event(gamepad.BACK_PRESSED)){ 
+        if(gamepad.check_event(gamepad.BACK_PRESSED)){              //pause menu
             PauseOption choice = pause.pause_menu(gamepad, lcd, fps);
-            if(choice == RESUME){}
-            if(choice == RESTART){ classic.init(ball, map); }
-            if(choice == QUIT){ break; }
+            if(choice == RESUME){}                                      //the different options must be processed
+            if(choice == RESTART){ classic.init(ball, map); }           //in main.cpp as they have different 
+            if(choice == QUIT){ break; }                                //return types so can't be passed into main
             if(choice == HELP){ pause.classic_help(gamepad, lcd); }
         }
     }
@@ -184,12 +184,14 @@
         lcd.clear();
         brick.brickbreaker_draw(lcd, ball);
         lcd.refresh();
+        brick.time_warning(gamepad, i, fps);
         wait_ms(1000/fps);
         if(gamepad.check_event(gamepad.BACK_PRESSED)){
             PauseOption choice = pause.pause_menu(gamepad, lcd, fps);
             i = pause.brickbreaker_action(choice, gamepad, lcd, i, fps);  //returns which frame to jump to
         }
     }
+    brick.end(gamepad, lcd);
     brick.write_high_scores();
 }