Changeset 243:46707efbb3a5 for nagslang


Ignore:
Timestamp:
Sep 4, 2013, 8:25:54 PM (7 years ago)
Author:
David Sharpe
Branch:
default
Message:

Added health bar to main screen.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/screens/area.py

    r211 r243  
    175175            if overlay.is_visible():
    176176                overlay.render(surface, render_rect.topleft)
     177        self.render_health_bar(surface)
    177178
    178179    def tick_protagonist(self):
     
    184185        for drawable in self._drawables:
    185186            drawable.animate()
     187
    186188        super(AreaScreen, self).tick(seconds)
     189
     190    def render_health_bar(self, surface, health_as_percentage=50,
     191                         health_type='human'):
     192        rect = pygame.Rect(50, 500, 110, 50)
     193        pygame.draw.rect(surface,  pygame.color.THECOLORS['white'],
     194                         rect, 0)
     195        if health_type is 'human':
     196            health_colour = pygame.color.THECOLORS['red']
     197        else:
     198            health_colour = pygame.color.THECOLORS['purple']
     199        rect = pygame.Rect(55, 505, health_as_percentage, 40)
     200        pygame.draw.rect(surface,  health_colour,
     201                         rect, 0)
Note: See TracChangeset for help on using the changeset viewer.