ELEC2645 (2018/19) / Mbed 2 deprecated 2645_Project_SiutingWong201186503

Dependencies:   mbed

Revision:
12:660458c41c8e
Parent:
9:f88f3f50bbee
Child:
13:c3c58d50a571
diff -r 4723e7f3f1d2 -r 660458c41c8e Engine/Engine.cpp
--- a/Engine/Engine.cpp	Thu May 09 03:49:59 2019 +0000
+++ b/Engine/Engine.cpp	Thu May 09 04:26:16 2019 +0000
@@ -118,19 +118,19 @@
     int w4_height = _w4.get_height();
     
     if ((
-         (avenger_pos.y + 4 >= 0) && (avenger_pos.y + 1 <= w0_height) && //bottom
+         (avenger_pos.y + 5 >= 0) && (avenger_pos.y + 1 <= w0_height) && //bottom
          (avenger_pos.x + 10 >= _w0.get_x()) && (avenger_pos.x + 10 <= _w0.get_x() + 1)
         ) || (
-         (avenger_pos.y + 4 >= 0) && (avenger_pos.y + 1 <= w1_height) && //bottom
+         (avenger_pos.y + 5 >= 0) && (avenger_pos.y + 1 <= w1_height) && //bottom
          (avenger_pos.x + 10 >= _w1.get_x()) && (avenger_pos.x + 10 <= _w1.get_x() + 1)
         ) || (
-         (avenger_pos.y + 4 >= 0) && (avenger_pos.y + 1 <= w2_height) && //bottom
+         (avenger_pos.y + 5 >= 0) && (avenger_pos.y + 1 <= w2_height) && //bottom
          (avenger_pos.x + 10 >= _w2.get_x()) && (avenger_pos.x + 10 <= _w2.get_x() + 1)
         ) || (
-         (avenger_pos.y + 4 >= 0) && (avenger_pos.y + 1 <= w3_height) && //bottom
+         (avenger_pos.y + 5 >= 0) && (avenger_pos.y + 1 <= w3_height) && //bottom
          (avenger_pos.x + 10 >= _w3.get_x()) && (avenger_pos.x + 10 <= _w3.get_x() + 1)
         ) || (
-         (avenger_pos.y + 4 >= 0) && (avenger_pos.y + 1 <= w4_height) && //bottom
+         (avenger_pos.y + 5 >= 0) && (avenger_pos.y + 1 <= w4_height) && //bottom
          (avenger_pos.x + 10 >= _w4.get_x()) && (avenger_pos.x + 10 <= _w4.get_x() + 1)
         )
        ) {
@@ -148,19 +148,19 @@
     }
     
     if ((
-         (avenger_pos.y + 4 >= _wall_gap + w0_height) && (avenger_pos.y + 1 <= HEIGHT) && //bottom
+         (avenger_pos.y + 5 >= _wall_gap + w0_height) && (avenger_pos.y + 1 <= HEIGHT) && //bottom
          (avenger_pos.x + 10 >= _w0.get_x()) && (avenger_pos.x + 10 <= _w0.get_x() + 1)
         ) || (
-         (avenger_pos.y + 4 >= _wall_gap + w1_height) && (avenger_pos.y + 1 <= HEIGHT) && //bottom
+         (avenger_pos.y + 5 >= _wall_gap + w1_height) && (avenger_pos.y + 1 <= HEIGHT) && //bottom
          (avenger_pos.x + 10 >= _w1.get_x()) && (avenger_pos.x + 10 <= _w1.get_x() + 1)
         ) || (
-         (avenger_pos.y + 4 >= _wall_gap + w2_height) && (avenger_pos.y + 1 <= HEIGHT) && //bottom
+         (avenger_pos.y + 5 >= _wall_gap + w2_height) && (avenger_pos.y + 1 <= HEIGHT) && //bottom
          (avenger_pos.x + 10 >= _w2.get_x()) && (avenger_pos.x + 10 <= _w2.get_x() + 1)
         ) || (
-         (avenger_pos.y + 4 >= _wall_gap + w3_height) && (avenger_pos.y + 1 <= HEIGHT) && //bottom
+         (avenger_pos.y + 5 >= _wall_gap + w3_height) && (avenger_pos.y + 1 <= HEIGHT) && //bottom
          (avenger_pos.x + 10 >= _w3.get_x()) && (avenger_pos.x + 10 <= _w3.get_x() + 1)
         ) || (
-         (avenger_pos.y + 4 >= _wall_gap + w4_height) && (avenger_pos.y + 1 <= HEIGHT) && //bottom
+         (avenger_pos.y + 5 >= _wall_gap + w4_height) && (avenger_pos.y + 1 <= HEIGHT) && //bottom
          (avenger_pos.x + 10 >= _w4.get_x()) && (avenger_pos.x + 10 <= _w4.get_x() + 1)
         )
        ) {
@@ -245,7 +245,7 @@
 
     // see if ball has hit the paddle by checking for overlaps
     if (
-        (avenger_pos.y + 4 >= stone_pos.y - _stone_size) && (avenger_pos.y + 1 <= stone_pos.y + _stone_size)
+        (avenger_pos.y + 4 >= stone_pos.y - _stone_size) && (avenger_pos.y + 2 <= stone_pos.y + _stone_size)
         && //bottom
         (avenger_pos.x + 10 >= stone_pos.x) && (avenger_pos.x + 10 <= stone_pos.x + 2)  //right
     ) {
@@ -266,7 +266,7 @@
     // print to LCD i
     char buffer1[14];
     sprintf(buffer1,"%2d",avenger_score);
-    lcd.printString(buffer1,10,1);  // font is 8 wide, so leave 4 pixel gape from middle assuming two digits
+    lcd.printString(buffer1,1,0);  // font is 8 wide, so leave 4 pixel gape from middle assuming two digits
 }
 
 int Engine::get_score() {