Changeset 435:b6fdaf8e453c


Ignore:
Timestamp:
04/09/11 17:15:37 (12 years ago)
Author:
Simon Cross <hodgestar@…>
Branch:
default
Phase:
public
Rebase:
66613237633036656136353361623931656539373834666365373566633438663536343233633236
Message:

Make shield last for one second. Separate out recharge times to allow the shield to take longer to recharge.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • skaapsteker/sprites/player.py

    r433 r435  
    3232        self._last_time = time.time()
    3333        self._recharge_timers = {
    34                 'fireball': time.time(),
    35                 'lightning': time.time(),
    36                 'shield': time.time(),
     34            'fireball': [ time.time(), lambda : 2.0 / len(self._me.tails) ],
     35            'lightning': [ time.time(), lambda : 2.0 / len(self._me.tails) ],
     36            'shield': [ time.time(), lambda : 16.0 / len(self._me.tails) ],
    3737        }
    3838        self._inv_cache = {} # invisible fox image cache
     
    160160                self.invisible = 0
    161161        if self.using_shield > 0:
    162             self.using_shield -= 1
     162            if (now - self._shield_start_time) > 1.0:
     163                self.using_shield = 0
    163164        if abs(v_x) < 80:
    164165            # Clamp when we're not moving at least 5 pixel / s
     
    228229
    229230    def damage(self, damage):
    230         if 'shield' in self._me.tails and self.check_fire_rate('shield'):
    231             print "Using shield"
    232             self.using_shield = 30
     231        if self.using_shield > 0:
     232            "Shield on."
     233            return
     234        elif 'shield' in self._me.tails and self.check_fire_rate('shield'):
     235            print "Activating shield."
     236            self._shield_start_time = time.time()
     237            self.using_shield = 1
    233238            return
    234239        self._me.cur_health -= damage
     
    386391        if self.recharge_level(attack) < 1:
    387392            return False
    388         self._recharge_timers[attack] = time.time()
     393        self._recharge_timers[attack][0] = time.time()
    389394        return True
    390395
    391396    def recharge_level(self, attack):
    392         recharge_time = 2.0 / len(self._me.tails)
    393         return min((time.time() - self._recharge_timers[attack]) / recharge_time, 1)
     397        recharge_time = self._recharge_timers[attack][1]()
     398        return min((time.time() - self._recharge_timers[attack][0]) / recharge_time, 1)
    394399
    395400    def discharge_level(self, tail):
Note: See TracChangeset for help on using the changeset viewer.