Dependencies:   mbed

Revision:
8:10eb578dd754
Parent:
7:35465b3bf586
Child:
13:fd290d2fd917
--- a/Ball/Ball.cpp	Mon May 18 14:28:05 2020 +0000
+++ b/Ball/Ball.cpp	Mon May 18 15:08:54 2020 +0000
@@ -28,43 +28,55 @@
     lcd.drawSprite(ball_x_pos,ball_y_pos,2,2,(int *)ball);
 }
 
-void Ball::update(Direction d)
+void Ball::update(Direction d,Gamepad &pad)
 {
     
     if(d != CENTRE){
         
-    if (d == S && ball_y_pos < 46){
+    if (d == S && ball_y_pos < 47){
+        if(pad.A_held() == true){ball_y_pos++;}
         ball_y_pos++;
         }
     
     if (d == N && ball_y_pos > 1){
+        if(pad.A_held() == true){ball_y_pos--;}
         ball_y_pos--;
         }
         
     if (d == E && ball_x_pos < 83){
+        if(pad.A_held() == true){ball_x_pos++;}
         ball_x_pos++;
         }
     
     if (d == W && ball_x_pos > 0){
+        if(pad.A_held() == true){ball_x_pos--;}
         ball_x_pos--;
         }
         
-    if (d == SE && ball_y_pos < 46 && ball_x_pos < 83){
+    if (d == SE && ball_y_pos < 47 && ball_x_pos < 83){
+        if(pad.A_held() == true){ball_y_pos++;
+        ball_x_pos++;}
         ball_x_pos++;
         ball_y_pos++;
         }
         
     if (d == NE && ball_y_pos > 1 && ball_x_pos < 83){
+        if(pad.A_held() == true){ball_y_pos--;
+        ball_x_pos++;}
         ball_x_pos++;
         ball_y_pos--;
         };
         
     if (d == NW && ball_x_pos > 0 && ball_y_pos > 1){
+        if(pad.A_held() == true){ball_y_pos--;
+        ball_x_pos--;}
         ball_x_pos--;
         ball_y_pos--;
         }
         
-    if (d == SW && ball_x_pos > 0 && ball_y_pos < 46){
+    if (d == SW && ball_x_pos > 0 && ball_y_pos < 47){
+        if(pad.A_held() == true){ball_y_pos++;
+        ball_x_pos--;}
         ball_x_pos--;
         ball_y_pos++;
         }