ELEC2645 (2016/17) / Mbed 2 deprecated Bomb_WeixiTao_el16wt

Dependencies:   mbed

Revision:
2:23b20cbd3330
Parent:
1:83459533ff72
diff -r 83459533ff72 -r 23b20cbd3330 hole.cpp
--- a/hole.cpp	Mon May 01 15:20:26 2017 +0000
+++ b/hole.cpp	Mon May 01 16:37:53 2017 +0000
@@ -5,23 +5,32 @@
 
 void hole::hole_place()
 {
-
+    int four = ((rand())%4)+1;
+    switch(four){
+     case 1:   
     //top left
     holeX = rand()%27+5;
     holeY = rand()%14+5;
-
+    break;
+    
+    case 2:
     // top right
-    holeX1 = rand()%27+47;
-    holeY1 = rand()%14+5;
+    holeX = rand()%27+47;
+    holeY = rand()%14+5;
+    break;
     
+    case 3:
     // button left
-    holeX2 = rand()%27+5;
-    holeY2 = rand()%14+29;
+    holeX = rand()%27+5;
+    holeY = rand()%14+29;
+    break;
     
+    case 4:
     //button right
-    holeX3 = rand()%27+47;
-    holeY3 = rand()%14+29;        
-}
+    holeX = rand()%27+47;
+    holeY = rand()%14+29;
+    break;        
+}}
 
 void hole::hole_show()
 {
@@ -43,7 +52,7 @@
     
     bool check = false;
     
-    if(x+41-3 <=holeX && holeX <=41+x+1+3 && y+24-3 <=holeY && y+24+6 >=holeY)
+    if(x+41-3 <=holeX && holeX <=41+x+1+3 && y+24-3 <=holeY && y+24+6 >=holeY )
     {
         printf("Check");
         check = true;