Started work on sound positioning for objects.
This commit is contained in:
parent
e8bf4f9565
commit
34d89ca54b
@ -28,7 +28,7 @@ except ImportError:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
print("No other speech providers found.")
|
print("No other speech providers found.")
|
||||||
exit()
|
exit()
|
||||||
|
import math
|
||||||
import time
|
import time
|
||||||
|
|
||||||
localConfig = configparser.ConfigParser()
|
localConfig = configparser.ConfigParser()
|
||||||
@ -173,6 +173,25 @@ def cut_scene(sounds, soundName):
|
|||||||
pygame.mixer.stop()
|
pygame.mixer.stop()
|
||||||
pygame.event.pump()
|
pygame.event.pump()
|
||||||
|
|
||||||
|
def obj_play(sounds, soundName, playerPos, objPos):
|
||||||
|
# attempt to stop sounds that go out of range.
|
||||||
|
if playerPos - objPos > 9 or playerPos - objPos < -9:
|
||||||
|
# The sound is out of range, so do nothing.
|
||||||
|
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
|
||||||
|
# x is the channel for the sound
|
||||||
|
x = sounds[soundName].play()
|
||||||
|
# Apply the position information to the channel
|
||||||
|
x.set_volume(left, right)
|
||||||
|
# return the channel so that it can be used in the update and stop functions.
|
||||||
|
return x
|
||||||
|
|
||||||
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