Mercurial > skaapsteker
changeset 453:9c9df17b98a7
Add support for choosing a volume. A music to temple.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Sat, 09 Apr 2011 20:42:48 +0200 |
parents | 2e9e24d0e594 |
children | 95527fd29872 |
files | data/levels/temple.json skaapsteker/level.py skaapsteker/sound.py |
diffstat | 3 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/data/levels/temple.json Sat Apr 09 20:24:49 2011 +0200 +++ b/data/levels/temple.json Sat Apr 09 20:42:48 2011 +0200 @@ -31,5 +31,9 @@ "doorways": { "starting": {"type": "StartingDoorway", "pos": [4, 16], "facing": "right"}, "to_temple_grounds": {"type": "Doorway", "pos": [17, 16], "facing": "left", "leadsto": "temple_grounds.starting"} + }, + "music" : { + "track" : "ambient japanese music 1.ogg", + "volume" : 1.0 } }
--- a/skaapsteker/level.py Sat Apr 09 20:24:49 2011 +0200 +++ b/skaapsteker/level.py Sat Apr 09 20:42:48 2011 +0200 @@ -70,7 +70,8 @@ self._background_music = None if 'music' in self.level_data: # soundsystem will call data.filepath - self._background_music = 'music/' + self.level_data['music'] + self._background_music = 'music/' + self.level_data['music'].get('track', '') + self._background_volume = self.level_data['music'].get('volume', 1.0) def build_backgrounds(self): self.backgrounds = [] @@ -92,7 +93,7 @@ def enter(self): if self._background_music: - self._soundsystem.play_background_music(self._background_music) + self._soundsystem.play_background_music(self._background_music, self._background_volume) def leave(self): pass
--- a/skaapsteker/sound.py Sat Apr 09 20:24:49 2011 +0200 +++ b/skaapsteker/sound.py Sat Apr 09 20:42:48 2011 +0200 @@ -24,11 +24,12 @@ self._sounds = {} - def play_background_music(self, track_name): + def play_background_music(self, track_name, volume=1.0): if self.sound_enabled: try: mixer.music.load(data.filepath(track_name)) mixer.music.play(-1) # Loop forever + mixer.music.set_volume(volume) except pygame.error: print 'Unable to load track'