From 3fee41ef2a3153579d9a9c9fe2b81dfb90e17352 Mon Sep 17 00:00:00 2001 From: Neil Date: Sat, 17 May 2014 00:13:26 +0200 Subject: [PATCH] Espescially if it plays --- naja/constants.py | 8 ++++++++ naja/scenes/game.py | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/naja/constants.py b/naja/constants.py index 25def14..ae812f7 100644 --- a/naja/constants.py +++ b/naja/constants.py @@ -143,3 +143,11 @@ ACTION_GLYPHS = AttrDict({ 'MSB': 'glyphs/msb.png', 'NOTHING': 'glyphs/do_nothing.png', }) + +TUNES = [ + 'ants.ogg', + 'python.ogg', + 'death_on_a_b.ogg', + 'scape.ogg', + 'another_beek.ogg', + ] diff --git a/naja/scenes/game.py b/naja/scenes/game.py index 0e76f5f..c0b4b27 100644 --- a/naja/scenes/game.py +++ b/naja/scenes/game.py @@ -3,8 +3,9 @@ Gameboard scene. """ import pygame.locals as pgl +import random -from naja.constants import KEYS +from naja.constants import KEYS, TUNES from naja.events import SceneChangeEvent, finish_event from naja.options import options from naja.scenes.scene import Scene @@ -30,11 +31,14 @@ class GameScene(Scene): self.add(info) self.add(RobotWidget(state)) sound.play_sound('startup.ogg') + background_track = random.choice(TUNES) + sound.play_music(background_track, 0.25) def handle_scene_event(self, ev): from naja.scenes.menu import MenuScene if ev.type == pgl.KEYDOWN: if ev.key in KEYS.QUIT: + sound.stop() SceneChangeEvent.post(MenuScene) return if options.cheat_enabled: -- 2.34.1