From 28d09374ba90a30225a4e23f9c41623104934102 Mon Sep 17 00:00:00 2001 From: David Sharpe Date: Sun, 18 May 2014 00:15:06 +0200 Subject: [PATCH] You can deal with comlications in untroduction. --- naja/scenes/dummygame.py | 3 +- naja/scenes/introduction.py | 61 +++++++++++++++++++++++++++++++++++-- 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/naja/scenes/dummygame.py b/naja/scenes/dummygame.py index 5111d05..077c07b 100644 --- a/naja/scenes/dummygame.py +++ b/naja/scenes/dummygame.py @@ -22,7 +22,7 @@ class DummyGameScene(Scene): if not state: game_state = GameState.new(max_health=4, wins_required=4) else: - game_state = state + game_state = GameState.load(state['data']) game = GameScene(game_state, play_sound=False) game_surface = pygame.surface.Surface(SCREEN) game.render(game_surface) @@ -38,3 +38,4 @@ class DummyGameScene(Scene): LoadGameEvent.post(None) SceneChangeEvent.post(MenuScene) return + diff --git a/naja/scenes/introduction.py b/naja/scenes/introduction.py index 95defaa..4081187 100644 --- a/naja/scenes/introduction.py +++ b/naja/scenes/introduction.py @@ -3,8 +3,9 @@ Load and save scenes. """ import pygame.locals as pgl +import pygame -from naja.constants import KEYS +from naja.constants import KEYS, SCREEN from naja.events import SceneChangeEvent, LoadGameEvent from naja.gamestate import GameState from naja.scenes.scene import Scene @@ -12,7 +13,10 @@ from naja.scenes.howto import HowtoScene from naja.widgets.image_box import ImageBox from naja.widgets.selector import SelectorWidget from naja.widgets.text import TextWidget - +from naja.widgets.text import TextBoxWidget +from naja.resources import resources +from naja.scenes.dummygame import DummyGameScene +from naja.widgets.image_box import PreRenderedImageBox class IntroductionScene(Scene): def __init__(self, state): @@ -44,7 +48,7 @@ class IntroductionScene(Scene): intro = TextWidget( (x_offset, y_offset), 'Introductory Level', colour='white', centre=True) - intro.add_callback('click', self.introduction_level) + intro.add_callback('click', self.introduction_to_screen_1) selector.add(intro) y_offset += 2*y_diff @@ -61,6 +65,57 @@ class IntroductionScene(Scene): LoadGameEvent.post(state=GameState.new(deck='introduction')) SceneChangeEvent.post(GameScene) + def introduction_to_screen_1(self, event): + 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.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 handle_scene_event(self, ev): if ev.type == pgl.KEYDOWN and ev.key in KEYS.QUIT: from naja.scenes.menu import MenuScene -- 2.34.1