5 import pygame.locals as pgl
8 from naja.constants import KEYS, SCREEN
9 from naja.events import SceneChangeEvent, LoadGameEvent
10 from naja.gamestate import GameState
11 from naja.scenes.scene import Scene
12 from naja.scenes.howto import HowtoScene
13 from naja.widgets.image_box import ImageBox
14 from naja.widgets.selector import SelectorWidget
15 from naja.widgets.text import TextWidget
16 from naja.widgets.text import TextBoxWidget
17 from naja.resources import resources
18 from naja.scenes.dummygame import DummyGameScene
19 from naja.widgets.image_box import PreRenderedImageBox
21 class IntroductionScene(Scene):
22 def __init__(self, state):
23 super(IntroductionScene, self).__init__(state)
25 background = ImageBox(
26 (0, 0), "screens/splash.png")
29 selector = SelectorWidget()
32 y_offset, y_diff = 270, 40
37 (x_offset, y_offset), 'Getting started', colour='white',
43 (x_offset, y_offset), 'How to play', colour='white', centre=True)
44 howto.add_callback('click', self.howto_scene)
49 (x_offset, y_offset), 'Introductory Level', colour='white',
51 intro.add_callback('click', self.introduction_to_screen_1)
56 (x_offset, y_offset), 'Press ESC to return to the main menu.',
57 colour='white', centre=True)
60 def howto_scene(self, event):
61 SceneChangeEvent.post(HowtoScene)
63 def introduction_level(self, event):
64 from naja.scenes.game import GameScene
65 LoadGameEvent.post(state=GameState.new(deck='introduction'))
66 SceneChangeEvent.post(GameScene)
68 def introduction_to_screen_1(self, event):
69 self.container.widgets = []
70 state = resources.get_json('tutorial/tutorial_screen_1.json')
71 dummy_game = DummyGameScene(state)
72 game_surface = pygame.surface.Surface(SCREEN)
73 dummy_game.render(game_surface)
74 self.add(PreRenderedImageBox((0, 0), game_surface))
76 # self.add(TextBoxWidget(
77 # (10, 50), '\n'.join([
78 # "You are a robot, frantically trying to set the correct "
79 # "bits to gain points for reasons that are unlikely ever "
82 # "You have 8 bits. Four bits control the directions "
83 # "you can move in {NORTH,SOUTH,EAST,WEST}, 3 allow you "
84 # "to unlock actions {RED,GREEN,BLUE} and the "
85 # "last, the Most Significant Bit {MSB}, makes everything "
90 # "During Movement, you can explore the board and learn about "
91 # "the available tiles. Tiles you can legally move onto are "
92 # "highlighted. It's always possible to stay in place.",
96 # "After moving, you must select an action. Some actions "
97 # "require the correct bits to be set before they can be "
98 # "selected. After the action, the tile will be replaced "
99 # "(except in puzzle mode).",
101 # "Some actions cost health {HEALTH}. If you run out of "
102 # "health {HEALTH}, you lose.",
104 # "Some actions gain you points {WINTOKEN}. Once you have "
105 # "enough points, you win the game.",
107 # "Some tiles have a countdown timer {COUNTDOWN}. This "
108 # "indicates the number of turns left before something "
109 # "happens. The timer moves faster as the deadline approaches.",
111 # "Press ESC to return to the menu.",
113 # colour='white', padding=1, border=1,
114 # bg_colour='black', border_colour='black',
115 # box_width=740, view_port=(780, 540)))
119 def handle_scene_event(self, ev):
120 if ev.type == pgl.KEYDOWN and ev.key in KEYS.QUIT:
121 from naja.scenes.menu import MenuScene
122 SceneChangeEvent.post(MenuScene)