Here is my side scroller panning code.
This is the best panning code that I've made.
Call this function with your x position and the observer x (the object
that is being listened) and the pygame volume value will be returned.
I tryed to make this code from the BGT code but... the other volume is
not changed and i don't know how to calculate this change, but at least
it is a bit realistic.
Code:
def distance_1d(x, observex, xstep):
vol = [100, 100]
speaker = -1
if x > observex: # At right
delta = x - observex
speaker = 1
elif observex > x: # At left
delta = observex - x
speaker = 0
else:
return 1.0
delta *= xstep
vol[speaker] -= delta
lst = []
for v in vol:
if v <= 0:
lst.append(0)
else:
lst.append(v*100*0.1*0.001)
return lst
End code.
I'll try to do a pascal equivalent of this for people using the pure
SDL_mixer library on pascal.
If you want, feel free to post in any programming language that you want, as this
post is being archived in the forum, if someone searches and finds a
implementation in their favorite programming language it will be easyer for them.
Pages 1