Ignore:
Timestamp:
Sep 6, 2013, 10:42:09 PM (7 years ago)
Author:
Stefano Rivera <stefano@…>
Branch:
default
Message:

Use Result to handle enemy death (but keep the event for accounting purposes)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/enemies.py

    r385 r391  
    99from nagslang.constants import (COLLISION_TYPE_ENEMY, COLLISION_TYPE_FURNITURE,
    1010                                ACID_SPEED, ACID_DAMAGE, ZORDER_MID)
    11 from nagslang.events import EnemyDeathEvent, FireEvent
     11from nagslang.events import FireEvent, EnemyDeathEvent
    1212from nagslang.game_object import (GameObject, SingleShapePhysicser, Result,
    1313                                  make_body)
     
    7171        self.health -= amount
    7272        if self.health <= 0:
     73            EnemyDeathEvent.post()
    7374            self.physicser.remove_from_space()
    74             EnemyDeathEvent.post(self.physicser.position, self.enemy_type)
    7575
    7676    def set_direction(self, dx, dy):
     
    129129        super(Enemy, self).update(dt)
    130130        if self.health <= 0:
    131             return Result(remove=[self])
     131            return Result(
     132                add=[DeadEnemy(self.get_space(), self.world,
     133                               self.physicser.position, self.enemy_type)],
     134                remove=[self])
    132135
    133136
Note: See TracChangeset for help on using the changeset viewer.