Musical menus
authorStefano Rivera <stefano@rivera.za.net>
Sat, 17 May 2014 13:57:29 +0000 (15:57 +0200)
committerStefano Rivera <stefano@rivera.za.net>
Sat, 17 May 2014 13:57:29 +0000 (15:57 +0200)
data/icons/robolock.ico
naja/scenes/menu.py
naja/sound.py

index eab34e6864cf39681e0c1ed9ece529a5fd1e8e78..2083c428c87ab9b31db7afdc4caddf52ad3bc2b3 100644 (file)
Binary files a/data/icons/robolock.ico and b/data/icons/robolock.ico differ
index d1812c5b88c52e6d7e957245c35ae8497bf475fb..4dde093a9a12ecff4faf807cb10c4e967115a5ca 100644 (file)
@@ -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)
index 2d61974a9bbc10dac235b41b236bc3a2a1238945..ec6953fb021a389a87abf5c8168f9c33e8873afa 100644 (file)
@@ -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):