Alvaro Cassinelli / Mbed 2 deprecated skinGames_forktest

Dependencies:   mbed

Fork of scoreLight_Advanced by Alvaro Cassinelli

Revision:
32:52273c3291fe
Parent:
31:5f039cbddee8
Child:
33:43e8bc451ef0
diff -r 5f039cbddee8 -r 52273c3291fe blobConfig.cpp
--- a/blobConfig.cpp	Sun Sep 23 10:11:43 2012 +0000
+++ b/blobConfig.cpp	Mon Oct 29 14:28:47 2012 +0000
@@ -51,7 +51,8 @@
         case FOLLOWING_SPOTS:
          // computeBoundingBox();
             clearConfig();
-            for (i=0; i<numblobs ; i++) addOneRigidLoopFollowing(vector2Df(CENTER_AD_MIRROR_X+i*200, CENTER_AD_MIRROR_Y+i*200), vector2Df(20,0));
+            for (i=0; i<numblobs ; i++) addOneRigidLoopFollowing(vector2Df(CENTER_AD_MIRROR_X+i*200, CENTER_AD_MIRROR_Y+i*200), vector2Df(11,0));
+            
         break;
         case ONE_TRACKING_SPOT:
            clearConfig();
@@ -80,14 +81,23 @@
         break;
         case VERTICAL_PINBALL_GAME:
          clearConfig();
-         // (1) one (or two9 SPOT_TRACK_DOT to track the background - It will be the number 0 (and 1) in the config. 
+         // (1) one (or two) SPOT_TRACK or SPOT_TRACK_DOT to track the background - It will be the number 0 (and 1) in the config. 
           addOneRigidTrackingSpotDot(vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y+600), 
                                      vector2Df(0,0));
+         // addOneRigidTrackingSpot(vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y+600), 
+          //                           vector2Df(0,0));
          // (2) one bouncing spot with gravity:
          addOneRigidLoopBouncingGravity(vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y-600), 
                                  vector2Df(0,0));                      
 
         break; 
+        case RAIN_MODE:
+        clearConfig();
+         // Add bouncing spot with gravity:
+          for (i=0; i<numblobs ; i++) {
+          addOneRigidLoopBouncingGravity(vector2Df(CENTER_AD_MIRROR_X, 10), vector2Df(0,0));   
+         }       
+        break;
         case FISH_NET_GAME:
         clearConfig();
          // (1) one SPOT_TRACK_DOT to track the background - It will be the number 0  
@@ -195,11 +205,13 @@
 }
 void blobConfig::addOneRigidLoopBouncingGravity(vector2Df initpos, vector2Df initspeed) {
     rigidLoop* pBlob= new rigidLoop();
-    pBlob->createBlob(blobArray.size(), SPOT_BOUNCING,  initpos, initspeed);
+    pBlob->createBlob(blobArray.size(), SPOT_BOUNCING_FACTOR,  initpos, initspeed);
     // (We can use here methods of the child class, even if these are not declared virtual on the base class, because we are doing this BEFORE
     // adding this to the blobArray as a pointer). This is good to set parameters...
-    pBlob->gravity.set(0,2.0);  
+    pBlob->gravity.set(0,3.0);  
     pBlob->centerMass.dampMotion = 0.002;
+    pBlob->factorBouncingForce=0;//0.003; // this is because we will use a force on the central mass (not used in SPOT_BOUNCING_FACTOR)
+    pBlob->factorAbsorptionShock=0.8; // coef elastic bouncing
    
     // add this relaxing loop to the present config:
     blobArray.push_back(pBlob);
@@ -209,7 +221,7 @@
 }
 void blobConfig::addOneRigidLoopBouncing(vector2Df initpos, vector2Df initspeed) {
     rigidLoop* pBlob= new rigidLoop();
-    pBlob->createBlob(blobArray.size(), SPOT_BOUNCING, initpos, initspeed);
+    pBlob->createBlob(blobArray.size(), SPOT_BOUNCING_FACTOR, initpos, initspeed);
     // add this relaxing loop to the present config:
     blobArray.push_back(pBlob);
 
@@ -331,6 +343,14 @@
 void blobConfig::allSetColor(unsigned char c) {
     for (int i=0; i<blobArray.size(); i++) blobArray[i]->setColor(c);
  }
+ 
+ void blobConfig::allSetGreen(unsigned char c) {
+    for (int i=0; i<blobArray.size(); i++) blobArray[i]->setGreenColor(c);
+ }
+ 
+  void blobConfig::allSetBlue(unsigned char c) {
+    for (int i=0; i<blobArray.size(); i++) blobArray[i]->setBlueColor(c);
+ }
 
 void blobConfig::update() { // update dynamics of the blob configuration:
 int i;
@@ -371,6 +391,20 @@
             }
         }
         break;
+        case RAIN_MODE: // this is just spots with gravity that reapears in the top position when reaching the bottom:
+          // others are bouncing with gravity:
+        for (i=0; i<blobArray.size(); i++) {
+            if (blobArray[i]->standByMode==false) blobArray[i]->update();
+        }
+        // GAME CHECKS:
+         for (i=0; i<blobArray.size(); i++) {
+           if (blobArray[i]->getCenter().y>MAX_AD_MIRRORS-20) {
+           // Replace position of spot to the initial position:
+                blobArray[i]->explosion();
+                blobArray[i]->resetPositionSpeed();
+            }
+      }
+        break;
         case VERTICAL_PINBALL_GAME:
           // spot index 0 is a tracking spot, the background "anchor":
          if (blobArray[0]->standByMode==false) blobArray[0]->update();