Re: Learning how to code free movement and panning in a game like Swamp.

Hello,
I'm using python2, but I converted all numbers to a floatingpoint.
Here is what aprone says about a:
If relativetheta was equal to zero, then the sound is exactly in front of us.  If relativetheta equals 45 then the sound is 45 degrees to our right, putting it halfway between being in front of us and being exactly to our right.  180 would be behind us and 270 would be directly off to our left.
According to aprone's first post, 270 is facing north. His  equation:
elif temp2 <= 0:
        a = atan(temp1/temp2) + pi

doesn't work because you can't divide a number by 0.
It also doesn't take into account the temp1 variable if temp2 is 0.
Then what is happening is you have a equal to pi and then you multiply 180/pi by a and it comes back to 180. Then you subtract 270 (pa) from 180.
a = (a * (180.0 / pi))
pa = float(a - pa)



from math import pi, sqrt, cos, atan

sound = (5.0,2.0)
player = (10.0,2.0)
pa = 270.0


temp1 = float(sound[0] - player[0])
temp2 = float(player[1] - sound[1])
if temp1 == 0 and temp2 == 0:
    a = -1.0
elif temp2 > 0:
    a = atan(temp1/temp2)
elif temp2 <= 0:
    if temp2 == 0:
        a = pi
    else:
        a = atan(temp1/temp2) + pi
a = (a * (180.0 / pi))
pa = float(a - pa)


print(pa)

_______________________________________________
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Off-topic room : frastlin via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : frastlin via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : frastlin via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : camlorn via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : camlorn via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : frastlin via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : camlorn via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : frastlin via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : camlorn via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : frastlin via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : frastlin via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : frastlin via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : frastlin via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : Aprone via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : frastlin via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : Aprone via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : camlorn via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : frastlin via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : frastlin via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : camlorn via Audiogames-reflector
    • ... AudioGames . net Forum — Off-topic room : frastlin via Audiogames-reflector

Reply via email to