Ignore:
Timestamp:
Sep 6, 2013, 9:58:15 PM (7 years ago)
Author:
Stefano Rivera <stefano@…>
Branch:
default
rebase_source:
5077a64a868295383cfa281f1f69c605a3d6437c
Message:

Use a result object to get new drawables back to the area

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/enemies.py

    r372 r385  
    1010                                ACID_SPEED, ACID_DAMAGE, ZORDER_MID)
    1111from nagslang.events import EnemyDeathEvent, FireEvent
    12 from nagslang.game_object import GameObject, SingleShapePhysicser, make_body
     12from nagslang.game_object import (GameObject, SingleShapePhysicser, Result,
     13                                  make_body)
    1314from nagslang.mutators import FLIP_H
    1415from nagslang.resources import resources
     
    6970    def lose_health(self, amount):
    7071        self.health -= amount
    71         if self.health < 0:
     72        if self.health <= 0:
    7273            self.physicser.remove_from_space()
    73             self.remove = True
    7474            EnemyDeathEvent.post(self.physicser.position, self.enemy_type)
    7575
     
    126126        return x_step, y_step
    127127
     128    def update(self, dt):
     129        super(Enemy, self).update(dt)
     130        if self.health <= 0:
     131            return Result(remove=[self])
     132
    128133
    129134class DeadEnemy(GameObject):
     
    195200        self.set_direction(x_step, y_step)
    196201        self.ranged_attack(300, ACID_SPEED, ACID_DAMAGE, 'acid', 0.2)
    197         super(PatrollingAlien, self).update(dt)
     202        return super(PatrollingAlien, self).update(dt)
    198203
    199204    @classmethod
     
    251256        dx, dy = self._calc_movement()
    252257        self.set_direction(dx, dy)
    253         super(ChargingAlien, self).update(dt)
     258        return super(ChargingAlien, self).update(dt)
    254259
    255260    @classmethod
     
    291296
    292297    def update(self, dt):
    293         super(RunAndGunAlien, self).update(dt)
    294298        self.count += 1
     299        return super(RunAndGunAlien, self).update(dt)
    295300
    296301    @classmethod
Note: See TracChangeset for help on using the changeset viewer.