diff pytouhou/game/game.py @ 321:61adb5453e46

Implement music playback.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 13 Jun 2012 15:29:43 +0200
parents 1a4ffdda8735
children 13201d90bb22
line wrap: on
line diff
--- a/pytouhou/game/game.py
+++ b/pytouhou/game/game.py
@@ -102,6 +102,14 @@ class Game(object):
             self.difficulty = self.difficulty_max
 
 
+    def change_music(self, track):
+        #TODO: don’t crash if the track has already be played.
+        bgm = self.bgms[track]
+        if bgm:
+            self.music.queue(bgm)
+            self.music.next()
+
+
     def enable_spellcard_effect(self):
         self.spellcard_effect = Effect((-32., -16.), 0,
                                        self.spellcard_effect_anm_wrapper) #TODO: find why this offset is necessary.