Mercurial > pyntnclick
comparison gamelib/endscreen.py @ 607:f2b1ddcc4986 pyntnclick
Make menu and endscreen work.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Sat, 11 Feb 2012 20:34:23 +0200 |
parents | 2d2ea51b73ad |
children | a25cd1c6335a |
comparison
equal
deleted
inserted
replaced
606:5d62644288eb | 607:f2b1ddcc4986 |
---|---|
1 # endscreen.py | 1 # endscreen.py |
2 # Copyright Boomslang team, 2010 (see COPYING File) | 2 # Copyright Boomslang team, 2010 (see COPYING File) |
3 # Victory screen for the game | 3 # Victory screen for the game |
4 | 4 |
5 from albow.screen import Screen | 5 import pygame.event |
6 | 6 from pygame.locals import QUIT |
7 from pyntnclick.widgets import BoomImageButton | 7 from pyntnclick.engine import Screen |
8 | 8 from pyntnclick.widgets.imagebutton import ImageButtonWidget |
9 | |
10 class EndImageButton(BoomImageButton): | |
11 | |
12 FOLDER = 'won' | |
13 | 9 |
14 | 10 |
15 class EndScreen(Screen): | 11 class EndScreen(Screen): |
16 def __init__(self, shell, game_description): | 12 def setup(self): |
17 Screen.__init__(self, shell) | 13 self._background = self.resource.get_image(('won', 'won.png')) |
18 self.background = game_description.resource.get_image( | 14 self.add_image_button((26, 500), ('won', 'menu.png'), self.main_menu) |
19 ('won', 'won.png')) | 15 self.add_image_button((250, 500), ('won', 'quit.png'), self.quit) |
20 self._menu_button = EndImageButton('menu.png', 26, 500, | |
21 action=self.main_menu) | |
22 self._quit_button = EndImageButton('quit.png', 250, 500, | |
23 action=shell.quit) | |
24 self.add(self._menu_button) | |
25 self.add(self._quit_button) | |
26 | 16 |
27 def draw(self, surface): | 17 def add_image_button(self, rect, image_name, callback): |
28 surface.blit(self.background, (0, 0)) | 18 image = self.resource.get_image(image_name) |
29 self._menu_button.draw(surface) | 19 widget = ImageButtonWidget(rect, image) |
30 self._quit_button.draw(surface) | 20 widget.add_callback('clicked', callback) |
21 self.container.add(widget) | |
31 | 22 |
32 def main_menu(self): | 23 def draw_background(self): |
33 self.shell.show_screen(self.shell.menu_screen) | 24 self.surface.blit(self._background, self.surface.get_rect()) |
25 | |
26 def main_menu(self, ev, widget): | |
27 from gamelib.menu import MenuScreen | |
28 self.change_screen(MenuScreen(self.game_description)) | |
29 | |
30 def quit(self, ev, widget): | |
31 pygame.event.post(pygame.event.Event(QUIT)) |