From 678af543466939151753d7e4b0a3802990cd1c36 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Wed, 9 Sep 2020 20:55:40 -0400 Subject: [PATCH] More work on the sound functions for object placement. --- libstormgames.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libstormgames.py b/libstormgames.py index 737ba74..817a258 100755 --- a/libstormgames.py +++ b/libstormgames.py @@ -176,7 +176,7 @@ def cut_scene(sounds, soundName): def obj_play(sounds, soundName, playerPos, objPos): if playerPos - objPos > 9 or playerPos - objPos < -9: # The sound is out of range, so do nothing. - return + return None distance = playerPos - objPos angle = math.radians(distance * 5) left = math.sqrt(2)/2.0 * (math.cos(angle) - math.sin(angle)) @@ -196,7 +196,7 @@ def obj_update(x, playerPos, objPos): # attempt to stop sounds that go out of range. if playerPos - objPos > 9 or playerPos - objPos < -9: obj_stop(x) - return + return None distance = playerPos - objPos angle = math.radians(distance * 5) left = math.sqrt(2)/2.0 * (math.cos(angle) - math.sin(angle)) @@ -207,13 +207,16 @@ def obj_update(x, playerPos, objPos): right *= -1 # Apply the position information to the channel x.set_volume(left, right) + # return the channel + return x def obj_stop(x): # Tries to stop a playing object channel try: x.stop() + return None except: - pass + return x def play_random(sounds, soundName, pause = False, interrupt = False): key = []