changeset 566:ea9dd2b9186a pyntnclick

Hook up sound in gamelib/scenes.
author Simon Cross <hodgestar+bzr@gmail.com>
date Sat, 11 Feb 2012 15:05:18 +0200
parents 88cffe418201
children b84534a1bd2e
files gamelib/scenes/bridge.py gamelib/scenes/cryo.py gamelib/scenes/manual.py gamelib/scenes/mess.py
diffstat 4 files changed, 20 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/gamelib/scenes/bridge.py	Sat Feb 11 15:37:59 2012 +0200
+++ b/gamelib/scenes/bridge.py	Sat Feb 11 15:05:18 2012 +0200
@@ -5,12 +5,10 @@
 from pygame.colordict import THECOLORS
 from pygame.color import Color
 from pygame.rect import Rect
-from albow.music import change_playlist, get_music, PlayList
 from albow.resource import get_image
 
 from pyntnclick.cursor import CursorSprite
 from pyntnclick.state import Scene, Item, Thing, Result
-from pyntnclick.sound import get_current_playlist
 from pyntnclick.constants import DEBUG
 from pyntnclick.scenewidgets import (InteractNoImage, InteractRectUnion,
                                   InteractImage, InteractAnimated,
@@ -78,12 +76,13 @@
         self.add_thing(self.doctor)
 
     def enter(self):
-        pieces = [get_music(x, prefix='sounds') for x in self.MUSIC]
-        self.background_playlist = PlayList(pieces, random=True, repeat=True)
-        change_playlist(self.background_playlist)
+        pieces = [self.sound.get_music(x, prefix='sounds') for x in self.MUSIC]
+        self.background_playlist = self.sound.get_playlist(pieces, random=True,
+                                                           repeat=True)
+        self.sound.change_playlist(self.background_playlist)
 
     def leave(self):
-        change_playlist(None)
+        self.sound.change_playlist(None)
 
 
 class ToMap(Door):
@@ -600,12 +599,12 @@
         self._logs = [get_image(self.FOLDER, x) for x in self.LOGS]
 
     def enter(self):
-        self._scene_playlist = get_current_playlist()
-        change_playlist(None)
+        self._scene_playlist = self.sound.get_current_playlist()
+        self.sound.change_playlist(None)
         self.set_background()
 
     def leave(self):
-        change_playlist(self._scene_playlist)
+        self.sound.change_playlist(self._scene_playlist)
 
     def set_background(self):
         if self.get_data('tab') == 'alert':
--- a/gamelib/scenes/cryo.py	Sat Feb 11 15:37:59 2012 +0200
+++ b/gamelib/scenes/cryo.py	Sat Feb 11 15:05:18 2012 +0200
@@ -2,7 +2,6 @@
 
 import random
 
-from albow.music import change_playlist, get_music, PlayList
 from albow.resource import get_image
 
 from pyntnclick.cursor import CursorSprite
@@ -129,9 +128,10 @@
 
     def enter(self):
         # Setup music
-        pieces = [get_music(x, prefix='sounds') for x in self.MUSIC]
-        background_playlist = PlayList(pieces, random=True, repeat=True)
-        change_playlist(background_playlist)
+        pieces = [self.sound.get_music(x, prefix='sounds') for x in self.MUSIC]
+        background_playlist = self.sound.get_playlist(pieces, random=True,
+                                                      repeat=True)
+        self.sound.change_playlist(background_playlist)
         if self.get_data('greet'):
             self.set_data('greet', False)
             return make_jim_dialog(
@@ -146,7 +146,7 @@
 
     def leave(self):
         # Stop music
-        change_playlist(None)
+        self.sound.change_playlist(None)
 
 
 class CryoPipeBase(Thing):
--- a/gamelib/scenes/manual.py	Sat Feb 11 15:37:59 2012 +0200
+++ b/gamelib/scenes/manual.py	Sat Feb 11 15:05:18 2012 +0200
@@ -3,7 +3,6 @@
 from albow.music import change_playlist
 
 from pyntnclick.state import Scene, Thing
-from pyntnclick.sound import get_current_playlist
 from pyntnclick.scenewidgets import InteractNoImage, InteractImage
 
 
@@ -115,7 +114,7 @@
         self._scene_playlist = None
 
     def enter(self):
-        self._scene_playlist = get_current_playlist()
+        self._scene_playlist = self.sound.get_current_playlist()
         change_playlist(None)
 
     def leave(self):
--- a/gamelib/scenes/mess.py	Sat Feb 11 15:37:59 2012 +0200
+++ b/gamelib/scenes/mess.py	Sat Feb 11 15:05:18 2012 +0200
@@ -4,7 +4,6 @@
 
 from pyntnclick.state import Scene, Item, CloneableItem, Thing, Result
 from pyntnclick.cursor import CursorSprite
-from pyntnclick.sound import get_sound
 from pyntnclick import constants
 from pyntnclick.scenewidgets import (InteractNoImage, InteractImage,
                                   InteractImageRect, InteractAnimated,
@@ -257,7 +256,11 @@
         'anim_pos': -1,
         }
 
-    HISS = get_sound('boomslang.ogg')
+    HISS = 'boomslang.ogg'
+
+    def __init__(self, state):
+        super(Boomslang, self).__init__(state)
+        self.hiss = self.sound.get_sound(self.HISS)
 
     def is_interactive(self, tool=None):
         return False
@@ -274,7 +277,7 @@
         if randint(0, 30 * constants.FRAME_RATE) == 0:
             self.set_interact('snake')
             self.set_data('anim_pos', 0)
-            self.HISS.play()
+            self.hiss.play()
         return False