James Heavey / Mbed 2 deprecated EL17JH

Dependencies:   mbed

Revision:
39:a9bb03bef107
Parent:
37:dd1538ae6534
Child:
40:ac53905346fb
--- a/BreakoutEngine/BreakoutEngine.cpp	Thu Apr 25 21:05:18 2019 +0000
+++ b/BreakoutEngine/BreakoutEngine.cpp	Thu Apr 25 21:08:34 2019 +0000
@@ -138,8 +138,8 @@
     
     //print_scores(lcd);
     
-    for (it = listofBricks.begin(); it != listofBricks.end(); ++it){
-        it->draw(lcd);
+    for (it_R = listofBricks.begin(); it_R != listofBricks.end(); ++it_R){
+        it_R->draw(lcd);
     }
     for (it_L = listofLasers.begin(); it_L != listofLasers.end(); ++it_L){
         it_L->draw(lcd);
@@ -306,23 +306,23 @@
     Vector2D ball_pos = _ball.get_pos();
     Vector2D ball_velocity = _ball.get_velocity();
     
-    for (it = listofBricks.begin(); it != listofBricks.end(); ++it){
+    for (it_R = listofBricks.begin(); it_R != listofBricks.end(); ++it_R){
         if (
-            (ball_pos.x >= it -> get_x()) && //left
-            (ball_pos.x <= it -> get_x() + BRICK_WIDTH) && //right
-            (ball_pos.y >= it -> get_y()) && //bottom
-            (ball_pos.y <= it -> get_y() + BRICK_HEIGHT)  //top
+            (ball_pos.x >= it_R -> get_x()) && //left
+            (ball_pos.x <= it_R -> get_x() + BRICK_WIDTH) && //right
+            (ball_pos.y >= it_R -> get_y()) && //bottom
+            (ball_pos.y <= it_R -> get_y() + BRICK_HEIGHT)  //top
         ) {    // edit this so that if it hits the middle, reflect, else change angle depending on how far off centre (add angle to ball)
             // if it has, fix position and reflect x velocity  
-            ball_pos.y = it -> get_y() + BRICK_HEIGHT;
+            ball_pos.y = it_R -> get_y() + BRICK_HEIGHT;
             ball_velocity.y = -ball_velocity.y;
             // audio feedback
             pad.tone(1000.0,0.1);
-            it -> hit();
-            it -> hit();
+            it_R -> hit();
+            it_R -> hit();
             //delete _brick11;
-            it -> set_posx(-100);
-            it -> set_posy(-100);
+            it_R -> set_posx(-100);
+            it_R -> set_posy(-100);
             one_less();
         }
     }
@@ -336,20 +336,20 @@
     // read current ball attributes
     // check p1 first
     for (it_L = listofLasers.begin(); it_L != listofLasers.end(); ++it_L){
-        for (it = listofBricks.begin(); it != listofBricks.end(); ++it){
+        for (it_R = listofBricks.begin(); it_R != listofBricks.end(); ++it_R){
             if (
-                (it_L -> get_x() >= it -> get_x()) && //left
-                (it_L -> get_x() <= it -> get_x() + BRICK_WIDTH) && //right
-                (it_L -> get_y() >= it -> get_y()) && //bottom
-                (it_L -> get_y()<= it -> get_y() + BRICK_HEIGHT)  //top
+                (it_L -> get_x() >= it_R -> get_x()) && //left
+                (it_L -> get_x() <= it_R -> get_x() + BRICK_WIDTH) && //right
+                (it_L -> get_y() >= it_R -> get_y()) && //bottom
+                (it_L -> get_y()<= it_R -> get_y() + BRICK_HEIGHT)  //top
             ) {    // edit this so that if it hits the middle, reflect, else change angle depending on how far off centre (add angle to ball)
                 // if it has, fix position and reflect x velocity  
                 it_L -> set_posx(-10);
                 // audio feedback
                 pad.tone(1000.0,0.1);
-                if(it->hit() == true) {
-                    it -> set_posx(-100);
-                    it -> set_posy(-100);
+                if(it_R->hit() == true) {
+                    it_R -> set_posx(-100);
+                    it_R -> set_posy(-100);
                     one_less();
                 }
             }