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

Dependencies:   mbed

Revision:
8:97576c8761a8
Parent:
7:193c0fd7afdd
Child:
14:13e82f720bea
--- a/Wall/Wall.cpp	Thu May 09 01:27:58 2019 +0000
+++ b/Wall/Wall.cpp	Thu May 09 02:17:47 2019 +0000
@@ -13,9 +13,9 @@
 void Wall::init(int x,int gap,int width,int speed) {
     
     _x = x;  // x value on screen is fixed
-    int uncertainty = rand() % 39;
+    _gap = gap;
+    int uncertainty = rand() % (47 - _gap);
     _height = uncertainty;  // y depends on height of screen and height of paddle
-    _gap = gap;
     _width = width;
     _speed = speed;
 }
@@ -36,7 +36,7 @@
 
 void Wall::reset() {
     _x = 149;
-    int uncertainty = rand() % 39;
+    int uncertainty = rand() % (47 - _gap);
     _height = uncertainty;
 }