Changeset 411:a5f54ae9217e


Ignore:
Timestamp:
04/09/11 15:35:11 (12 years ago)
Author:
Stefano Rivera <stefano@…>
Branch:
default
Phase:
public
Message:

Per weapon recharge

Location:
skaapsteker
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • skaapsteker/constants.py

    r405 r411  
    5959    HEALTH_WIDTH = 20
    6060
    61     RECHARGE_BACKGROUND = pygame.Color(64, 128, 0, 128)
    62     RECHARGE_FOREGROUND = pygame.Color(64, 255, 0, 196)
    63     RECHARGE_TOP = 220
    64     RECHARGE_WIDTH = 50
    65     RECHARGE_HEIGHT = 15
    66 
    67     SCROLL_TOP = 240
    68     TOFU_TOP = 270
     61    SCROLL_TOP = 220
     62    TOFU_TOP = 250
  • skaapsteker/levelscene.py

    r408 r411  
    255255        pygame.draw.rect(self._level_surface, fox_hud.HEALTH_FOREGROUND, bar)
    256256
    257         # Draw fire recharge bar
    258         recharge = pygame.Rect(self._clip_rect.right - 55,
    259                                self._clip_rect.top + fox_hud.RECHARGE_TOP,
    260                                fox_hud.RECHARGE_WIDTH, fox_hud.RECHARGE_HEIGHT)
    261         pygame.draw.rect(self._level_surface, fox_hud.RECHARGE_BACKGROUND, recharge)
    262         recharge.width = int(fox_hud.RECHARGE_WIDTH * self._player.recharge_level())
    263         pygame.draw.rect(self._level_surface, fox_hud.RECHARGE_FOREGROUND, recharge)
    264 
    265257        # Draw scroll count
    266258        pos = self._clip_rect.right - 20, self._clip_rect.top + fox_hud.SCROLL_TOP + 5
  • skaapsteker/sprites/player.py

    r410 r411  
    1212
    1313from pygame.constants import BLEND_RGBA_MULT
    14 
    1514
    1615class Player(Sprite):
     
    3231        self._animation_frame = 0.0
    3332        self._last_time = time.time()
    34         self._last_fired = time.time()
     33        self._last_attacked = {
     34                'fireball': time.time(),
     35                'lightning': time.time(),
     36        }
    3537        self._inv_cache = {}
    3638        # State flags and such
     
    241243        self._max_flight_time = float(len(self._me.tails))
    242244        self._flight_start_time = time.time()
    243 
    244245    def action_invisible(self):
    245246        if self.invisible > 0 or 'invisibility' not in self._me.tails:
     
    314315
    315316    def _fireball_attack(self):
     317        if not self.check_fire_rate('fireball'):
     318            return
    316319        self.invisible = 0
    317320        self.attacking = 2
     
    320323
    321324    def _lightning_attack(self):
     325        if not self.check_fire_rate('lightning'):
     326            return
    322327        self.invisible = 0
    323328        self.attacking = 2
     
    326331
    327332    def action_fire1(self):
    328         if self._me.shape != 'fox' or not self.check_fire_rate():
     333        if self._me.shape != 'fox':
    329334            return
    330335        if "fireball" not in self._me.tails:
     
    334339
    335340    def action_fire2(self):
    336         if self._me.shape != 'fox' or not self.check_fire_rate():
     341        if self._me.shape != 'fox':
    337342            return
    338343        if "lightning" not in self._me.tails:
     
    341346            self._lightning_attack()
    342347
    343     def check_fire_rate(self):
    344         if self.recharge_level() < 1:
     348    def check_fire_rate(self, attack):
     349        if self.recharge_level(attack) < 1:
    345350            return False
    346         self._last_fired = time.time()
     351        self._last_attacked[attack] = time.time()
    347352        return True
    348353
    349     def recharge_level(self):
    350         return min((time.time() - self._last_fired) / RECHARGE_TIME, 1)
     354    def recharge_level(self, attack):
     355        return min((time.time() - self._last_attacked[attack]) / RECHARGE_TIME, 1)
    351356
    352357    def _get_action(self):
Note: See TracChangeset for help on using the changeset viewer.