5 import pygame.locals as pgl
7 from naja.constants import KEYS
8 from naja.scenes.scene import Scene
9 from naja.widgets.text import TextWidget
10 from naja.widgets.selector import SelectorWidget
11 from naja.events import QuitGameEvent
12 from naja.scenes.credits import CreditsScene
13 from naja.scenes.game import GameScene
14 from naja.events import SceneChangeEvent
17 class MenuScene(Scene):
18 def __init__(self, state):
19 super(MenuScene, self).__init__(state)
20 selector = SelectorWidget()
22 run_game = TextWidget((100, 100), 'Game', fontsize=32, colour='white')
23 run_game.add_callback('click',
24 lambda event: SceneChangeEvent.post(GameScene))
25 selector.add(run_game)
27 (100, 200), 'Credits', fontsize=32, colour='white')
28 credits.add_callback('click',
29 lambda event: SceneChangeEvent.post(CreditsScene))
31 quit = TextWidget((100, 300), 'Quit', fontsize=32, colour='white')
32 quit.add_callback('click', lambda event: QuitGameEvent.post())
35 def handle_scene_event(self, ev):
36 if ev.type == pgl.KEYDOWN:
37 if ev.key in KEYS.QUIT: