James Heavey / Mbed 2 deprecated EL17JH

Dependencies:   mbed

Revision:
60:63d69184ec0a
Parent:
57:d498dd835cfc
Child:
61:0a8b3ffedc40
--- a/BreakoutEngine/BreakoutEngine.cpp	Sat May 04 19:09:10 2019 +0000
+++ b/BreakoutEngine/BreakoutEngine.cpp	Sat May 04 19:57:31 2019 +0000
@@ -14,9 +14,11 @@
 
 void BreakoutEngine::init(int paddle_width,int paddle_height,int ball_size,int speed, int prev_score)
 {
+    /*
     printf("init started /n");
     listofBricks.clear();
     listofLasers.clear();
+    */
     
     // initialise the game parameters
     _paddle_width = paddle_width;
@@ -82,9 +84,31 @@
     listofLasers.push_back(_laser1);
     listofLasers.push_back(_laser2);
     listofLasers.push_back(_laser3);
-    printf("init ended /n");
+    //printf("init ended /n");
 }
 
+void BreakoutEngine::moveback_bricks()  // rename to reset add in ball reset and use to increase the number of balls each time
+{    
+    reset_num_left();
+    
+    int pointer = 0;
+    for (it_R = listofBricks.begin(); it_R != listofBricks.end(); ++it_R){
+        if (pointer <= 5) {   
+            it_R -> set_posx((pointer * 13) + 3);
+        }
+        else if (pointer <= 11) {   
+            it_R -> set_posx(((pointer-6) * 13) + 3);
+        }
+        else if (pointer <= 17) {   
+            it_R -> set_posx(((pointer-12) * 13) + 3);
+        }
+        
+        it_R -> reset_lives();   
+        pointer ++;
+    }
+}
+    
+
 void BreakoutEngine::read_input(Gamepad &pad, bool x)
 {
     _d = pad.get_direction();
@@ -353,7 +377,6 @@
             it_R -> hit();
             //delete _brick11;
             it_R -> set_posx(-100);
-            it_R -> set_posy(-100);
             one_less();
         }
     }
@@ -380,7 +403,6 @@
                 pad.tone(1000.0,0.1);
                 if(it_R->hit() == true) {
                     it_R -> set_posx(-100);
-                    it_R -> set_posy(-100);
                     one_less();
                 }
             }
@@ -427,4 +449,7 @@
 }
 void BreakoutEngine::one_less() {
     _number_left -= 1;
+}
+void BreakoutEngine::reset_num_left() {
+    _number_left = 18;
 }
\ No newline at end of file