Hook the introduction into the menus
[naja.git] / naja / scenes / howto.py
1 """
2 Howto scene.
3 """
4
5 import pygame.locals as pgl
6
7 from naja.constants import KEYS
8 from naja.events import SceneChangeEvent
9 from naja.scenes.scene import Scene
10 from naja.widgets.text import TextWidget, TextBoxWidget
11
12
13 class HowtoScene(Scene):
14     """
15     Tell the player what to do.
16     """
17
18     def __init__(self, state):
19         super(HowtoScene, self).__init__(state)
20         self.add(TextWidget(
21             (200, 4), 'How To Play the Game', fontsize=32,
22             colour='white'))
23         self.add(TextBoxWidget(
24             (10, 50), '\n'.join([
25                 "You are a robot, frantically trying to set the correct "
26                 "bits to gain points for reasons that are unlikely ever "
27                 "to become clear.",
28                 "",
29                 "You have 8 bits. Four bits control the directions "
30                 "you can move in {NORTH,SOUTH,EAST,WEST}, 3 allow you "
31                 "to unlock actions {RED,GREEN,BLUE} and the "
32                 "last, the Most Significant Bit {MSB}, makes everything "
33                 "work better.",
34                 "",
35                 "MOVEMENT",
36                 "",
37                 "During Movement, you can explore the board and learn about "
38                 "the available tiles. Tiles you can legally move onto are "
39                 "highlighted. It's always possible to stay in place.",
40                 "",
41                 "ACTIONS",
42                 "",
43                 "After moving, you must select an action. Some actions "
44                 "require the correct bits to be set before they can be "
45                 "selected. After the action, the tile will be replaced "
46                 "(except in puzzle mode).",
47                 "",
48                 "Some actions cost health {HEALTH}. If you run out of "
49                 "health {HEALTH}, you lose.",
50                 "",
51                 "Some actions gain you points {WINTOKEN}. Once you have "
52                 "enough points, you win the game.",
53                 "",
54                 "Some tiles have a countdown timer {COUNTDOWN}. This "
55                 "indicates the number of turns left before something "
56                 "happens. The timer moves faster as the deadline approaches.",
57                 "",
58                 "Press ESC to return to the menu.",
59             ]), fontsize=32,
60             colour='white', padding=1, border=1,
61             bg_colour='black', border_colour='black',
62             box_width=740, view_port=(780, 540)))
63
64     def handle_scene_event(self, ev):
65         from naja.scenes.introduction import IntroductionScene
66         if ev.type == pgl.KEYDOWN and ev.key in KEYS.QUIT:
67             SceneChangeEvent.post(IntroductionScene)
68             return