Alvaro Cassinelli
/
skinGames_II
save loops
Embed:
(wiki syntax)
Show/hide line numbers
blobConfig.cpp
00001 00002 #include "blobConfig.h" 00003 00004 blobConfig::blobConfig(): numBlobs(0) { 00005 //blobArray.clear();// there is no need to do this, the vector does not contains anything here. 00006 } 00007 00008 blobConfig::~blobConfig() { 00009 clearConfig(); 00010 } 00011 00012 // =========================================== STANDARD CONFIGURATIONS ============================================================================= 00013 00014 00015 00016 void blobConfig::clearConfig() { 00017 for (int i=0; i<blobArray.size(); i++) delete blobArray[i]; // we must delete the pointer created with new, so the memory for the object is liberated (calls its destructor) 00018 blobArray.clear(); 00019 numBlobs=0;// this is just equal to blobArray.size() 00020 } 00021 00022 void blobConfig::initConfig(configType cfType, int numblobs) { 00023 myConfigType=cfType; 00024 int i; 00025 switch(myConfigType) { 00026 case ONE_ELASTIC_FOLLOWING: 00027 // computeBoundingBox(); 00028 clearConfig(); 00029 addOneElasticContourFollowing(); 00030 break; 00031 case ONE_ELASTIC_MOUTH: 00032 // computeBoundingBox(); 00033 clearConfig(); 00034 addOneElasticLoopContractCentral(); 00035 break; 00036 case ONE_ELASTIC_MOUTH_SMALL: 00037 // computeBoundingBox(); 00038 clearConfig(); 00039 addOneElasticLoopContractCentralFast(); 00040 break; 00041 case BOUNCING_SPOTS: 00042 // computeBoundingBox(); 00043 clearConfig(); 00044 for (i=0; i<numblobs ; i++) addOneRigidLoopBouncing(); 00045 randomizeAllColors(); 00046 break; 00047 case LORENTZ_SPOTS: 00048 // computeBoundingBox(); 00049 clearConfig(); 00050 for (i=0; i<numblobs ; i++) addOneRigidLoopLorentz(); 00051 randomizeAllColors(); 00052 break; 00053 case FOLLOWING_SPOTS: 00054 // computeBoundingBox(); 00055 clearConfig(); 00056 for (i=0; i<numblobs ; i++) { 00057 addOneRigidLoopFollowing(vector2Df(CENTER_AD_MIRROR_X+i*200, CENTER_AD_MIRROR_Y+i*200), vector2Df(11,0)); 00058 } 00059 // randomize colors: 00060 randomizeAllColors(); 00061 break; 00062 case ONE_TRACKING_SPOT: 00063 clearConfig(); 00064 addOneRigidTrackingSpot(); 00065 break; 00066 case ONE_TRACKING_SPOT_DOT: 00067 clearConfig(); 00068 addOneRigidTrackingSpotDot(); 00069 break; 00070 case AIR_HOCKEY_GAME: 00071 // computeBoundingBox(); 00072 clearConfig(); 00073 for (i=0; i<numblobs ; i++) addOneRigidLoopAirHockey(); 00074 break; 00075 case CIRCULAR_PONG_GAME: 00076 // computeBoundingBox(); 00077 clearConfig(); 00078 // (1) One SPOT_TRACK to track the background. It will be the number 0 in the config. 00079 addOneRigidTrackingSpotDot(); 00080 // (2) Add bouncing spots: 00081 for (i=0; i<numblobs ; i++) { 00082 float anglaux=1.0*i/numblobs*2*PI; 00083 addOneRigidLoopBouncing(vector2Df(CENTER_AD_MIRROR_X+200*cos(anglaux), CENTER_AD_MIRROR_Y+200*sin(anglaux)), 00084 vector2Df(5*cos(anglaux),sin(anglaux))*10); 00085 } 00086 break; 00087 case VERTICAL_PINBALL_GAME: 00088 clearConfig(); 00089 // (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. 00090 addOneRigidTrackingSpotDot(vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y+600), 00091 vector2Df(0,0)); 00092 // addOneRigidTrackingSpot(vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y+600), 00093 // vector2Df(0,0)); 00094 // (2) one or more bouncing spots with gravity: 00095 for (i=0; i<numblobs ; i++) { 00096 addOneRigidLoopBouncingGravity(vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y-600), 00097 vector2Df(i*10-5,0)); 00098 } 00099 00100 break; 00101 case RAIN_MODE: 00102 clearConfig(); 00103 // Add bouncing spot with gravity: 00104 for (i=0; i<numblobs ; i++) { 00105 addOneRigidLoopBouncingGravity(vector2Df(CENTER_AD_MIRROR_X, 10), vector2Df(0,0)); 00106 } 00107 randomizeAllColors(); 00108 break; 00109 case FISH_NET_GAME: 00110 clearConfig(); 00111 // (1) one SPOT_TRACK_DOT to track the background - It will be the number 0 00112 addOneRigidTrackingSpotDot(vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), // CENTERED 00113 vector2Df(0,0)); 00114 // (2) Add bouncing spots without gravity: 00115 for (i=0; i<numblobs ; i++) { 00116 float anglaux=1.0*i/numblobs*2*PI; 00117 addOneRigidLoopBouncing(vector2Df(CENTER_AD_MIRROR_X+400*cos(anglaux), CENTER_AD_MIRROR_Y+400*sin(anglaux)), 00118 vector2Df(cos(anglaux),sin(anglaux))*10); 00119 } 00120 break; 00121 case PAC_MAN_GAME: 00122 clearConfig(); 00123 //(1) add one very slowly slidind-bouncing spot, the PACMAN (number 0 in the config): 00124 // addOneRigidLoopPacman(vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df(20,0)); 00125 00126 // note: the pacman behaviour is not so good... for the time being, let's just use a following spot: 00127 addOneRigidLoopFollowing(vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df(10,0)); 00128 // set the color to red+green: 00129 blobArray.back()->setColor(0x06); 00130 00131 00132 // (2) Add some initial SPOT_FOLLOWING or SPOT_GHOST spots (the ghosts): 00133 addOneRigidLoopGhost(vector2Df(CENTER_AD_MIRROR_X+500, CENTER_AD_MIRROR_Y-500), vector2Df(-5,0)); 00134 addOneRigidLoopGhost(vector2Df(CENTER_AD_MIRROR_X-500, CENTER_AD_MIRROR_Y-500), vector2Df(5,0)); 00135 00136 break; 00137 default: 00138 break; 00139 } 00140 00141 // make sure lockin red is ON (could be off if using blue for checking mirror delay...): 00142 IO.setLaserLockinPower(1); 00143 } 00144 00145 void blobConfig::printParameters() { 00146 for (int i=0; i<blobArray.size(); i++) { 00147 pc.printf("Blob n.%d\n", i); 00148 blobArray[i]->printParameters(); // a blob that is in stand-by mode may send data (good for testing with a fixed loop) 00149 } 00150 } 00151 00152 // ==================== Template spots from which to create multi-spot configurations: ===================== 00153 00154 void blobConfig::addOneElasticLoopRelax(vector2Df initpos, vector2Df initspeed) { 00155 elasticLoop* pBlob= new elasticLoop(); 00156 pBlob->createBlob(blobArray.size(), RELAX, initpos, initspeed); 00157 // add this relaxing loop to the present config: 00158 blobArray.push_back(pBlob); 00159 00160 // update auxiliary variable numBlobs (just for easy reference): 00161 numBlobs=blobArray.size(); 00162 00163 } 00164 00165 00166 void blobConfig::addOneElasticLoopContract(vector2Df initpos, vector2Df initspeed) { 00167 elasticLoop* pBlob= new elasticLoop(); 00168 pBlob->createBlob(blobArray.size(), CONTRACT, initpos, initspeed); 00169 // add this relaxing loop to the present config: 00170 blobArray.push_back(pBlob); 00171 00172 // update auxiliary variable numBlobs (just for easy reference): 00173 numBlobs=blobArray.size(); 00174 } 00175 00176 void blobConfig::addOneElasticLoopContractCentral(vector2Df initpos, vector2Df initspeed) { 00177 elasticLoop* pBlob= new elasticLoop(); 00178 pBlob->createBlob(blobArray.size(), CONTRACT_CENTRAL, initpos, initspeed); 00179 // add this relaxing loop to the present config: 00180 blobArray.push_back(pBlob); 00181 00182 // update auxiliary variable numBlobs (just for easy reference): 00183 numBlobs=blobArray.size(); 00184 } 00185 00186 void blobConfig::addOneElasticLoopContractCentralFast(vector2Df initpos, vector2Df initspeed) { 00187 elasticLoop* pBlob= new elasticLoop(); 00188 pBlob->createBlob(blobArray.size(), CONTRACT_CENTRAL_FAST, initpos, initspeed); 00189 // add this relaxing loop to the present config: 00190 blobArray.push_back(pBlob); 00191 00192 // update auxiliary variable numBlobs (just for easy reference): 00193 numBlobs=blobArray.size(); 00194 } 00195 00196 void blobConfig::addOneElasticContourFollowing(vector2Df initpos, vector2Df initspeed) { 00197 00198 elasticLoop* pBlob= new elasticLoop(); 00199 pBlob->createBlob(blobArray.size(), CONTOUR_FOLLOWING, initpos, initspeed); 00200 // add this relaxing loop to the present config: 00201 blobArray.push_back(pBlob); 00202 00203 // update auxiliary variable numBlobs (just for easy reference): 00204 numBlobs=blobArray.size(); 00205 } 00206 00207 00208 void blobConfig:: addOneElasticContourFollowingFAST(vector2Df initpos, vector2Df initspeed) { 00209 elasticLoop* pBlob= new elasticLoop(); 00210 pBlob->createBlob(blobArray.size(), CONTOUR_FOLLOWING_FAST, initpos, initspeed); 00211 // add this relaxing loop to the present config: 00212 blobArray.push_back(pBlob); 00213 00214 // update auxiliary variable numBlobs (just for easy reference): 00215 numBlobs=blobArray.size(); 00216 } 00217 00218 void blobConfig::addOneElasticBouncing(vector2Df initpos, vector2Df initspeed) { 00219 elasticLoop* pBlob= new elasticLoop(); 00220 pBlob->createBlob(blobArray.size(), BOUNCING, initpos, initspeed); 00221 // add this relaxing loop to the present config: 00222 blobArray.push_back(pBlob); 00223 00224 // update auxiliary variable numBlobs (just for easy reference): 00225 numBlobs=blobArray.size(); 00226 } 00227 void blobConfig::addOneRigidLoopBouncingGravity(vector2Df initpos, vector2Df initspeed) { 00228 rigidLoop* pBlob= new rigidLoop(); 00229 pBlob->createBlob(blobArray.size(), SPOT_BOUNCING_FACTOR, initpos, initspeed); 00230 // (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 00231 // adding this to the blobArray as a pointer). This is good to set parameters... 00232 pBlob->gravity.set(0,3.5); 00233 pBlob->centerMass.dampMotion = 0.002; 00234 pBlob->factorBouncingForce=0;//0.003; // this is because we will use a force on the central mass (not used in SPOT_BOUNCING_FACTOR) 00235 pBlob->factorAbsorptionShock=0.9; // coef elastic bouncing 00236 00237 // add this relaxing loop to the present config: 00238 blobArray.push_back(pBlob); 00239 00240 // update auxiliary variable numBlobs (just for easy reference): 00241 numBlobs=blobArray.size(); 00242 } 00243 void blobConfig::addOneRigidLoopBouncing(vector2Df initpos, vector2Df initspeed) { 00244 rigidLoop* pBlob= new rigidLoop(); 00245 pBlob->createBlob(blobArray.size(), SPOT_BOUNCING_FACTOR, initpos, initspeed); 00246 // add this relaxing loop to the present config: 00247 blobArray.push_back(pBlob); 00248 00249 // update auxiliary variable numBlobs (just for easy reference): 00250 numBlobs=blobArray.size(); 00251 } 00252 00253 void blobConfig::addOneRigidLoopPacman(vector2Df initpos, vector2Df initspeed) { 00254 rigidLoop* pBlob= new rigidLoop(); 00255 pBlob->createBlob(blobArray.size(), SPOT_PACMAN, initpos, initspeed); 00256 // add this relaxing loop to the present config: 00257 blobArray.push_back(pBlob); 00258 00259 // update auxiliary variable numBlobs (just for easy reference): 00260 numBlobs=blobArray.size(); 00261 } 00262 void blobConfig::addOneRigidLoopGhost(vector2Df initpos, vector2Df initspeed) { 00263 rigidLoop* pBlob= new rigidLoop(); 00264 pBlob->createBlob(blobArray.size(), SPOT_GHOST, initpos, initspeed); 00265 // add this relaxing loop to the present config: 00266 blobArray.push_back(pBlob); 00267 00268 // update auxiliary variable numBlobs (just for easy reference): 00269 numBlobs=blobArray.size(); 00270 } 00271 00272 00273 void blobConfig::addOneRigidLoopLorentz(vector2Df initpos, vector2Df initspeed) { 00274 rigidLoop* pBlob= new rigidLoop(); 00275 pBlob->createBlob(blobArray.size(), SPOT_LORENTZ_FORCE, initpos, initspeed); 00276 // add this loop to the present config: 00277 blobArray.push_back(pBlob); 00278 00279 // update auxiliary variable numBlobs (just for easy reference): 00280 numBlobs=blobArray.size(); 00281 } 00282 00283 void blobConfig::addOneRigidLoopAirHockey(vector2Df initpos, vector2Df initspeed) { 00284 rigidLoop* pBlob= new rigidLoop(); 00285 pBlob->createBlob(blobArray.size(), SPOT_AIR_HOCKEY, initpos, initspeed); 00286 // add this loop to the present config: 00287 blobArray.push_back(pBlob); 00288 00289 // update auxiliary variable numBlobs (just for easy reference): 00290 numBlobs=blobArray.size(); 00291 } 00292 00293 void blobConfig::addOneRigidLoopFollowing(vector2Df initpos, vector2Df initspeed) { 00294 rigidLoop* pBlob= new rigidLoop(); 00295 pBlob->createBlob(blobArray.size(), SPOT_FOLLOWING, initpos, initspeed); 00296 // add this relaxing loop to the present config: 00297 blobArray.push_back(pBlob); 00298 00299 // random color for Tokyo Designer Week: 00300 //randomizeAllColors(); 00301 00302 // update auxiliary variable numBlobs (just for easy reference): 00303 numBlobs=blobArray.size(); 00304 } 00305 00306 void blobConfig::addOneRigidLoopTest(vector2Df initpos, vector2Df initspeed) { 00307 rigidLoop* pBlob= new rigidLoop(); 00308 pBlob->createBlob(blobArray.size(), SPOT_TEST, initpos, initspeed); 00309 // add this relaxing loop to the present config: 00310 blobArray.push_back(pBlob); 00311 00312 // update auxiliary variable numBlobs (just for easy reference): 00313 numBlobs=blobArray.size(); 00314 } 00315 00316 void blobConfig::addOneRigidTrackingSpot(vector2Df initpos, vector2Df initspeed) { 00317 rigidLoop* pBlob= new rigidLoop(); 00318 pBlob->createBlob(blobArray.size(), SPOT_TRACK, initpos, initspeed); 00319 // add this relaxing loop to the present config: 00320 blobArray.push_back(pBlob); 00321 00322 // update auxiliary variable numBlobs (just for easy reference): 00323 numBlobs=blobArray.size(); 00324 } 00325 00326 void blobConfig::addOneRigidTrackingSpotDot(vector2Df initpos, vector2Df initspeed) { 00327 rigidLoop* pBlob= new rigidLoop(); 00328 pBlob->createBlob(blobArray.size(), SPOT_TRACK_DOT, initpos, initspeed); 00329 // add this relaxing loop to the present config: 00330 blobArray.push_back(pBlob); 00331 00332 // update auxiliary variable numBlobs (just for easy reference): 00333 numBlobs=blobArray.size(); 00334 } 00335 // ================================================================================================================================================== 00336 void blobConfig::processSensedData() { 00337 for (int i=0; i<blobArray.size(); i++) blobArray[i]->displaySensingBuffer.processSensedData(); // note: region with light is -1, and without is 2 (TO CHANGE!!! then we don't need to do "if" in the moment computation, but just a product) 00338 } 00339 00340 void blobConfig::allKill() { // this put all the blobs in "dead" mode, meaning that neither rendering nor update is done (but they are not deleted). 00341 for (int i=0; i<blobArray.size(); i++) { 00342 blobArray[i]->render = false; 00343 blobArray[i]->standByMode = true; 00344 } 00345 } 00346 void blobConfig::allAlive() { 00347 for (int i=0; i<blobArray.size(); i++) { 00348 blobArray[i]->render = true; 00349 blobArray[i]->standByMode = false; 00350 } 00351 } 00352 00353 void blobConfig::allStandBy() { 00354 for (int i=0; i<blobArray.size(); i++) blobArray[i]->standByMode = true; 00355 } 00356 00357 void blobConfig::allResume() { 00358 for (int i=0; i<blobArray.size(); i++) blobArray[i]->standByMode = false; 00359 } 00360 00361 void blobConfig::allVisible() { 00362 for (int i=0; i<blobArray.size(); i++) blobArray[i]->render = true; 00363 } 00364 00365 void blobConfig::allInvisible() { // note that they may continue to evolve 00366 for (int i=0; i<blobArray.size(); i++) blobArray[i]->render = false; 00367 } 00368 00369 void blobConfig::allSetColor(unsigned char c) { 00370 for (int i=0; i<blobArray.size(); i++) blobArray[i]->setColor(c); 00371 } 00372 00373 void blobConfig::allSetGreen(unsigned char c) { 00374 for (int i=0; i<blobArray.size(); i++) blobArray[i]->setGreenColor(c); 00375 } 00376 00377 void blobConfig::allSetBlue(unsigned char c) { 00378 for (int i=0; i<blobArray.size(); i++) blobArray[i]->setBlueColor(c); 00379 } 00380 00381 void blobConfig::randomizeAllColors() { 00382 int c; 00383 for (int i=0; i<blobArray.size(); i++) { 00384 c= rand() % 2; 00385 blobArray[i]->setBlueColor(c); 00386 c= rand() % 2; 00387 blobArray[i]->setGreenColor(c); 00388 } 00389 } 00390 00391 void blobConfig::update() { // update dynamics of the blob configuration: 00392 int i; 00393 float minDist=5000, dist; 00394 bool win; 00395 // Depending on the config type, perform some special test and updates: 00396 switch(myConfigType) { 00397 // simple behaviours: 00398 case ONE_ELASTIC_FOLLOWING: 00399 case ONE_ELASTIC_MOUTH: 00400 case ONE_ELASTIC_MOUTH_SMALL: 00401 case BOUNCING_SPOTS: 00402 case LORENTZ_SPOTS: 00403 case FOLLOWING_SPOTS: 00404 case ONE_TRACKING_SPOT: 00405 case AIR_HOCKEY_GAME: 00406 // In all these simple cases, update dynamics of each blob independently: 00407 for (i=0; i<blobArray.size(); i++) { 00408 if (blobArray[i]->standByMode==false) blobArray[i]->update(); 00409 } 00410 break; 00411 // more game-like: 00412 case CIRCULAR_PONG_GAME: 00413 // spot index 0 is a tracking spot, the background "anchor": 00414 if (blobArray[0]->standByMode==false) blobArray[0]->update(); 00415 // all the other spots are bouncing spots: 00416 for (i=1; i<blobArray.size(); i++) { 00417 if (blobArray[i]->standByMode==false) blobArray[i]->update(); 00418 } 00419 // GAME CHECK: is some bouncing spot too far from the anchor? if so, make it "explode" (and then dissapear, but leave this for now): 00420 for (i=1; i<blobArray.size(); i++) { 00421 dist=(blobArray[0]->getCenter()).distance(blobArray[i]->getCenter()); 00422 if (dist>1000) { 00423 blobArray[i]->explosion(); 00424 float anglaux=1.0*(i-1)/(blobArray.size()-1)*2*PI; 00425 blobArray[i]->setPositionSpeed(vector2Df(CENTER_AD_MIRROR_X+200*cos(anglaux), CENTER_AD_MIRROR_Y+200*sin(anglaux)), 00426 vector2Df(cos(anglaux),sin(anglaux))*10); 00427 } 00428 } 00429 break; 00430 case RAIN_MODE: // this is just spots with gravity that reapears in the top position when reaching the bottom: 00431 // others are bouncing with gravity: 00432 for (i=0; i<blobArray.size(); i++) { 00433 if (blobArray[i]->standByMode==false) blobArray[i]->update(); 00434 } 00435 // GAME CHECKS: 00436 for (i=0; i<blobArray.size(); i++) { 00437 if (blobArray[i]->getCenter().y>MAX_AD_MIRRORS-20) { 00438 // Replace position of spot to the initial position: 00439 blobArray[i]->explosion(); 00440 blobArray[i]->resetPositionSpeed(); 00441 } 00442 } 00443 break; 00444 case VERTICAL_PINBALL_GAME: 00445 // spot index 0 is a tracking spot, the background "anchor": 00446 if (blobArray[0]->standByMode==false) blobArray[0]->update(); 00447 // others are bouncing with gravity: 00448 for (i=1; i<blobArray.size(); i++) { 00449 if (blobArray[i]->standByMode==false) blobArray[i]->update(); 00450 } 00451 // GAME CHECKS: 00452 for (i=1; i<blobArray.size(); i++) { 00453 dist=(blobArray[0]->getCenter()).distance(blobArray[i]->getCenter()); 00454 //(1) win (meaning bouncing spot very close to anchor): 00455 if (dist<60) { 00456 blobArray[i]->explosion(); 00457 blobArray[i]->setPositionSpeed(vector2Df(blobArray[0]->getCenter().x-400+rand()%800, blobArray[0]->getCenter().y-1200), 00458 vector2Df(0, 0)); 00459 } 00460 //(2) loose (meaning spot went outside range): 00461 if (blobArray[i]->getCenter().y>blobArray[0]->getCenter().y) { 00462 blobArray[i]->setPositionSpeed(vector2Df(blobArray[0]->getCenter().x-400+rand()%800, blobArray[0]->getCenter().y-1200), 00463 vector2Df(i*10-5, 0)); 00464 } 00465 } 00466 break; 00467 case FISH_NET_GAME: 00468 // spot index 0 is a tracking spot, the background "anchor": 00469 if (blobArray[0]->standByMode==false) blobArray[0]->update(); 00470 // all the other spots are bouncing spots: 00471 for (i=1; i<blobArray.size(); i++) { 00472 if (blobArray[i]->standByMode==false) blobArray[i]->update(); 00473 } 00474 // GAME CHECKS: a win only, when all the spots are very close to the mother spot: 00475 win=true; 00476 for (i=1; i<blobArray.size(); i++) { 00477 dist=(blobArray[0]->getCenter()).distance(blobArray[i]->getCenter()); 00478 win&=(dist<80); 00479 } 00480 if (win) { 00481 for (i=1; i<blobArray.size(); i++) { 00482 blobArray[i]->explosion(); 00483 float anglaux=1.0*(i-1)/(blobArray.size()-1)*2*PI; 00484 blobArray[i]->setPositionSpeed(vector2Df(CENTER_AD_MIRROR_X+400*cos(anglaux), CENTER_AD_MIRROR_Y+400*sin(anglaux)), 00485 vector2Df(cos(anglaux),sin(anglaux))*10); 00486 } 00487 } 00488 break; 00489 case PAC_MAN_GAME: 00490 // spot index 0 is the pacman: 00491 if (blobArray[0]->standByMode==false) blobArray[0]->update(); 00492 // spot 1 and 2 are ghosts: 00493 if (blobArray[1]->standByMode==false) blobArray[1]->update(blobArray[0]->getCenter()); 00494 if (blobArray[2]->standByMode==false) blobArray[2]->update(blobArray[0]->getCenter()); // pass the position of the PACMAN! 00495 00496 // GAME CHECK: are any ghost too close to the pacman? 00497 for (i=1; i<blobArray.size(); i++) { 00498 dist=(blobArray[0]->getCenter()).distance(blobArray[i]->getCenter()); 00499 if (minDist>dist) minDist=dist; 00500 } 00501 if (minDist<50) { 00502 blobArray[0]->explosion(); 00503 // then restart the game: 00504 // initConfig(PAC_MAN_GAME); 00505 } 00506 00507 break; 00508 default: 00509 break; 00510 } 00511 00512 00513 } 00514 00515 void blobConfig::computeBoundingBox() { 00516 for (int i=0; i<blobArray.size(); i++) { 00517 blobArray[i]->computeBoundingBox(); 00518 } 00519 } 00520 00521 void blobConfig::draw() { // draw uses the opengl like renderer (if any), and save projected trajectory in the LaserSensingTrajectory object of each blob 00522 for (int i=0; i<blobArray.size(); i++) { 00523 if (blobArray[i]->render==true) blobArray[i]->draw(); 00524 } 00525 } 00526 00527 void blobConfig::sendConfData() { 00528 // For the time being, only "per blob" data sending: 00529 // (b) Per-spot sending of data (note: both are NOT exclusive; so if we want just packaged data, 00530 // we need to make all the spot STOP sending data. 00531 for (int i=0; i<blobArray.size(); i++) { 00532 if (blobArray[i]->render==true) blobArray[i]->sendData(); // a blob that is in stand-by mode may send data (good for testing with a fixed loop) 00533 } 00534 } 00535 00536 00537 00538
Generated on Tue Jul 12 2022 21:23:03 by 1.7.2