changeset 446:4240854e59b0

Better death screen
author Stefano Rivera <stefano@rivera.za.net>
date Sat, 09 Apr 2011 19:58:06 +0200
parents 5c8d090dbeec
children 4bec05fed6c7
files skaapsteker/levelscene.py skaapsteker/widgets/bubble.py
diffstat 2 files changed, 15 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/skaapsteker/levelscene.py	Sat Apr 09 19:52:44 2011 +0200
+++ b/skaapsteker/levelscene.py	Sat Apr 09 19:58:06 2011 +0200
@@ -37,6 +37,17 @@
         self._world = physics.World(self._level_surface.get_rect())
         self._paused = False
 
+        # Prepare a Surface for displaying when Dead
+        self._dead_overlay = pygame.Surface(constants.SCREEN, flags=SRCALPHA)
+        self._dead_overlay.fill((255, 255, 255, 128))
+        death_text_pos = constants.SCREEN[0] / 2, constants.SCREEN[1] / 2
+        death_text = Text("You've died.", death_text_pos, size=24)
+        death_text.rect.move_ip(-death_text.rect.width / 2, -death_text.rect.height)
+        death_text.draw(self._dead_overlay)
+        death_text = Text("Press Escape to exit or Return to restart the level.", death_text_pos)
+        death_text.rect.move_ip(-death_text.rect.width / 2, 0)
+        death_text.draw(self._dead_overlay)
+
         # Helper images for hud
         self._tofu = data.load_image('icons/tofu.png')
         self._scroll = data.load_image('icons/haiku-scroll.png')
@@ -190,9 +201,7 @@
             paused_text.draw(self._level_surface)
 
         if self._player_dead:
-            death_text_pos = self._clip_rect.centerx - 100, self._clip_rect.centery - 100
-            death_text = Text("You've died.\nPress Escape to exit or Return to restart the level", death_text_pos)
-            death_text.draw(self._level_surface)
+            self._level_surface.blit(self._dead_overlay, self._clip_rect)
 
         screen_surface.blit(self._level_surface, (0, 0), self._clip_rect)
 
--- a/skaapsteker/widgets/bubble.py	Sat Apr 09 19:52:44 2011 +0200
+++ b/skaapsteker/widgets/bubble.py	Sat Apr 09 19:58:06 2011 +0200
@@ -4,11 +4,12 @@
 import pygame.draw
 import pygame
 
+from . import Widget
 from ..engine import OpenDialog, CloseDialog
 from .text import Text, TextChoice
 
 
-class NotificationWidget(object):
+class NotificationWidget(Widget):
 
     def __init__(self, text):
         pos = pygame.Rect((0, 0), (300, 1))
@@ -38,7 +39,7 @@
 
 
 
-class DialogueWidget(object):
+class DialogueWidget(Widget):
 
     def __init__(self, npc):
         self.npc = npc