Changeset 430:25efc74ac19c


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

Hook up flight and invisibility discharge

Location:
skaapsteker
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • skaapsteker/levelscene.py

    r419 r430  
    242242        for tail, position in constants.FoxHud.TAIL_POSITIONS.iteritems():
    243243            has_tail = tail in fox.tails
    244             tail_pos = (self._clip_rect.left + fox_hud.TAILS_BG_MARGIN,
    245                         self._clip_rect.top + fox_hud.TAIL_POSITIONS[tail])
    246 
    247             if has_tail and tail in ('fireball', 'lightning'):
    248                 imgs = self._tails[tail]
    249                 size = imgs[0].get_size()
     244            tail_pos = pygame.Rect(self._clip_rect.left + fox_hud.TAILS_BG_MARGIN,
     245                                   self._clip_rect.top + fox_hud.TAIL_POSITIONS[tail],
     246                                   0, 0)
     247
     248            imgs = self._tails[tail]
     249            size = imgs[0].get_size()
     250            if has_tail and tail in ('flight', 'invisibility'):
     251                area = pygame.Rect(self._player.discharge_level(tail) * size[0], 0, size[0], size[1])
     252                self._level_surface.blit(imgs[0], tail_pos)
     253                self._level_surface.blit(imgs[1], tail_pos.move(area.left, 0), area)
     254            elif has_tail and tail in ('fireball', 'lightning', 'shield'):
    250255                area = pygame.Rect(0, 0, self._player.recharge_level(tail) * size[0], size[1])
    251256                self._level_surface.blit(imgs[0], tail_pos)
    252257                self._level_surface.blit(imgs[1], tail_pos, area)
    253258            else:
    254                 self._level_surface.blit(self._tails[tail][int(has_tail)], tail_pos)
     259                self._level_surface.blit(imgs[int(has_tail)], tail_pos)
    255260
    256261        # Draw the health bar
  • skaapsteker/sprites/player.py

    r429 r430  
    392392        return min((time.time() - self._last_attacked[attack]) / RECHARGE_TIME, 1)
    393393
     394    def discharge_level(self, tail):
     395        if tail == 'invisibility' and hasattr(self, '_invisibility_start_time'):
     396            start_time = self._invisibility_start_time
     397            max_time = self._max_invisibility_time
     398        elif tail == 'flight' and hasattr(self, '_flight_start_time'):
     399            start_time = self._flight_start_time
     400            max_time = self._max_flight_time
     401        else:
     402            return 0
     403        discharge = (time.time() - start_time) / max_time
     404        if discharge > 1:
     405            return 0
     406        return discharge
     407
    394408    def _get_action(self):
    395409        if self.attacking:
Note: See TracChangeset for help on using the changeset viewer.