bool HollowBall::contains(const HollowBall& b) const { if(b.outerRadius > outerRadius) return false; Real d = b.center.distance(center); ClosedInterval i,ib; if(isBall()) { i.a = -outerRadius; i.b = outerRadius; ib.a = d-b.outerRadius; ib.b = d+b.outerRadius; return i.contains(ib); } else { //first positive side i.a = innerRadius; i.b = outerRadius; if(d > b.outerRadius) { //check b as a ball ib.a = d-b.outerRadius; ib.b = d+b.outerRadius; return i.contains(ib); } //check b in two parts -- positive, negative ib.a = d+Max(b.innerRadius,Zero); ib.b = d+b.outerRadius; if(!i.contains(ib)) return false; //negative part i.a = -outerRadius; i.b = -innerRadius; ib.a = d-b.outerRadius; ib.b = d-Max(b.innerRadius,Zero); return i.contains(ib); } }
void Wall::update() { if (callback->ctxt.hit) { if (simulator->soundOn) { if (isBall(callback->ctxt.theObject->name)) { //simulator->soundSystem->playWallHit(); } } } }
void printMap() { for(int l = 0; l < HEIGHT; ++l) { for(int c = 0; c < WIDTH; ++c) { if(isWall(theMap[l][c])) { printf("#"); } else if(isBall(theMap[l][c])) { if(theMap[l][c].ballType == RED_BALL) { printf("R"); } else { printf("G"); } } else { printf("."); } } printf("\n"); } printf("\n"); }