source: nagslang/screens/playerdied.py@ 363:3dd08e18580f

Last change on this file since 363:3dd08e18580f was 285:ef4f6375c0b5, checked in by Neil Muller <drnlmuller@…>, 8 years ago

Basic death

File size: 958 bytes
Line 
1"""Display a menu screen."""
2
3import pygame
4
5from nagslang.screens.base import Screen
6from nagslang.events import ScreenChange
7from nagslang.widgets.text import TextWidget, MultiLineWidget
8
9
10class PlayerDiedScreen(Screen):
11 def setup(self):
12 # Position is hacked later
13 self.widgets = [
14 TextWidget((10, 10), 'You Died!', fontsize=20),
15 TextWidget((40, 70), 'Press escape to return to the menu.'),
16 MultiLineWidget((60, 120), self.world.get_formatted_stats()),
17 ]
18
19 def handle_event(self, ev):
20 if ev.type == pygame.locals.KEYDOWN:
21 if ev.key == pygame.locals.K_ESCAPE:
22 self.world.protagonist.reset()
23 self.world.protagonist.set_position((350, 300))
24 ScreenChange.post('menu')
25
26 def render(self, surface):
27 surface.fill(pygame.color.Color(255, 255, 255))
28 for widget in self.widgets:
29 widget.draw(surface)
Note: See TracBrowser for help on using the repository browser.