# HG changeset patch # User Neil Muller # Date 1378595103 -7200 # Node ID 59d375111cc5ab1f7c99b511f027cda8c1c257bc # Parent 9f0e738ab4a528f993370985ffe3a2770e743423 collider based moonlight and acid diff -r 9f0e738ab4a5 -r 59d375111cc5 nagslang/game_object.py --- a/nagslang/game_object.py Sun Sep 08 01:04:04 2013 +0200 +++ b/nagslang/game_object.py Sun Sep 08 01:05:03 2013 +0200 @@ -716,6 +716,9 @@ self.shape.collision_type = COLLISION_TYPE_SWITCH self.shape.sensor = True renderer = self._fix_image(outline) + self._collider = puzzle.CollidePuzzler() + self._collider.set_game_object(self) + self._protagonist = None super(HostileTerrain, self).__init__( SingleShapePhysicser(space, self.shape), renderer) @@ -736,16 +739,16 @@ def update_image(self, new_outline): self.renderer = self._fix_image(new_outline) + def update(self, seconds): + if self._collider.get_state(): + if self._ticks == 0: + self.apply_effect(self._protagonist) + self._ticks += 1 + if self._ticks > self.rate: + self._ticks = 0 + def collide_with_protagonist(self, protagonist): - # We're called every frame we're colliding, so - # There are timing issues with stepping on and - # off terrian, but as long as the rate is reasonably - # low, they shouldn't impact gameplay - if self._ticks == 0: - self.apply_effect(protagonist) - self._ticks += 1 - if self._ticks > self.rate: - self._ticks = 0 + self._protagonist = protagonist def apply_effect(self, protagonist): protagonist.lose_health(self.damage)