From: Stefano Rivera Date: Sat, 17 May 2014 13:57:29 +0000 (+0200) Subject: Musical menus X-Git-Tag: 0.1~96^2~10 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=1be3c4bdb77da69df48d6c75dc0a6842e2fcf379;p=naja.git Musical menus --- diff --git a/data/icons/robolock.ico b/data/icons/robolock.ico index eab34e6..2083c42 100644 Binary files a/data/icons/robolock.ico and b/data/icons/robolock.ico differ 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):