Mercurial > boomslang
comparison gamelib/menu.py @ 599:2d2ea51b73ad pyntnclick
Move menu.py and endscreen.py to gamelib. Add default versions for new games
author | Neil Muller <neil@dip.sun.ac.za> |
---|---|
date | Sat, 11 Feb 2012 18:46:19 +0200 |
parents | pyntnclick/menu.py@f20d211d2c91 |
children | fabce47e542f |
comparison
equal
deleted
inserted
replaced
598:c1b5e982809b | 599:2d2ea51b73ad |
---|---|
1 # menu.py | |
2 # Copyright Boomslang team, 2010 (see COPYING File) | |
3 # Main menu for the game | |
4 | |
5 from albow.screen import Screen | |
6 | |
7 from pyntnclick.widgets import BoomImageButton | |
8 | |
9 | |
10 class SplashButton(BoomImageButton): | |
11 | |
12 FOLDER = 'splash' | |
13 | |
14 | |
15 class MenuScreen(Screen): | |
16 def __init__(self, shell, game_description): | |
17 Screen.__init__(self, shell) | |
18 self._background = game_description.resource.get_image( | |
19 ('splash', 'splash.png')) | |
20 self._start_button = SplashButton('play.png', 16, 523, self.start) | |
21 self._resume_button = SplashButton('resume.png', 256, 523, self.resume, | |
22 enable=self.check_running) | |
23 self._quit_button = SplashButton('quit.png', 580, 523, shell.quit) | |
24 self.add(self._start_button) | |
25 self.add(self._resume_button) | |
26 self.add(self._quit_button) | |
27 | |
28 def draw(self, surface): | |
29 surface.blit(self._background, (0, 0)) | |
30 self._start_button.draw(surface) | |
31 self._resume_button.draw(surface) | |
32 self._quit_button.draw(surface) | |
33 | |
34 def start(self): | |
35 self.shell.game_screen.start_game() | |
36 self.shell.show_screen(self.shell.game_screen) | |
37 | |
38 def check_running(self): | |
39 return self.shell.game_screen.running | |
40 | |
41 def resume(self): | |
42 if self.shell.game_screen.running: | |
43 self.shell.show_screen(self.shell.game_screen) |