Ignore:
Timestamp:
09/05/13 22:17:22 (9 years ago)
Author:
Stefano Rivera <stefano@…>
Branch:
default
Phase:
public
Amend:
31616561636265613935303431666638633164313365323262306563373433383838376266386139
Rebase:
61646163653333336362393533363133646636663330303337356162336137626565373132336334
Message:

Enemies now die

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/enemies.py

    r278 r305  
    2626        self._setup_physics(space, position)
    2727        self._setup_renderer()
     28        self.health = 42
    2829
    2930        super(Enemy, self).__init__(
     
    4748    def requires(cls):
    4849        return [("name", "string"), ("position", "coordinates")]
     50
     51    def lose_health(self, amount):
     52        self.health -= amount
     53        if self.health < 0:
     54            self.world.kills += 1
     55            self.physicser.remove_from_space()
     56            self.remove = True
    4957
    5058
     
    130138    def collide_with_protagonist(self, protagonist):
    131139        protagonist.lose_health(15)
     140
     141    def hit(self, weapon):
     142        self.lose_health(weapon.damage)
    132143
    133144    @classmethod
Note: See TracChangeset for help on using the changeset viewer.