Ignore:
Timestamp:
09/06/13 19:56:57 (8 years ago)
Author:
Jeremy Thurgood <firxen@…>
Branch:
default
Phase:
public
Message:

Automatic weapons.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/game_object.py

    r370 r371  
    127127            self.interactible.set_game_object(self)
    128128        self.remove = False  # If true, will be removed from drawables
     129        self._timers = {}
     130        self._active_timers = {}
     131
     132    def add_timer(self, name, secs):
     133        self._timers[name] = secs
     134
     135    def start_timer(self, name, secs=None):
     136        if secs is None:
     137            secs = self._timers[name]
     138        self._active_timers[name] = secs
     139
     140    def check_timer(self, name):
     141        return name in self._active_timers
    129142
    130143    def set_stored_state_dict(self, stored_state):
     
    160173    def update(self, dt):
    161174        self.lifetime += dt
     175        for timer in self._active_timers.keys():
     176            self._active_timers[timer] -= dt
     177            if self._active_timers[timer] <= 0:
     178                self._active_timers.pop(timer)
    162179        self.renderer.update(dt)
    163180
Note: See TracChangeset for help on using the changeset viewer.