Thomas Davies / Mbed 2 deprecated LetTheBallDrop

Dependencies:   N5110 mbed PowerControl

Revision:
10:d8ef8633bd98
Parent:
9:c20f11f9b310
Child:
11:c6c88617f7e7
--- a/GameScreen.cpp	Mon Apr 27 14:24:59 2015 +0000
+++ b/GameScreen.cpp	Mon Apr 27 21:10:23 2015 +0000
@@ -139,7 +139,7 @@
         else
         {
             allPlatforms[n]->y =  maxY_ - platThickness_ + 1; //send back to bottom.
-            //allPlatforms[n]->x = rand() % (maxX_-platGapSize_ + 1) - 1; //select a new random position of gap!
+            allPlatforms[n]->x = rand() % (maxX_-platGapSize_ + 1) - 1; //select a new random position of gap!
             
         }
     }
@@ -147,14 +147,16 @@
 
 Platform GameScreen::nextClosestPlatform(int y)
 {
-    int closestY = 15;
+    Serial serial(USBTX,USBRX);
+    int closestY = 100;
     Platform closestPlatform;
     
     for (int i = 0; i < numPlatforms_; i++)
     {
-        if ((allPlatforms[i]->y - y) < closestY && (allPlatforms[i]->y - y) >= -1)
+        
+        if (((allPlatforms[i]->y - y) < closestY) && ((allPlatforms[i]->y - y) >  -1))
         {
-            closestY = allPlatforms[i]->y;
+            closestY = allPlatforms[i]->y-y;
             closestPlatform = *allPlatforms[i];            
         }
     }