More work on the sound functions for object placement.
This commit is contained in:
parent
d456b8b3b3
commit
678af54346
@ -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 = []
|
||||
|
Loading…
Reference in New Issue
Block a user