Add welcome sound
[naja.git] / naja / scenes / game.py
1 """
2 Gameboard 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.board import BoardWidget
11 from naja.widgets.player_bits import PlayerBitsWidget
12 from naja.widgets.game_bits import GameBitsWidget
13 from naja.widgets.info_area import InfoAreaWidget
14 from naja.widgets.robot import RobotWidget
15 from naja.sound import sound
16
17
18 class GameScene(Scene):
19     """
20     Gameboard scene.
21     """
22
23     def __init__(self, state):
24         super(GameScene, self).__init__(state)
25         self.add(PlayerBitsWidget((0, 0), state))
26         info = InfoAreaWidget((480, 0), state)
27         self.add(BoardWidget((0, 60), state, info))
28         self.add(GameBitsWidget((0, 540), state))
29         self.add(info)
30         self.add(RobotWidget(state))
31         sound.play_sound('startup.ogg')
32
33     def handle_scene_event(self, ev):
34         from naja.scenes.menu import MenuScene
35         if ev.type == pgl.KEYDOWN and ev.key in KEYS.QUIT:
36             SceneChangeEvent.post(MenuScene)
37             return