James Heavey / Mbed 2 deprecated EL17JH

Dependencies:   mbed

Revision:
48:966f2cf803ec
Parent:
47:1d1a827be81b
Child:
57:d498dd835cfc
--- a/BreakoutEngine/BreakoutEngine.cpp	Fri Apr 26 21:43:55 2019 +0000
+++ b/BreakoutEngine/BreakoutEngine.cpp	Fri Apr 26 21:57:09 2019 +0000
@@ -333,7 +333,14 @@
             (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_R -> get_y() + BRICK_HEIGHT;
+            if (ball_velocity.y < 0) 
+            {   
+                ball_pos.y = it_R -> get_y() + BRICK_HEIGHT;
+            }
+            else 
+            {
+                ball_pos.y = it_R -> get_y();
+            }
             ball_velocity.y = -ball_velocity.y;
             // audio feedback
             pad.tone(1000.0,0.1);