Mercurial > nagslang
changeset 624:59d375111cc5
collider based moonlight and acid
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sun, 08 Sep 2013 01:05:03 +0200 |
parents | 9f0e738ab4a5 |
children | e9e73ec9b18a |
files | nagslang/game_object.py |
diffstat | 1 files changed, 12 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- 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)