Small update to object positioning.
This commit is contained in:
parent
84a722bb8e
commit
37aa764d68
@ -178,13 +178,15 @@ def obj_play(sounds, soundName, playerPos, objPos):
|
|||||||
# The sound is out of range, so do nothing.
|
# The sound is out of range, so do nothing.
|
||||||
return None
|
return None
|
||||||
distance = playerPos - objPos
|
distance = playerPos - objPos
|
||||||
angle = math.radians(distance * 5)
|
if distance == 0:
|
||||||
left = math.sqrt(2)/2.0 * (math.cos(angle) + math.sin(angle))
|
left = 0.9
|
||||||
right = math.sqrt(2)/2.0 * (math.cos(angle) - math.sin(angle))
|
right = 0.9
|
||||||
if left < 0:
|
else:
|
||||||
left *= -1
|
angle = math.radians(distance * 5)
|
||||||
if right < 0:
|
left = math.sqrt(2)/2.0 * (math.cos(angle) + math.sin(angle))
|
||||||
right *= -1
|
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 is the channel for the sound
|
||||||
x = sounds[soundName].play(-1)
|
x = sounds[soundName].play(-1)
|
||||||
# Apply the position information to the channel
|
# Apply the position information to the channel
|
||||||
@ -198,13 +200,15 @@ def obj_update(x, playerPos, objPos):
|
|||||||
obj_stop(x)
|
obj_stop(x)
|
||||||
return None
|
return None
|
||||||
distance = playerPos - objPos
|
distance = playerPos - objPos
|
||||||
angle = math.radians(distance * 5)
|
if distance == 0:
|
||||||
left = math.sqrt(2)/2.0 * (math.cos(angle) + math.sin(angle))
|
left = 0.9
|
||||||
right = math.sqrt(2)/2.0 * (math.cos(angle) - math.sin(angle))
|
right = 0.9
|
||||||
if left < 0:
|
else:
|
||||||
left *= -1
|
angle = math.radians(distance * 5)
|
||||||
if right < 0:
|
left = math.sqrt(2)/2.0 * (math.cos(angle) + math.sin(angle))
|
||||||
right *= -1
|
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
|
# Apply the position information to the channel
|
||||||
x.set_volume(left, right)
|
x.set_volume(left, right)
|
||||||
# return the channel
|
# return the channel
|
||||||
|
Loading…
Reference in New Issue
Block a user