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.
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