diff nagslang/screens/area.py @ 243:46707efbb3a5

Added health bar to main screen.
author David Sharpe
date Wed, 04 Sep 2013 22:25:54 +0200
parents 434b5a3aaaff
children 93a20b51963f
line wrap: on
line diff
--- a/nagslang/screens/area.py	Wed Sep 04 20:20:13 2013 +0200
+++ b/nagslang/screens/area.py	Wed Sep 04 22:25:54 2013 +0200
@@ -174,6 +174,7 @@
         for overlay in self._level.overlay_drawables:
             if overlay.is_visible():
                 overlay.render(surface, render_rect.topleft)
+        self.render_health_bar(surface)
 
     def tick_protagonist(self):
         dx, dy = self.keys.get_direction()
@@ -183,4 +184,18 @@
         self.tick_protagonist()
         for drawable in self._drawables:
             drawable.animate()
+
         super(AreaScreen, self).tick(seconds)
+
+    def render_health_bar(self, surface, health_as_percentage=50,
+                         health_type='human'):
+        rect = pygame.Rect(50, 500, 110, 50)
+        pygame.draw.rect(surface,  pygame.color.THECOLORS['white'],
+                         rect, 0)
+        if health_type is 'human':
+            health_colour = pygame.color.THECOLORS['red']
+        else:
+            health_colour = pygame.color.THECOLORS['purple']
+        rect = pygame.Rect(55, 505, health_as_percentage, 40)
+        pygame.draw.rect(surface,  health_colour,
+                         rect, 0)
\ No newline at end of file