Mercurial > skaapsteker
diff skaapsteker/cutscene.py @ 262:de60329cfc9f
Factor out sound stuff
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Fri, 08 Apr 2011 11:29:37 +0200 |
parents | 8c0c132b422f |
children | 62b98bea56bf |
line wrap: on
line diff
--- a/skaapsteker/cutscene.py Fri Apr 08 10:40:16 2011 +0200 +++ b/skaapsteker/cutscene.py Fri Apr 08 11:29:37 2011 +0200 @@ -9,15 +9,14 @@ from .widgets.text import Text, ButtonSet, TextButton, unindent_text class CutScene(Scene): - def __init__(self, game_state, text, background, music=None): - super(CutScene, self).__init__(game_state) + def __init__(self, game_state, soundsystem, text, background, music=None): + super(CutScene, self).__init__(game_state, soundsystem) self.background = data.load_image('backgrounds/' + background) self.start_time = pygame.time.get_ticks() self.run_time = 60000 # ms self._background_music = None - if music and pygame.mixer.get_init(): - self._background_music = data.filepath(music) + self._background_music = music text_widget = Text(text, pygame.Rect(20, 20, 800-40, 600-40), size=24, shadow='gray', wrap=True) @@ -56,15 +55,10 @@ def enter(self): if self._background_music: - pygame.mixer.music.load(self._background_music) - pygame.mixer.music.play(-1) - - def leave(self): - if self._background_music: - pygame.mixer.music.stop() + self._soundsystem.play_background_music(self._background_music) -def opening_cutscene(game_state): +def opening_cutscene(game_state, soundsystem): text = u""" Many moons ago, an evil nine-tailed kitsune, a fearsome fox god, ruled the land. @@ -82,4 +76,4 @@ The kitsune stole your tail. Now it’s time to get it back. """ text = unindent_text(text) - return CutScene(game_state, text, 'background_01_back.png') + return CutScene(game_state, soundsystem, text, 'background_01_back.png')