Changeset 356:f5148f70ca84


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

Backgrounds for HUD

Location:
skaapsteker
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • skaapsteker/constants.py

    r318 r356  
    3333    HEALTH_HEIGHT = 160
    3434    HEALTH_WIDTH = 20
     35
     36    BG_ALPHA = 120
     37    BG_MARGIN = 8
     38
    3539    INVENTORY_SIZE = 48
     40    INVENTORY_START = 32
    3641
    3742    TAIL_START = 100
     
    4752            'lightning' : TAIL_START + 7 * TAIL_OFFSET,
    4853            }
     54    TAILS_WIDTH = 51
     55    TAILS_HEIGHT = 8 * TAIL_OFFSET
     56
  • skaapsteker/levelscene.py

    r349 r356  
    22
    33from pygame.locals import (KEYDOWN, KEYUP, K_DOWN, K_ESCAPE, K_LEFT, K_RIGHT,
    4                            K_SEMICOLON, K_UP, K_p, K_q, K_x, K_z, K_RETURN, K_c, K_j)
     4                           K_SEMICOLON, K_UP, K_c, K_j, K_p, K_q, K_x, K_z,
     5                           K_RETURN, SRCALPHA)
    56
    67import pygame
     
    189190           left side of the screen, a health bar and collected tofu and
    190191           scroll counts are shown on the right"""
    191         fox = self.game_state.world.fox  # conveience shortcur
    192         # Draw the healt bar
     192        # Convenience shortcuts
     193        fox = self.game_state.world.fox
     194        fox_hud = constants.FoxHud
     195
     196        # Draw the health bar
    193197        health_bottom = self._clip_rect.right - 30, self._clip_rect.top + 200
    194198        bar = pygame.Rect(0, 0, constants.FoxHud.HEALTH_WIDTH, constants.FoxHud.HEALTH_HEIGHT)
     
    198202        bar.bottomleft = health_bottom
    199203        pygame.draw.rect(self._level_surface, constants.FoxHud.HEALTH_FOREGROUND, bar)
     204        # Inventory bg
     205        bgsurf = pygame.Surface((fox_hud.INVENTORY_SIZE + 2 * 8,
     206                                 fox_hud.INVENTORY_SIZE + 2 * 8),
     207                                flags=SRCALPHA)
     208        bgsurf.fill((255, 255, 255, fox_hud.BG_ALPHA))
     209        self._level_surface.blit(bgsurf, (self._clip_rect.left,
     210                                          self._clip_rect.top + fox_hud.INVENTORY_START - 8))
    200211
    201212        # Draw inventory
     
    203214        if my_item:
    204215            # Get image and resize it
    205             inv_pos = self._clip_rect.left + 8, self._clip_rect.top + 32
     216            inv_pos = self._clip_rect.left + 8, self._clip_rect.top + fox_hud.INVENTORY_START
    206217            if self._player.inventory_image is None:
    207218                self._player.make_inventory_image()
    208219            self._level_surface.blit(self._player.inventory_image, inv_pos)
     220        # Tail bg
     221        bgsurf = pygame.Surface((self._tail.get_size()[0] + 2 * fox_hud.BG_MARGIN,
     222                                 fox_hud.TAILS_HEIGHT + fox_hud.BG_MARGIN),
     223                                flags=SRCALPHA)
     224        bgsurf.fill((255, 255, 255, fox_hud.BG_ALPHA))
     225        self._level_surface.blit(bgsurf,
     226                                 (self._clip_rect.left,
     227                                  self._clip_rect.top
     228                                  + fox_hud.TAIL_START
     229                                  - fox_hud.BG_MARGIN))
    209230
    210231        # Draw tails
    211232        # FIXME: Use correct tail icon
    212233        for tail in fox.tails:
    213             tail_pos = self._clip_rect.left + 8, self._clip_rect.top + constants.FoxHud.TAIL_POSITIONS[tail]
     234            tail_pos = self._clip_rect.left + 8, self._clip_rect.top + fox_hud.TAIL_POSITIONS[tail]
    214235            self._level_surface.blit(self._tail, tail_pos)
    215236
Note: See TracChangeset for help on using the changeset viewer.