# HG changeset patch # User Stefano Rivera # Date 1378418270 -7200 # Node ID a0a471ad2ee804f7b191d24d4ed6ccfe16aeced9 # Parent 893f148a2f13982c0afc3066c91bc485ba469244 Pass bullet hits through to the target diff -r 893f148a2f13 -r a0a471ad2ee8 nagslang/game_object.py --- a/nagslang/game_object.py Thu Sep 05 23:56:25 2013 +0200 +++ b/nagslang/game_object.py Thu Sep 05 23:57:50 2013 +0200 @@ -148,6 +148,10 @@ def animate(self): self.renderer.animate() + def hit(self, weapon): + '''Was hit with a weapon (such as a bullet)''' + pass + def collide_with_protagonist(self, protagonist): """Called as a `pre_solve` collision callback with the protagonist. @@ -357,11 +361,13 @@ r = self.get_space().segment_query(self.last_position, position) self.last_position = position for collision in r: - if (collision.shape.collision_type == self.source_collision_type - or collision.shape == self.physicser.get_shape() - or collision.shape.sensor): + shape = collision.shape + if (shape.collision_type == self.source_collision_type + or shape == self.physicser.get_shape() + or shape.sensor): continue - print "Hit", collision.shape.collision_type + if hasattr(shape, 'physicser'): + shape.physicser.game_object.hit(self) self.physicser.remove_from_space() self.remove = True break