comparison gamelib/helpscreen.py @ 390:2bcfccb8288e

Make help screen use goal from the level
author Neil Muller <drnlmuller@gmail.com>
date Thu, 29 Oct 2009 21:06:44 +0000
parents cdfeef53d6f1
children 263dea6d226b
comparison
equal deleted inserted replaced
389:463802281182 390:2bcfccb8288e
17 17
18 Game mechanics: 18 Game mechanics:
19 19
20 You lose if you end a night with no chickens left. 20 You lose if you end a night with no chickens left.
21 21
22 Depending on the game length you select, you win if you survive for two weeks,
23 three months or until you have chopped down all the trees in the forest and
24 caused the complete extinction of the fox population.
25
26 Chickens only lay eggs in henhouses, and must stay on the egg for 2 days to 22 Chickens only lay eggs in henhouses, and must stay on the egg for 2 days to
27 hatch a new chicken. Chickens that hatch in already full henhouses are 23 hatch a new chicken. Chickens that hatch in already full henhouses are
28 moved to just outside. If there is no space outside, they die immediately 24 moved to just outside. If there is no space outside, they die immediately
29 from overcrowding. 25 from overcrowding.
30 """ % constants.NAME 26 """ % constants.NAME
31 27
32 def make_help_screen(): 28 LEVEL_TEXT="""The currently selected level is %(name)s
29
30 The goal is:
31 %(goal)s
32 """
33
34 def make_help_screen(level):
33 """Create a main menu""" 35 """Create a main menu"""
34 help_screen = HelpScreen(width=600) 36 help_screen = HelpScreen(level, width=600)
35 37
36 c = HelpContainer(align=0, valign=0) 38 c = HelpContainer(align=0, valign=0)
37 c.add(help_screen, 0, 0) 39 c.add(help_screen, 0, 0)
38 40
39 return c 41 return c
44 splash = imagecache.load_image("images/splash.png", ["lighten_most"]) 46 splash = imagecache.load_image("images/splash.png", ["lighten_most"])
45 pygame.display.get_surface().blit(splash, (0, 0)) 47 pygame.display.get_surface().blit(splash, (0, 0))
46 gui.Container.paint(self, s) 48 gui.Container.paint(self, s)
47 49
48 class HelpScreen(gui.Document): 50 class HelpScreen(gui.Document):
49 def __init__(self, **params): 51 def __init__(self, level, **params):
50 gui.Document.__init__(self, **params) 52 gui.Document.__init__(self, **params)
51 53
52 def done_pressed(): 54 def done_pressed():
53 pygame.event.post(engine.GO_MAIN_MENU) 55 pygame.event.post(engine.GO_MAIN_MENU)
54 56
55 done_button = gui.Button("Return to Main Menu") 57 done_button = gui.Button("Return to Main Menu")
56 done_button.connect(gui.CLICK, done_pressed) 58 done_button.connect(gui.CLICK, done_pressed)
57 59
58 space = self.style.font.size(" ") 60 space = self.style.font.size(" ")
59 61
60 for paragraph in HELP.split('\n\n'): 62 full_text = HELP + '\n\n' + LEVEL_TEXT % {
63 'name' : level.level_name,
64 'goal' : level.goal
65 }
66
67 for paragraph in full_text.split('\n\n'):
61 self.block(align=-1) 68 self.block(align=-1)
62 for word in paragraph.split(): 69 for word in paragraph.split():
63 self.add(gui.Label(word)) 70 self.add(gui.Label(word))
64 self.space(space) 71 self.space(space)
65 self.br(space[1]) 72 self.br(space[1])