receiveDamage method

void receiveDamage(
  1. double damage,
  2. dynamic from
)

Implementation

void receiveDamage(double damage, dynamic from) {
  if (life > 0) {
    life -= damage;
  }
  if (life <= 0) {
    die();
  }
}