Changeset 453:9c9df17b98a7


Ignore:
Timestamp:
04/09/11 18:42:48 (12 years ago)
Author:
Simon Cross <hodgestar@…>
Branch:
default
Phase:
public
Rebase:
35363430393630643964303932393366663131646630653962343939393239626135393838363230
Message:

Add support for choosing a volume. A music to temple.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • data/levels/temple.json

    r394 r453  
    3232        "starting": {"type": "StartingDoorway", "pos": [4, 16], "facing": "right"},
    3333        "to_temple_grounds": {"type": "Doorway", "pos": [17, 16], "facing": "left", "leadsto": "temple_grounds.starting"}
     34    },
     35    "music" : {
     36        "track" : "ambient japanese music 1.ogg",
     37        "volume" : 1.0
    3438    }
    3539}
  • skaapsteker/level.py

    r428 r453  
    7171        if 'music' in self.level_data:
    7272            # soundsystem will call data.filepath
    73             self._background_music = 'music/' + self.level_data['music']
     73            self._background_music = 'music/' + self.level_data['music'].get('track', '')
     74            self._background_volume = self.level_data['music'].get('volume', 1.0)
    7475
    7576    def build_backgrounds(self):
     
    9394    def enter(self):
    9495        if self._background_music:
    95             self._soundsystem.play_background_music(self._background_music)
     96            self._soundsystem.play_background_music(self._background_music, self._background_volume)
    9697
    9798    def leave(self):
  • skaapsteker/sound.py

    r263 r453  
    2525
    2626
    27     def play_background_music(self, track_name):
     27    def play_background_music(self, track_name, volume=1.0):
    2828        if self.sound_enabled:
    2929            try:
    3030                mixer.music.load(data.filepath(track_name))
    3131                mixer.music.play(-1)  # Loop forever
     32                mixer.music.set_volume(volume)
    3233            except pygame.error:
    3334                print 'Unable to load track'
Note: See TracChangeset for help on using the changeset viewer.