void PlayerPhysicsComponent::onHit()
{
    if (!invulnerable && !decrementHealth(1))
    {
        onDestroy();
    }
}
Esempio n. 2
0
	// included decrementHealth() not sure its created properly
int robot::decrementHealth(int amount){
    if ((health - amount) > 0) {
        while (amount > 0) {
			decrementHealth();
			amount--;
		}
        return health;
    }else{
        health = 0;
//		std::cout << "This robot is not feeling too good :( Health: " << health << std::endl;
        return health;
    }
}
Esempio n. 3
0
/** Function that returns true when the Alien intersects with a Thing. If it does, it decrements the Thing's health by 10 while decrementing its own by 1
  @param rocket the Thing that the Alien is checking if its intersecting
*/
bool Alien::collidesWith(Thing* rocket){
  bool collide = collidesWithItem(rocket, Qt::IntersectsItemShape);

  // colliding with something that has the same pic (and therefore same classification as Alien) is the same as no collission
  if (rocket->getPic() == pic_)
    return false;
    
  if (collide && collisionCounts)
  {
    rocket->decrementHealth(5);
    decrementHealth(1);
    //collisionCounts = false;
    if (rocket->dead) // if rocket's health is 0, flags offScreen
      rocket->offScreen = true;
    return true;
  }
  else
    return false;
}