From 1be3c4bdb77da69df48d6c75dc0a6842e2fcf379 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sat, 17 May 2014 15:57:29 +0200 Subject: [PATCH] Musical menus --- data/icons/robolock.ico | Bin 873614 -> 874118 bytes naja/scenes/menu.py | 3 +++ naja/sound.py | 7 ++++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/data/icons/robolock.ico b/data/icons/robolock.ico index eab34e6864cf39681e0c1ed9ece529a5fd1e8e78..2083c428c87ab9b31db7afdc4caddf52ad3bc2b3 100644 GIT binary patch delta 634 zcmY+ByGjE=6o&uZ#9LIz2n(x32!a@_0-~k%lENiUqXUA7r1Al5cB6Q~!p6czG=&k2 zT1W~jkwvC4L5qMsf&q(w79xo2nZ0!I|Dqf=}0C6J45-CXOs}-mw@GS9ocM{-wxd8V!v@DFp-ZToetv7L8?8> z_k#MuB(j7WM6I;8cMxB+>#o5q7Oa%Z>Y-!?V{W8Vj9HQX=eL-M{8DbnNDICZ_zi;@ zc`lhn<)l-bu2PzD`nk&t%O=BRsTpOEq<)eQ3r06mg)4Yjh9e2d%Yp{<17e=bXi|f7 z;g_mNy&kk7Nd?j@ZYwXlJFevVMuvPnSD7vkoK$>maGML(@9Uq<^E`N_4ex-?>pv(v z{9c?VycD1C=04-S*uooH_`m}`afB~S!E)LQpsm*$TeXIE zRcq)APW3fW$Xu>wwCdbgp;X<87uvT*XJbU1Xd{%}L39#bM1trhdiFQp6OP>yeR;2Q7no8 diff --git a/naja/scenes/menu.py b/naja/scenes/menu.py index d1812c5..4dde093 100644 --- a/naja/scenes/menu.py +++ b/naja/scenes/menu.py @@ -16,6 +16,7 @@ from naja.scenes.new_game import NewGameScene from naja.widgets.selector import SelectorWidget from naja.widgets.text import TextWidget from naja.widgets.image_box import ImageBox +from naja.sound import sound class MenuScene(Scene): @@ -81,6 +82,8 @@ class MenuScene(Scene): selector.add(quit) self.konami = [] + if not sound.playing_music: + sound.play_music('scape.ogg', 0.25) def scene_callback(self, scene_class): return lambda event: SceneChangeEvent.post(scene_class) diff --git a/naja/sound.py b/naja/sound.py index 2d61974..ec6953f 100644 --- a/naja/sound.py +++ b/naja/sound.py @@ -13,7 +13,7 @@ from naja.constants import ( class DummySound(object): def init(self): - pass + self.playing_music = False def play_sound(self, name, volume=DEFAULT_SOUND_VOLUME, foreground=False): pass @@ -34,6 +34,7 @@ class DummySound(object): class PygameSound(object): def __init__(self): self._sounds = {} + self.playing_music = False def init(self): mixer.init(FREQ, BITSIZE, CHANNELS, BUFFER) @@ -64,16 +65,20 @@ class PygameSound(object): mixer.music.load(track_name) mixer.music.set_volume(volume) mixer.music.play(-1) # loop sound + self.playing_music = True def pause_music(self): mixer.music.pause() + self.playing_music = False def unpause_music(self): mixer.music.unpause() + self.playing_music = True def stop(self): mixer.fadeout(1000) mixer.music.stop() + self.playing_music = False class SoundProxy(object): -- 2.34.1