Ignore:
Timestamp:
09/06/13 08:49:19 (8 years ago)
Author:
Jeremy Thurgood <firxen@…>
Branch:
default
Phase:
public
Message:

Better wolf claw attack.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/enemies.py

    r318 r333  
    2525    """A base class for mobile enemies"""
    2626    enemy_type = None  # Image to use for dead Enemy
     27    enemy_damage = None
    2728
    2829    def __init__(self, space, world, position):
     
    6162            self.remove = True
    6263            EnemyDeathEvent.post(self.physicser.position, self.enemy_type)
     64
     65    def collide_with_protagonist(self, protagonist):
     66        if self.enemy_damage is not None:
     67            protagonist.lose_health(self.enemy_damage)
     68
     69    def collide_with_claw_attack(self, claw_attack):
     70        self.lose_health(claw_attack.damage)
    6371
    6472
     
    136144            (dx * self.impulse_factor, dy * self.impulse_factor))
    137145
    138     def update(self, seconds):
     146    def update(self, dt):
    139147        # Calculate the step every frame
    140148        if self._direction == 'away':
     
    159167            self._switch_direction()
    160168        self.set_direction(x_step, y_step)
    161         super(PatrollingAlien, self).update(seconds)
    162 
    163     def collide_with_protagonist(self, protagonist):
    164         protagonist.lose_health(15)
     169        super(PatrollingAlien, self).update(dt)
    165170
    166171    @classmethod
     
    217222            (dx * self.impulse_factor, dy * self.impulse_factor))
    218223
    219     def update(self, seconds):
     224    def update(self, dt):
    220225        # Calculate the step every frame
    221226        # Distance to the protagonist
     
    242247            y_step = 0
    243248        self.set_direction(x_step, y_step)
    244         super(ChargingAlien, self).update(seconds)
    245 
    246     def collide_with_protagonist(self, protagonist):
    247         protagonist.lose_health(20)
     249        super(ChargingAlien, self).update(dt)
    248250
    249251    @classmethod
Note: See TracChangeset for help on using the changeset viewer.