Clean-up text on intro.
[naja.git] / naja / scenes / introduction.py
index 40811877808423b6958d0512871110963c290e25..dd161bb32f39411fae45982a519123c3b8b9a847 100644 (file)
@@ -5,7 +5,7 @@ Load and save scenes.
 import pygame.locals as pgl
 import pygame
 
 import pygame.locals as pgl
 import pygame
 
-from naja.constants import KEYS, SCREEN
+from naja.constants import KEYS, SCREEN, PALETTE
 from naja.events import SceneChangeEvent, LoadGameEvent
 from naja.gamestate import GameState
 from naja.scenes.scene import Scene
 from naja.events import SceneChangeEvent, LoadGameEvent
 from naja.gamestate import GameState
 from naja.scenes.scene import Scene
@@ -18,6 +18,7 @@ from naja.resources import resources
 from naja.scenes.dummygame import DummyGameScene
 from naja.widgets.image_box import PreRenderedImageBox
 
 from naja.scenes.dummygame import DummyGameScene
 from naja.widgets.image_box import PreRenderedImageBox
 
+
 class IntroductionScene(Scene):
     def __init__(self, state):
         super(IntroductionScene, self).__init__(state)
 class IntroductionScene(Scene):
     def __init__(self, state):
         super(IntroductionScene, self).__init__(state)
@@ -26,6 +27,8 @@ class IntroductionScene(Scene):
             (0, 0), "screens/splash.png")
         self.add(background)
 
             (0, 0), "screens/splash.png")
         self.add(background)
 
+        self.intro = 0
+
         selector = SelectorWidget()
         self.add(selector)
 
         selector = SelectorWidget()
         self.add(selector)
 
@@ -65,59 +68,108 @@ class IntroductionScene(Scene):
         LoadGameEvent.post(state=GameState.new(deck='introduction'))
         SceneChangeEvent.post(GameScene)
 
         LoadGameEvent.post(state=GameState.new(deck='introduction'))
         SceneChangeEvent.post(GameScene)
 
-    def introduction_to_screen_1(self, event):
+    def make_game_surface(self):
         self.container.widgets = []
         state = resources.get_json('tutorial/tutorial_screen_1.json')
         dummy_game = DummyGameScene(state)
         game_surface = pygame.surface.Surface(SCREEN)
         dummy_game.render(game_surface)
         self.add(PreRenderedImageBox((0, 0), game_surface))
         self.container.widgets = []
         state = resources.get_json('tutorial/tutorial_screen_1.json')
         dummy_game = DummyGameScene(state)
         game_surface = pygame.surface.Surface(SCREEN)
         dummy_game.render(game_surface)
         self.add(PreRenderedImageBox((0, 0), game_surface))
+        return game_surface
 
 
-        # self.add(TextBoxWidget(
-        #     (10, 50), '\n'.join([
-        #         "You are a robot, frantically trying to set the correct "
-        #         "bits to gain points for reasons that are unlikely ever "
-        #         "to become clear.",
-        #         "",
-        #         "You have 8 bits. Four bits control the directions "
-        #         "you can move in {NORTH,SOUTH,EAST,WEST}, 3 allow you "
-        #         "to unlock actions {RED,GREEN,BLUE} and the "
-        #         "last, the Most Significant Bit {MSB}, makes everything "
-        #         "work better.",
-        #         "",
-        #         "MOVEMENT",
-        #         "",
-        #         "During Movement, you can explore the board and learn about "
-        #         "the available tiles. Tiles you can legally move onto are "
-        #         "highlighted. It's always possible to stay in place.",
-        #         "",
-        #         "ACTIONS",
-        #         "",
-        #         "After moving, you must select an action. Some actions "
-        #         "require the correct bits to be set before they can be "
-        #         "selected. After the action, the tile will be replaced "
-        #         "(except in puzzle mode).",
-        #         "",
-        #         "Some actions cost health {HEALTH}. If you run out of "
-        #         "health {HEALTH}, you lose.",
-        #         "",
-        #         "Some actions gain you points {WINTOKEN}. Once you have "
-        #         "enough points, you win the game.",
-        #         "",
-        #         "Some tiles have a countdown timer {COUNTDOWN}. This "
-        #         "indicates the number of turns left before something "
-        #         "happens. The timer moves faster as the deadline approaches.",
-        #         "",
-        #         "Press ESC to return to the menu.",
-        #     ]), fontsize=32,
-        #     colour='white', padding=1, border=1,
-        #     bg_colour='black', border_colour='black',
-        #     box_width=740, view_port=(780, 540)))
-
-
+    def introduction_to_screen_1(self, event):
+        game_surface = self.make_game_surface()
+        self.intro = 1
+
+        self.add(TextBoxWidget(
+            (24, 72), '\n'.join([
+                "These are your robot's status bits. On the left we have"
+                " the Most Signiticant Bit (MSB, currently set), then the"
+                " Red (unset), Green (set) and Blue (set) key bits, and"
+                " finally the four bits which control movement options, of"
+                " which only left is set. You can only move in directions"
+                " which are set.",
+                "Enter to continue.",
+            ]), fontsize=32,
+            colour=PALETTE.GREEN, padding=12, border=8,
+            bg_colour=PALETTE.BLACK, border_colour=PALETTE.GREEN,
+            box_width=400, view_port=(500, 800)))
+
+        pygame.draw.rect(game_surface, PALETTE.GREEN, (0, 0, 480, 60), 8)
+
+    def introduction_to_screen_2(self, event):
+        game_surface = self.make_game_surface()
+        self.intro = 2
+
+        self.add(TextBoxWidget(
+            (24, 172), '\n'.join([
+                "These are your health and score. On the left we have four "
+                "health bits. The robot has taken one damage, so only three "
+                "are lit. The stars are points you have scored. Once you have "
+                "all of them you win the game! Total health and required "
+                "points vary according to the game. \n"
+                "Enter to continue.",
+            ]), fontsize=32,
+            colour=PALETTE.GREEN, padding=12, border=8,
+            bg_colour=PALETTE.BLACK, border_colour=PALETTE.GREEN,
+            box_width=400, view_port=(500, 800)))
+
+        pygame.draw.rect(game_surface, PALETTE.GREEN, (0, 540, 480, 60), 8)
+
+    def introduction_to_screen_3(self, event):
+        game_surface = self.make_game_surface()
+        self.intro = 3
+
+        self.add(TextBoxWidget(
+            (24, 132), '\n'.join([
+                "This text box describes the current game mode. The game is "
+                "divided into movements and actions, and each mode has "
+                "different options, shown here.",
+                "During movement, you can examine the entire board, but you "
+                "can only move to highlighted tiles (including the one you"
+                " are on). Actions come next ...",
+                "Enter to continue.",
+            ]), fontsize=32,
+            colour=PALETTE.GREEN, padding=12, border=8,
+            bg_colour=PALETTE.BLACK, border_colour=PALETTE.GREEN,
+            box_width=400, view_port=(500, 800)))
+
+        pygame.draw.rect(game_surface, PALETTE.GREEN, (488, 416, 304, 132), 8)
+
+    def introduction_to_screen_4(self, event):
+        game_surface = self.make_game_surface()
+        self.intro = 4
+
+        self.add(TextBoxWidget(
+            (24, 72), '\n'.join([
+                "This text box shows actions available on the tile. "
+                "Some actions have requirements and are only selectable if "
+                "you have the correct bits set (unavailable actions are "
+                "greyed out). Actions usually change the bits set on "
+                "your robot. This is often not beneficial.",
+                "Some actions have additional effects if the MSB is "
+                "set.",
+                "Enter to continue.",
+            ]), fontsize=32,
+            colour=PALETTE.GREEN, padding=12, border=8,
+            bg_colour=PALETTE.BLACK, border_colour=PALETTE.GREEN,
+            box_width=400, view_port=(500, 800)))
+
+        pygame.draw.rect(game_surface, PALETTE.GREEN, (488, 52, 304, 240), 8)
 
     def handle_scene_event(self, ev):
         if ev.type == pgl.KEYDOWN and ev.key in KEYS.QUIT:
             from naja.scenes.menu import MenuScene
             SceneChangeEvent.post(MenuScene)
             return
 
     def handle_scene_event(self, ev):
         if ev.type == pgl.KEYDOWN and ev.key in KEYS.QUIT:
             from naja.scenes.menu import MenuScene
             SceneChangeEvent.post(MenuScene)
             return
+        if ev.type == pgl.KEYDOWN and ev.key in KEYS.SELECT:
+            if 0 < self.intro < 5:
+                if self.intro == 1:
+                    self.introduction_to_screen_2(ev)
+                elif self.intro == 2:
+                    self.introduction_to_screen_3(ev)
+                elif self.intro == 3:
+                    self.introduction_to_screen_4(ev)
+                else:
+                    self.introduction_level(ev)
+            return