2020-04-29 15:55:00

Hi all, i got the idea that i want to make a lane splitter type of game in python. i am going to use lucia for this. how ever while i was planning every thing out, i noticed that i might need a formula for the positioning of the objects.
what i want to do is the following:
I have an x value. it can only be 1, 2 or 3. this represent's the lanes in which you walk, and the lanes where the items spawn in. So is there a formula for me to ensure that the player can here what side of them the objects are? because if the panning values are incremented or decremented only by 1(switching between lines), there won't reelly be an audible difference. Please help if possible.
I am sorry if this sounds stupid or if it makes me look stupid, but i reelly tried for the passed 5 hours to figure out a formula, and it still does not work. thanks

best regards
never give up on what ever you are doing.

2020-04-29 16:26:38

(player.x-sound.x) will give you -1 if the sound is to the left, 0 if the sound is in the same lane as the player, and 1 if the sound is to the right.  Can just convert those to whatever audio thing uses for panning.

My Blog
Twitter: @ajhicks1992

2020-04-29 16:27:20

O oops, I think I got it backwards--it's probably sound.x-player.x.   Way too early in the morning for math.

My Blog
Twitter: @ajhicks1992

2020-04-29 16:58:22

Ok, will try that. thanx

best regards
never give up on what ever you are doing.

2020-04-29 22:43:12 (edited by amerikranian 2020-04-29 22:43:34)

@camlorn is correct, sound_x - player_x is what you want. Allow me to further demonstrate:
For this example, player_x = 0, sound_x = 0
sound_x - player_x = 0. Now multiply this value by something like, say, 30. This will dictate how sharp do the sounds pan in your ears. Still 0.
Let's do something else:
player_x = 0, sound_x = 2
sound_x - player_x = 2, * 30 = 60
There's your pan value.
Final example
player_x = 2, sound_x = 0
sound_x - player_x = -2, * 30 = -60
That's still valid, the pan can be  -100 to 100 in Lucia sound_pool.
Hope this helps

2020-04-30 09:58:11

Ok, i see how this works. @5 thanx for your example, i will try it out. I guess i can multiply it with another value to ensure that the sounds still remain with in ear shot right?

best regards
never give up on what ever you are doing.

2020-04-30 14:26:25

Hi all, this formula works great. the audio is not positioning propperly yet, but i will fix that one. I've wrote a return_pan function that helps me calculate the panning value at which the sound needs to be panned. Once again, thanx

best regards
never give up on what ever you are doing.