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):
|
def obj_play(sounds, soundName, playerPos, objPos):
|
||||||
if playerPos - objPos > 9 or playerPos - objPos < -9:
|
if playerPos - objPos > 9 or playerPos - objPos < -9:
|
||||||
# The sound is out of range, so do nothing.
|
# The sound is out of range, so do nothing.
|
||||||
return
|
return None
|
||||||
distance = playerPos - objPos
|
distance = playerPos - objPos
|
||||||
angle = math.radians(distance * 5)
|
angle = math.radians(distance * 5)
|
||||||
left = math.sqrt(2)/2.0 * (math.cos(angle) - math.sin(angle))
|
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.
|
# attempt to stop sounds that go out of range.
|
||||||
if playerPos - objPos > 9 or playerPos - objPos < -9:
|
if playerPos - objPos > 9 or playerPos - objPos < -9:
|
||||||
obj_stop(x)
|
obj_stop(x)
|
||||||
return
|
return None
|
||||||
distance = playerPos - objPos
|
distance = playerPos - objPos
|
||||||
angle = math.radians(distance * 5)
|
angle = math.radians(distance * 5)
|
||||||
left = math.sqrt(2)/2.0 * (math.cos(angle) - math.sin(angle))
|
left = math.sqrt(2)/2.0 * (math.cos(angle) - math.sin(angle))
|
||||||
@ -207,13 +207,16 @@ def obj_update(x, playerPos, objPos):
|
|||||||
right *= -1
|
right *= -1
|
||||||
# Apply the position information to the channel
|
# Apply the position information to the channel
|
||||||
x.set_volume(left, right)
|
x.set_volume(left, right)
|
||||||
|
# return the channel
|
||||||
|
return x
|
||||||
|
|
||||||
def obj_stop(x):
|
def obj_stop(x):
|
||||||
# Tries to stop a playing object channel
|
# Tries to stop a playing object channel
|
||||||
try:
|
try:
|
||||||
x.stop()
|
x.stop()
|
||||||
|
return None
|
||||||
except:
|
except:
|
||||||
pass
|
return x
|
||||||
|
|
||||||
def play_random(sounds, soundName, pause = False, interrupt = False):
|
def play_random(sounds, soundName, pause = False, interrupt = False):
|
||||||
key = []
|
key = []
|
||||||
|
Loading…
Reference in New Issue
Block a user