bool Column::gotHealth(Displayable& helicopter){ //column has no health if(orbo == NULL){ return false; } int heliY1 = helicopter.getY() - (orbo->getHeight() / 4); int heliY2 = heliY1 + helicopter.getHeight() + (orbo->getHeight() / 4); int orbMidpointY = orbo->getY() + (orbo->getHeight() / 2); if((orbMidpointY < heliY2) && (orbMidpointY > heliY1)){ return true; } return false; }
bool Column::missileStrike(Displayable& helicopter){ //column has no gunner -> column has no missiles associated with it if(missiles == NULL || missiles->empty()){ return false; } int heliY1 = helicopter.getY(); int heliY2 = heliY1 + helicopter.getHeight(); std::list<Missile*>::iterator missile = missiles->begin(); //loop through missiles and see if one has hit our hero for(int i = 0; i < missiles->size(); i++, missile++){ if(((*missile)->getY() < heliY2) && ((*missile)->getY() > heliY1)){//helicopter struck by missile missiles->erase(missile); return true; } } return false; }