Added the rest of the object management functions, hopefully.
This commit is contained in:
parent
34d89ca54b
commit
c5c32943e2
@ -174,7 +174,6 @@ def cut_scene(sounds, soundName):
|
|||||||
pygame.event.pump()
|
pygame.event.pump()
|
||||||
|
|
||||||
def obj_play(sounds, soundName, playerPos, objPos):
|
def obj_play(sounds, soundName, playerPos, objPos):
|
||||||
# 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:
|
||||||
# The sound is out of range, so do nothing.
|
# The sound is out of range, so do nothing.
|
||||||
return
|
return
|
||||||
@ -186,12 +185,34 @@ def obj_play(sounds, soundName, playerPos, objPos):
|
|||||||
if right < 0:
|
if right < 0:
|
||||||
right *= -1
|
right *= -1
|
||||||
# x is the channel for the sound
|
# x is the channel for the sound
|
||||||
x = sounds[soundName].play()
|
x = sounds[soundName].play(-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 so that it can be used in the update and stop functions.
|
# return the channel so that it can be used in the update and stop functions.
|
||||||
return x
|
return x
|
||||||
|
|
||||||
|
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
|
||||||
|
angle = math.radians(distance * 5)
|
||||||
|
left = math.sqrt(2)/2.0 * (math.cos(angle) - math.sin(angle))
|
||||||
|
right = math.sqrt(2)/2.0 * (math.cos(angle) + math.sin(angle))
|
||||||
|
if left < 0:
|
||||||
|
left *= -1
|
||||||
|
if right < 0:
|
||||||
|
right *= -1
|
||||||
|
# Apply the position information to the channel
|
||||||
|
x.set_volume(left, right)
|
||||||
|
|
||||||
|
def obj_stop(x):
|
||||||
|
# Tries to stop a playing object channel
|
||||||
|
try:
|
||||||
|
x.stop()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
def play_random(sounds, soundName, pause = False, interrupt = False):
|
def play_random(sounds, soundName, pause = False, interrupt = False):
|
||||||
key = []
|
key = []
|
||||||
for i in sounds.keys():
|
for i in sounds.keys():
|
||||||
|
Loading…
Reference in New Issue
Block a user