James Heavey / Mbed 2 deprecated EL17JH

Dependencies:   mbed

Revision:
41:fe383cbb51b2
Parent:
40:ac53905346fb
Child:
42:347c20a16ee6
--- a/BreakoutEngine/BreakoutEngine.cpp	Fri Apr 26 07:07:42 2019 +0000
+++ b/BreakoutEngine/BreakoutEngine.cpp	Fri Apr 26 08:11:02 2019 +0000
@@ -166,6 +166,7 @@
     check_paddle_collisions(pad);
     check_brick_collisions(pad);
     check_laser_collisions(pad);
+    check_laser_ceiling_collision();
     
     
 }
@@ -252,6 +253,18 @@
     
 }
 
+void BreakoutEngine::check_laser_ceiling_collision()
+{   
+    for (it_L = listofLasers.begin(); it_L != listofLasers.end(); ++it_L){
+        if (
+            (it_L -> get_y() <= GAP_TOP - 1)
+        ) {    // 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);
+        }
+    }
+}
+
 void BreakoutEngine::check_paddle_collisions(Gamepad &pad)
 {
     // read current ball attributes