Changeset 624:59d375111cc5 for nagslang


Ignore:
Timestamp:
Sep 7, 2013, 11:05:03 PM (7 years ago)
Author:
Neil Muller <drnlmuller@…>
Branch:
default
rebase_source:
fb14cdf865194ae023d2cc2dee3215fd0109e64f
Message:

collider based moonlight and acid

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/game_object.py

    r614 r624  
    717717        self.shape.sensor = True
    718718        renderer = self._fix_image(outline)
     719        self._collider = puzzle.CollidePuzzler()
     720        self._collider.set_game_object(self)
     721        self._protagonist = None
    719722        super(HostileTerrain, self).__init__(
    720723            SingleShapePhysicser(space, self.shape),
     
    737740        self.renderer = self._fix_image(new_outline)
    738741
     742    def update(self, seconds):
     743        if self._collider.get_state():
     744            if self._ticks == 0:
     745                self.apply_effect(self._protagonist)
     746            self._ticks += 1
     747            if self._ticks > self.rate:
     748                self._ticks = 0
     749
    739750    def collide_with_protagonist(self, protagonist):
    740         # We're called every frame we're colliding, so
    741         # There are timing issues with stepping on and
    742         # off terrian, but as long as the rate is reasonably
    743         # low, they shouldn't impact gameplay
    744         if self._ticks == 0:
    745             self.apply_effect(protagonist)
    746         self._ticks += 1
    747         if self._ticks > self.rate:
    748             self._ticks = 0
     751        self._protagonist = protagonist
    749752
    750753    def apply_effect(self, protagonist):
Note: See TracChangeset for help on using the changeset viewer.