Changeset 302:a0a471ad2ee8 for nagslang


Ignore:
Timestamp:
Sep 5, 2013, 9:57:50 PM (7 years ago)
Author:
Stefano Rivera <stefano@…>
Branch:
default
Message:

Pass bullet hits through to the target

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/game_object.py

    r297 r302  
    149149        self.renderer.animate()
    150150
     151    def hit(self, weapon):
     152        '''Was hit with a weapon (such as a bullet)'''
     153        pass
     154
    151155    def collide_with_protagonist(self, protagonist):
    152156        """Called as a `pre_solve` collision callback with the protagonist.
     
    358362        self.last_position = position
    359363        for collision in r:
    360             if (collision.shape.collision_type == self.source_collision_type
    361                     or collision.shape == self.physicser.get_shape()
    362                     or collision.shape.sensor):
     364            shape = collision.shape
     365            if (shape.collision_type == self.source_collision_type
     366                    or shape == self.physicser.get_shape()
     367                    or shape.sensor):
    363368                continue
    364             print "Hit", collision.shape.collision_type
     369            if hasattr(shape, 'physicser'):
     370                shape.physicser.game_object.hit(self)
    365371            self.physicser.remove_from_space()
    366372            self.remove = True
Note: See TracChangeset for help on using the changeset viewer.