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

2020-05-29 Thread AudioGames . net Forum — Off-topic room : Blind angel 444 via Audiogames-reflector


  


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

@Aprone, thank you for these tutorials on coding and can someone please post the link for beginners since I’m still learning the language. This is advanced for me but very helpful.

URL: https://forum.audiogames.net/post/534526/#p534526




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


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

2020-05-29 Thread AudioGames . net Forum — Off-topic room : Rastislav Kiss via Audiogames-reflector


  


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

Hi there,@62: you can imagine it easily from sine's and cosine's diagrams (warning, I mean diagrams, not function graphs).Imagine a 2d graphing plane, with x axis going from left to right, and y axis from bottom to top. On this plane, imagine a cyrcle with radius 1 and center in coordinates 0;0.Now, imagine a pointer, vector, which would be fixed in 0;0, and point to 1;0 i.e. to the right. This pointer has length 1, and angle 0 degrees with x axis.Imagine this pointer would start rotating in the cyrcle, like clock pointer rotates in watches, just in opposite direction i.e. counterclockwise.At every moment, distance between pointer's ending and x axis is sine of the current angle.Why?Because the pointer has length 1 and is hypotenuse, whereas the distance between pointer's ending and x axis is the opposite cathetus to our angle. Marking this distance as d, from definition of sine as oppositeCathetus/hypotenuse we get:sin=d/1and thus:sin=dThe distance between pointer's ending and y axis is on the other hand cosine. Reason is similar like with sine, cosine is defined as:cos=nearbyCathetus/hypotenusei.e. in this case:cos=nearbyCathetus/1cos=nearbyCathetusI'm not sure if I'm using the right english term for nearby cathetus, I mean thatone directly near the angle.Now, you should be able to tell just naturally, why sine for one and cosine for other dymension.If your angle system has 0 degrees on the east and increases in counterclockwise movement, like in the case above, sine is logical choice for forward movement i.e. y axis, because the sine goes in this direction, whereas cosine is natural for sides, as it's the distance from y axis and thus modifies your x coordinate.Infact, any angle you choose on these "clocks", you can see its sine and cosine, like you'd need to add in a game.If your angle system works like in perhaps most games, i.e. with zero pointing to the north and angle increasing when turning in clockwise direction, the same diagram applies, you just need to turn it to right position.Now zero is infront of you, the pointer rotates in clockwise movement and sine is the distance between its ending and y axis, whereas cosine the distance between its ending and x axis.Thus it makes sense to increase x by sine and y by cosine, as those are their natural directions.I hope this explanation made at least some sense. Best regardsRastislav

URL: https://forum.audiogames.net/post/534518/#p534518




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


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

2020-05-29 Thread AudioGames . net Forum — Off-topic room : Rastislav Kiss via Audiogames-reflector


  


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

Hi there,@62: you can imagine it easily from sine's and cosine's diagrams (warning, I mean diagrams, not function graphs).Imagine a 2d graphing plane, with x axis going from left to right, and y axis from bottom to top. On this plane, imagine a cyrcle with radius 1 and center in coordinates 0;0.Now, imagine a pointer, vector, which would be fixed in 0;0, and point to 1;0 i.e. to the right. This pointer has length 1, and angle 0 degrees with x axis.Imagine this pointer would start rotating in the cyrcle, like clock pointer rotates in watches, just in opposite direction i.e. counterclockwise.At every moment, distance between pointer's ending and x axis is sine of the current angle.Why?Because the pointer has length 1 and is hypotenuse, whereas the distance between pointer's ending and x axis is the opposite cathetus to our angle. Marking this distance as d, from definition of sine as oppositeCathetus/hypotenuse we get:sin=d/1and thus:sin=dThe distance between pointer's ending and y axis is on the other hand cosine. Reason is similar like with sine, cosine is defined as:cos=nearbyCathetus/hypotenusei.e. in this case:cos=nearbyCathetus/1cos=nearbyCathetusI'm not sure if I'm using the right english term for nearby cathetus, I mean thatone directly near the angle.Now, you should be able to tell just naturally, why sine for one and cosine for other dymension.If your angle system has 0 degrees on the east and increases in counterclockwise movement, like in the case above, sine is logical choice for forward movement i.e. y axis, because the sine goes in this direction, whereas cosine is natural for sides, as it's the distance from y axis and thus modifies your x coordinate.Infact, any angle you choose on these "clocks", you can see its sine and cosine, like you'd need to add in a game.If your angle system works like in perhaps most games, i.e. with zero pointing to the north and angle increasing when turning in clockwise direction, the same diagram applies, you just need to turn it to right position.Now zero is infront of you, the pointer rotates in clockwise movement and sine is the distance between its ending and y axis, whereas cosine the distance between its ending and x axis.Thus it makes sense to increase x by sine and y by cosine, as those are their natural directions.I hope this explanation made at least some sense.Best regardsRastislav

URL: https://forum.audiogames.net/post/534518/#p534518




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


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

2020-05-29 Thread AudioGames . net Forum — Off-topic room : Rastislav Kiss via Audiogames-reflector


  


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

Hi there,@62: you can imagine it easily from sine's and cosine's diagrams (warning, I mean diagrams, not function graphs).Imagine a 2d graphing plane, with x axis going from left to right, and y axis from bottom to top. On this plane, imagine a cyrcle with radius 1 and center in coordinates 0;0.Now, imagine a pointer, vector, which would be fixed in 0;0, and point to 1;0 i.e. to the right. This pointer has length 1, and angle 0 degrees with x axis.Imagine this pointer would start rotating in the cyrcle, like clock pointer rotates in watches, just in opposite direction i.e. counterclockwise.At every moment, distance between pointer's ending and x axis is sine of the current angle.Why?Because the pointer has length 1 and is hypotenuse, whereas the distance between pointer's ending and x axis is the opposite cathetus to our angle. Marking this distance as d, from definition of sine as oppositeCathetus/hypotenuse we get:sin=d/1and thus:sin=dThe distance between pointer's ending and y axis is on the other hand cosine. Reason is similar like with sine, cosine is defined as:cos=nearbyCathetus/hypotenusei.e. in this case:cos=nearbyCathetus/1cos=nearbyCathetusI'm not sure if I'm using the right english term for nearby cathetus, I mean thatone directly near the angle.Now, you should be able to tell just naturally, why sine for one and cosine for other dymension.If your angle system has 0 degrees on the east and increases in counterclockwise movement, like in the case above, sine is logical choice for forward movement i.e. y axis, because the sine goes in this direction, whereas cosine is natural for sides, as it's the distance from y axis and thus modifies your x coordinate.Infact, any angle you choose on these "clocks", you can see its sine and cosine, like you'd need to add in a game.If your angle system works like in perhaps most games, i.e. with zero pointing to north and angle increasing when turning in clockwise direction, the same diagram applies, you just need to turn it to right position.Now zero is infront of you, the pointer rotates in clockwise movement and sine is the distance between its ending and y axis, whereas cosine the distance between its ending and x axis.Thus it makes sense to increase x by sine and y by cosine, as those are their natural directions.I hope this explanation made at least some sense.Best regardsRastislav

URL: https://forum.audiogames.net/post/534518/#p534518




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


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

2020-05-29 Thread AudioGames . net Forum — Off-topic room : Rastislav Kiss via Audiogames-reflector


  


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

Hi there,@62: you can imagine it easily from sine's and cosine's diagrams (warning, I mean diagrams, not function graphs).Imagine a 2d graphing plane, with x axis going from left to right, and y axis from bottom to top. On this plane, imagine a cyrcle with radius 1 and center in coordinates 0;0.Now, imagine a pointer, vector, which would be fixed in 0;0, and point to 1;0 i.e. to the right. This pointer has length 1, and angle 0 degrees with x axis.Imagine this pointer would start rotating in the cyrcle, like clock pointer rotates in watches, just in opposite direction i.e. counterclockwise.At every moment, distance between pointer's ending and x axis is sine of the current angle.Why?Because the pointer has length 1 and is hypotenuse, whereas the distance between pointer's ending and x axis is the opposite cathetus to our angle. Marking this distance as d, from definition of sine as oppositeCathetus/hypotenuse we get:sin=d/1and thus:sin=dThe distance between pointer's ending and y axis is on the other hand cosine. Reason is similar like with sine, cosine is defined as:cos=nearbyCathetus/hypotenusei.e. in this case:cos=nearbyCathetus/1cos=nearbyCathetusI'm not sure if I'm using the right english term for nearby cathetus, I mean thatone directly near the angle.Now, you should be able to tell just naturally, why sine for one and cosine for other dymension.If your angle system has 0 degrees on the east and increases in counterclockwise movement, like in the case above, sine is logical choice for forward movement i.e. y axis, because the sine goes in this direction, whereas cosine is natural for sides, as it's the distance from y axis and thus modifies your x coordinate.Infact, any angle you choose on these "clocks", you can see its sine and cosine, like you'd need to add in a game.If your angle system works like in perhaps most games, i.e. with zero pointing to north and angle increasing when turning right, the same diagram applies, you just need to turn it to right position.Now zero is infront of you, the pointer rotates in clockwise movement and sine is the distance between its ending and y axis, whereas cosine the distance between its ending and x axis.Thus it makes sense to increase x by sine and y by cosine, as those are their natural directions.I hope this explanation made at least some sense.Best regardsRastislav

URL: https://forum.audiogames.net/post/534518/#p534518




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


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

2020-05-29 Thread AudioGames . net Forum — Off-topic room : Rastislav Kiss via Audiogames-reflector


  


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

Hi there,@62: you can imagine it easily from sine's and cosine's diagrams (warning, I mean diagrams, not function graphs).Imagine a 2d graphing plane, with x axis going from left to right, and y axis from bottom to top. On this plane, imagine a cyrcle with radius 1 and center in coordinates 0;0.Now, imagine a pointer, vector, which would be fixed in 0;0, and point to 1;0 i.e. to the right. This pointer has length 1, and angle 0 degrees with x axis.Imagine this pointer would start rotating in the cyrcle, like clock pointer rotates in watches, just in opposite direction i.e. counterclockwise.At every moment, distance between pointer's ending and x axis is sine of the current angle.Why?Because the pointer has length 1 and is hypotenuse, whereas the distance between pointer's ending and x axis is the opposite cathetus to our angle. Marking this distance as d, from definition of sine as oppositeCathetus/hypotenuse we get:sin=d/1and thus:sin=dThe distance between pointer's ending and y axis is on the other hand cosine. Reason is similar like with sine, cosine is defined as:cos=nearbyCathetus/hypotenusei.e. in this case:cos=nearbyCathetus/1cos=nearbyCathetusI'm not sure if I'm using the right english term for nearby cathetus, I mean thatone directly near the angle.Now, you should be able to tell just naturally, why sine for one and cosine for other dymension.If your angle system has 0 degrees on the east, like in the case above, sine is logical choice for forward movement i.e. y axis, because the sine goes in this direction, whereas cosine is natural for sides, as it's the distance from y axis and thus modifies your x coordinate.Infact, any angle you choose on these "clocks", you can see its sine and cosine, like you'd need to add in a game.If your angle system works like in perhaps most games, i.e. with zero pointing to north and angle increasing when turning right, the same diagram applies, you just need to turn it to right position.Now zero is infront of you, the pointer rotates in clockwise movement and sine is the distance between its ending and y axis, whereas cosine the distance between its ending and x axis.Thus it makes sense to increase x by sine and y by cosine, as those are their natural directions.I hope this explanation made at least some sense.Best regardsRastislav

URL: https://forum.audiogames.net/post/534518/#p534518




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


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

2020-05-29 Thread AudioGames . net Forum — Off-topic room : Rastislav Kiss via Audiogames-reflector


  


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

Hi there,@62: you can imagine it easily from sine's and cosine's diagrams.Imagine a 2d graphing plane, with x axis going from left to right, and y axis from bottom to top. On this plane, imagine a cyrcle with radius 1 and center in coordinates 0;0.Now, imagine a pointer, vector, which would be fixed in 0;0, and point to 1;0 i.e. to the right. This pointer has length 1, and angle 0 degrees with x axis.Imagine this pointer would start rotating in the cyrcle, like clock pointer rotates in watches, just in opposite direction i.e. counterclockwise.At every moment, distance between pointer's ending and x axis is sine of the current angle.Why?Because the pointer has length 1 and is hypotenuse, whereas the distance between pointer's ending and x axis is the opposite cathetus to our angle. Marking this distance as d, from definition of sine as oppositeCathetus/hypotenuse we get:sin=d/1and thus:sin=dThe distance between pointer's ending and y axis is on the other hand cosine. Reason is similar like with sine, cosine is defined as:cos=nearbyCathetus/hypotenusei.e. in this case:cos=nearbyCathetus/1cos=nearbyCathetusI'm not sure if I'm using the right english term for nearby cathetus, I mean thatone directly near the angle.Now, you should be able to tell just naturally, why sine for one and cosine for other dymension.If your angle system has 0 degrees on the east, like in the case above, sine is logical choice for forward movement i.e. y axis, because the sine goes in this direction, whereas cosine is natural for sides, as it's the distance from y axis and thus modifies your x coordinate.Infact, any angle you choose on these "clocks", you can see its sine and cosine, like you'd need to add in a game.If your angle system works like in perhaps most games, i.e. with zero pointing to north and angle increasing when turning right, the same diagram applies, you just need to turn it to right position.Now zero is infront of you, the pointer rotates in clockwise movement and sine is the distance between its ending and y axis, whereas cosine the distance between its ending and x axis.Thus it makes sense to increase x by sine and y by cosine, as those are their natural directions.I hope this explanation made at least some sense.Best regardsRastislav

URL: https://forum.audiogames.net/post/534518/#p534518




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


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

2020-05-28 Thread AudioGames . net Forum — Off-topic room : Nuno via Audiogames-reflector


  


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

I know this question might be stupid, but I am genuinely interestedi n the process.How does the cosine relate to the horizontal, and sine to the vertical line? DOes it have to do something with the function graphs? I actually understand the math, just don't understand that part.

URL: https://forum.audiogames.net/post/534407/#p534407




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


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

2020-05-28 Thread AudioGames . net Forum — Off-topic room : chrisnorman7 via Audiogames-reflector


  


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

Hi all,Afraid I've done that most terrible of things! I've copy and pasted Aprone's wonderful formula into my own code, without really understanding the maths behind it.It's all working fine, except I'm not sure how to adjust my WebAudio listener's orientation to match.Does anyone have the magic formula? Or a pointer where I can go learn, read, and work one out for myself?Thanks so much for the maths Aprone, it's really useful stuff, and thanks all in advance.

URL: https://forum.audiogames.net/post/534329/#p534329




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


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

2017-04-29 Thread AudioGames . net Forum — Off-topic room : brian . kurosawa via Audiogames-reflector


  


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

I understud all of the consepts of the code, but i'm not able to think on how we could play a footstep sound exactly whem the player moves a distance of 1.0 from their previous spot. Is there a formula to solve it, or do i must get the average motion time?

URL: http://forum.audiogames.net/viewtopic.php?pid=309077#p309077





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

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

2015-01-23 Thread AudioGames . net Forum — Off-topic room : frastlin via Audiogames-reflector


  


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

So, This just pans a sound based on a location 1 coord away.But it also says that the sound is behind when it is really to the side. See the following prints:print pan_value((3, 2), 90, (5, 2))print pan_value((4, 2), 90, (5, 2))print pan_value((5, 2), 90, (5, 2))print pan_value((6, 2), 90, (5, 2))print pan_value((7, 2), 90, (5, 2))(1.0, False)(1.0, False)(1.0, False)(-1.0, True)(-1.0, True)

URL: http://forum.audiogames.net/viewtopic.php?pid=202064#p202064




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

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

2015-01-23 Thread AudioGames . net Forum — Off-topic room : camlorn via Audiogames-reflector


  


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

Yeah. You probably cant actually fix that, and in practice its not noticeable.See, the thing is that two floats are almost never equal. The only time you can be sure that a==b is if you type out the values for a and b immediately before hand.In the same way that we cant represent 1/3 as a decimal with complete accuracy, computers also cant represent certain decimals with complete accuracy, either. Floating point math is completely weird and surprises a lot of people-for example, if you keep adding one to a float for long enough itll stop going up because the next value is further than 1 away and negative zero actually exists. When you add in the fact that pi is also an approximation (recall that pi is infinite), the chances of it deciding that 90 is consistently in front of you in all cases is basically nil.that line is ambiguous anyway. At what point do we say that it is behind you? It
 s kind of both. But in practice, your players arent going to notice that 89.939 degrees to your right is in front but 90 degrees to your right is behind, etc.

URL: http://forum.audiogames.net/viewtopic.php?pid=202096#p202096




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

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

2015-01-22 Thread AudioGames . net Forum — Off-topic room : Aprone via Audiogames-reflector


  


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

frastlin wrote:Aprone really likes dividing his numbers by 0 doesnt he When theres nothing good on TV, I often sit around dividing numbers by zero.  Its fun! ROFL!Id weigh in and help with this math discussion, but I cant remember the whats and whys of this code. Its been a while, and I have this vague remembrance that someone (I want to say Ghorthalon or CAE Jones) spotted a typo in it. The code in this thread wasnt pulled from Swamp, it was typed out right from my head, if memory serves me. So I wouldnt be surprised if it contains a mistake somewhere. I hope it doesnt... but it just wou
 ldnt surprise me.

URL: http://forum.audiogames.net/viewtopic.php?pid=201921#p201921




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

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

2015-01-22 Thread AudioGames . net Forum — Off-topic room : camlorn via Audiogames-reflector


  


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

The following code is correct as far as I can tell. I included the test cases. The function pan_value returns two things: a value between -1 and 1 as above and a true/false value that tells you if the object is behind the player or not. This is basically a 2d transformation matrix, but gameobjects is overkill so I didnt bring it in.Possibly unlike the first post, the angle 0 is east, the angle 90 is north, the angle 180 is west, and the angle 270 is south. If you need to make it so that 90 is south and 270 is north, you can negate the parameter as the first line of the function. Tabs apparently break hard on this forum in the sense that NVDA at least doesnt like reading indentation indication when you use them (the forum appears to be doing some sanitizing). Consequently, I used single-space indentation.if you can find a test case where this is broken, post it and Ill fix the code.from __future__ import division
import math

def dot(a, b):
 return sum(a[i]*b[i] for i in xrange(len(a)))

def magnitude(a):
 return math.sqrt(sum(i**2 for i in a))

def normalize(a):
 m = magnitude(a)
 return tuple(i/m for i in a)

def pan_value(player_pos, player_facing, sound_pos):
 player_facing=player_facing*(math.pi/180.0)
 front = normalize((math.cos(player_facing), math.sin(player_facing)))
 right = normalize((math.cos(player_facing-math.pi/2.0), math.sin(player_facing-math.pi/2.0)))
 #translate the sounds position to be relative to the player.
 translated_pos= sound_pos[0]-player_pos[0], sound_pos[1]-player_pos[1]
 #y is front because this gives an angle on the range 0 to pi instead of -pi/2 to pi/2.
 x= dot(right, translated_pos)
 y = dot(front, translated_pos)
 angle =math.atan2(y, x)
 is_behind = y  0
 return (math.cos(angle), is_behind)

print pan_value((5, 0), 0, (2, 0))
print pan_value((5, 0), 90, (0, 0))
print pan_value((5, 0), 110, (0, 0))
print pan_value((5, 0), 270, (2, 0))
print pan_value((5, 0), 270, (2, 1))And thats it.

URL: http://forum.audiogames.net/viewtopic.php?pid=201935#p201935




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

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

2015-01-22 Thread AudioGames . net Forum — Off-topic room : Aprone via Audiogames-reflector


  


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

Which parts Are working for you? For example, can you measure the angle that your character is facing? Can you measure the angle between you and the sound you are trying to hear? Perhaps listing what parts are working will help us piece together what is missing.(Sorry if you already did this in an earlier post. I didnt go back and read all of the posts on this thread.)

URL: http://forum.audiogames.net/viewtopic.php?pid=201927#p201927




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

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

2015-01-22 Thread AudioGames . net Forum — Off-topic room : frastlin via Audiogames-reflector


  


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

Hello,Im using python2, but I converted all numbers to a floatingpoint.Here is what aprone says about pa: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 aprones first post, 270 is facing north. His equation:elif temp2 = 0:a = atan(temp1/temp2) + pidoesnt work because you cant divide a number by 0.It also doesnt 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, atansound = (5.0,2.0)player = (10.0,2.0)pa = 270.0temp1 = float(sound[0] - player[0])temp2 = float(player[1] - sound[1])if temp1 == 0 and temp2 == 0:  a = -1.0elif temp2  0:  a = atan(temp1/temp2)elif temp2 = 0:  if temp2 == 0:a = pi  else:a = atan(temp1/temp2) + pia = (a * (180.0 / pi))pa = float(a - pa)print(pa)*edit*Looking at Aprones post 31, he says something completely different.He says it should look like:if temp1 == 0 and temp2 == 0:  a = -1.0elif temp1  0:  a = atan(temp1/temp2)elif temp1 = 0:  if temp2 == 0:a = pi  else:a = atan(temp1/temp2) + pia = (a * (180.0 / pi))-90Aprone really likes dividing his numbers by 0 doesnt he This doesnt give the right numbers either. It just changes the -90 to +90...

URL: http://forum.audiogames.net/viewtopic.php?pid=201909#p201909




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

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

2015-01-22 Thread AudioGames . net Forum — Off-topic room : frastlin via Audiogames-reflector


  


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

Well,The problem is that each set of code that was typed out here is different and none of it seems to work for me. Granted I am not the best at BGT, so there could have been some new thing that was introduced above what I was looking at.But I would really like to get this sound positioning thing right as it is the last huge piece missing in my library.

URL: http://forum.audiogames.net/viewtopic.php?pid=201924#p201924




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

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

2015-01-22 Thread AudioGames . net Forum — Off-topic room : frastlin via Audiogames-reflector


  


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

Hello,Im using python2, but I converted all numbers to a floatingpoint.According to aprones first post, 270 is facing north. His equation:elif temp2 = 0:a = atan(temp1/temp2) + pidoesnt work because you cant divide a number by 0.It also doesnt 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, atansound = (5.0,2.0)player = (10.0,2.0)pa = 270.0temp1 = float(sound[0] - player[0])temp2 = float(player[1] - sound[1])if temp1 == 0 and temp2 == 0:  a = -1.0elif temp2  0:  a = atan(temp1/temp2)elif temp2 = 0:  if temp2 =
 = 0:a = pi  else:a = atan(temp1/temp2) + pia = (a * (180.0 / pi))pa = float(a - pa)print(pa)

URL: http://forum.audiogames.net/viewtopic.php?pid=201909#p201909




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

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

2015-01-22 Thread AudioGames . net Forum — Off-topic room : frastlin via Audiogames-reflector


  


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

Hello,Im 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 aprones first post, 270 is facing north. His equation:elif temp2 = 0:a = atan(temp1/temp2) + pidoesnt work because you cant divide a number by 0.It also doesnt 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, atansound = (5.0,2.0)player = (10.0,2.0)pa = 270.0temp1 = float(sound[0] - player[0])temp2 = float(player[1] - sound[1])if temp1 == 0 and temp2 == 0:  a = -1.0elif temp2  0:  a = atan(temp1/temp2)elif temp2 = 0:  if temp2 == 0:a = pi  else:a = atan(temp1/temp2) + pia = (a * (180.0 / pi))pa = float(a - pa)print(pa)

URL: http://forum.audiogames.net/viewtopic.php?pid=201909#p201909




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

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

2015-01-22 Thread AudioGames . net Forum — Off-topic room : frastlin via Audiogames-reflector


  


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

Hello,Im using python2, but I converted all numbers to a floatingpoint.Here is what aprone says about pa: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 aprones first post, 270 is facing north. His equation:elif temp2 = 0:a = atan(temp1/temp2) + pidoesnt work because you cant divide a number by 0.It also doesnt 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, atansound = (5.0,2.0)player = (10.0,2.0)pa = 270.0temp1 = float(sound[0] - player[0])temp2 = float(player[1] - sound[1])if temp1 == 0 and temp2 == 0:  a = -1.0elif temp2  0:  a = atan(temp1/temp2)elif temp2 = 0:  if temp2 == 0:a = pi  else:a = atan(temp1/temp2) + pia = (a * (180.0 / pi))pa = float(a - pa)print(pa)

URL: http://forum.audiogames.net/viewtopic.php?pid=201909#p201909




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

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

2015-01-22 Thread AudioGames . net Forum — Off-topic room : frastlin via Audiogames-reflector


  


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

Ill go through camlorns code and see what hes doing. Its just a little different than what Aprone did.BTW, you can copy and paste the code into EdSharp and do a ctrl+r and type:replace:  with\tand it replaces all 4 spaces with a tab.But Aprone, All my posts say the problem, but post 43 and 49 show what is going on.In a nutshell, the code is giving an error because you cant divide numbers by 0 and it is coming out with the sound as a -90 when the player is at 10,2 facing 270 and the sound is at 5,2. It is also coming out with a -90 when the player is at the same place 10,2 facing 270 and the sound is at 15,2.One should give 270 and the other should give 90.

URL: http://forum.audiogames.net/viewtopic.php?pid=201938#p201938




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

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

2015-01-22 Thread AudioGames . net Forum — Off-topic room : camlorn via Audiogames-reflector


  


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

My east is at 0 because I was trying not to break the convention too badly, but Aprones east is at zero most likely because this is how trigonometry works. The standard convention in the literature is east is 0 radians and positive angles are counterclockwise from that. If you really need a version with north at 0 and going clockwise, I can maybe work one out for you-but clockwise is just negating the functions second parameter on the first line and north is just adding 90 degrees.Do not try to understand my code. Just use my code and post if its broken. The only way youll understand my code is if you know what sine and cosine do in terms of the unit circle and what the dot product means. In fact, going over it now, the normalize for front and right is a no-op. Ah well.I know how to find/replace. I used one space instead of one tab because the forum here is doing something interesting with tabs, a fact which m
 ade your code above hard to read. The entire situation with Firefox indentation is weird, and theres almost no way around it. Of all of us, I am the only one who does not care about four spaces versus one tab; this is because I read and work with code from the sighted, and its really not that big a deal anyway.

URL: http://forum.audiogames.net/viewtopic.php?pid=201946#p201946




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

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

2015-01-22 Thread AudioGames . net Forum — Off-topic room : frastlin via Audiogames-reflector


  


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

Ill go through camlorns code and see what hes doing. Its just a little different than what Aprone did.BTW, you can copy and paste the code into EdSharp and do a ctrl+r and type:replace:  with\tand it replaces all 4 spaces with a tab.But Aprone, All my posts say the problem, but post 43 and 49 show what is going on.In a nutshell, the code is giving an error because you cant divide numbers by 0 and it is coming out with the sound as a -90 when the player is at 10,2 facing 270 and the sound is at 5,2. It is also coming out with a -90 when the player is at the same place 10,2 facing 270 and the sound is at 15,2.One should give 270 and the other should give 90.*question*Why does everyone have east at 0 when most people like to start out north?

URL: http://forum.audiogames.net/viewtopic.php?pid=201938#p201938




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

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

2015-01-22 Thread AudioGames . net Forum — Off-topic room : frastlin via Audiogames-reflector


  


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

Hm, Youre right, Im very lost on this code... I did however make it python 2 and 3 compliant I believe as well as sped it up to 1/3 its original speed.from math import cos, sin, sqrt, atan2, pidef dot(a, b):  return (a[0]*b[0]) + (a[1]*b[1]) def magnitude(a):  returns the sqrt of a squared + b squared  return sqrt(a[0]**2 + a[1]**2)def normalize(a):  m = magnitude(a)  return (a[0]/m, a[1]/m)def pan_value(player_pos, player_facing, sound_pos):  player_facing = player_facing*(pi/180.0)  front = normalize((cos(player_facing), sin(player_facing)))  right = normalize((cos(player_facing-pi/2.0), sin(player_facing-pi/2.0)))  #translate the sounds position to be relative to the player  translated_pos = sound_pos[0]-pla
 yer_pos[0], sound_pos[1]-player_pos[1]  #y is front because this gives an angle on the range 0 to pi instead of -pi/2 to pi/2  x= dot(right, translated_pos)  y = dot(front, translated_pos)  angle = atan2(y, x)  is_behind = y 0  return (cos(angle), is_behind)print pan_value((5, 0), 0, (2, 0))I guess with this many equasions, it is bound to be somewhat slow, but I dont think it matters when using pygame though as I dont think you can have more than 16 sounds going at once...

URL: http://forum.audiogames.net/viewtopic.php?pid=202007#p202007




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

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

2015-01-22 Thread AudioGames . net Forum — Off-topic room : frastlin via Audiogames-reflector


  


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

Hm, Youre right, Im very lost on this code... I did however make it python 2 and 3 compliant I believe as well as sped it up to 1/3 its original speed.from math import cos, sin, sqrt, atan2, pidef dot(a, b):  return (a[0]*b[0]) + (a[1]*b[1]) def magnitude(a):  returns the sqrt of a squared + b squared  return sqrt(a[0]**2 + a[1]**2)def normalize(a):  m = magnitude(a)  return (a[0]/m, a[1]/m)def pan_value(player_pos, player_facing, sound_pos):  player_facing = player_facing*(pi/180.0)  front = normalize((cos(player_facing), sin(player_facing)))  right = normalize((cos(player_facing-pi/2.0), sin(player_facing-pi/2.0)))  #translate the sounds position to be relative to the player  translated_pos = sound_pos[0]-pla
 yer_pos[0], sound_pos[1]-player_pos[1]  #y is front because this gives an angle on the range 0 to pi instead of -pi/2 to pi/2  x= dot(right, translated_pos)  y = dot(front, translated_pos)  angle = atan2(y, x)  is_behind = y 0  return (cos(angle), is_behind)print(pan_value((5, 0), 0, (2, 0)))I guess with this many equasions, it is bound to be somewhat slow, but I dont think it matters when using pygame though as I dont think you can have more than 16 sounds going at once...

URL: http://forum.audiogames.net/viewtopic.php?pid=202007#p202007




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

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

2015-01-22 Thread AudioGames . net Forum — Off-topic room : frastlin via Audiogames-reflector


  


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

Hm, Youre right, Im very lost on this code... I did however make it python 2 and 3 compliant I believe as well as sped it up to 1/3 its original speed.from math import cos, sin, sqrt, atan2, pidef dot(a, b):  return (a[0]*b[0]) + (a[1]*b[1]) def magnitude(a):  returns the sqrt of a squared + b squared  return sqrt(a[0]**2 + a[1]**2)def normalize(a):  m = magnitude(a)  return (a[0]/m, a[1]/m)def pan_value(player_pos, player_facing, sound_pos):  player_facing = player_facing*(pi/180.0)  front = normalize((cos(player_facing), sin(player_facing)))  right = normalize((cos(player_facing-pi/2.0), sin(player_facing-pi/2.0)))  #translate the sounds position to be relative to the player  tra
 nslated_pos = sound_pos[0]-player_pos[0], sound_pos[1]-player_pos[1]  #y is front because this gives an angle on the range 0 to pi instead of -pi/2 to pi/2  x= dot(right, translated_pos)  y = dot(front, translated_pos)  angle = atan2(y, x)  is_behind = y 0  return (cos(angle), is_behind)print(pan_value((5, 0), 0, (2, 0)))I guess with this many equasions, it is bound to be somewhat slow, but I dont think it matters when using pygame though as I dont think you can have more than 16 sounds going at once...

URL: http://forum.audiogames.net/viewtopic.php?pid=202007#p202007




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

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

2015-01-22 Thread AudioGames . net Forum — Off-topic room : camlorn via Audiogames-reflector


  


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

Okay. So, here is an informative Python repl session. import timeit
 timeit.timeit(lambda: pan_value((5, 0), 90, (2, 0)), number=1)/1.0
1.0377488363072835e-05
 timeit.timeit(lambda: pan_value((5, 0), 90, (2, 0)), number=1)
0.10387503569908141
So you can basically run 2 or 3 thousand calls to it a frame without it even being that big a deal.Your version may be faster, but mine is extensible. The magnitude, normalize and dot functions I am utilizing will work with any number of dimensions, up to and including vectors that are so long they break your ram. Unfortunately, the pan_value function only works in 2-the 3-dimensional version absolutely requires transformation matrices, because otherwise you have to do a projection onto a plane. Obviously panning stops mattering once we get into 4, as do most games.But seriously, dont optimize until and unless it proves to be too slow. This can be microoptimized even further by not using tuples at all and getting rid of the dot and normalize functions and technically you can compute cosine with a division. But it simply does not matter. Code for clarity, not for speed.Make your game.
 bsp; When your game proves to be too slow, profile it. Then fix whichever functions are at the top of the list of total time taken. Any other optimization in Python is simply not worth it-if you are actually doing something that might actually have a performance issue of this sort at all then youre using C/C++.And I could care less about Python 3-a huge number of libraries remain unported, enough that most people who use the language still use 2. This is changing and Ill start caring when Twisted and Gevent port as, if youre going to try networked games in Python, you really really want one or the other of those. 3 has some very nice features, but a lot of the useful stuff is available as backports and its just not worth it without all the stuff you can get in 2 (hint: gameobjects, possibly the ODE bindings, not sure if lxml ported yet or not...). 3 is nice in theory, but its going to stay theory until we actually see
  a concerted effort by all the major libraries-in practice, braking backward compatibility in an established programming language as they did means theyre lucky that Python is still popular.

URL: http://forum.audiogames.net/viewtopic.php?pid=202014#p202014




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

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

2015-01-22 Thread AudioGames . net Forum — Off-topic room : camlorn via Audiogames-reflector


  


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

Okay. So, here is an informative Python repl session. import timeit
 timeit.timeit(lambda: pan_value((5, 0), 90, (2, 0)), number=1)/1.0
1.0377488363072835e-05
 timeit.timeit(lambda: pan_value((5, 0), 90, (2, 0)), number=1)
0.10387503569908141
So you can basically run 2 or 3 thousand calls to it a frame without it even being that big a deal.Your version may be faster, but mine is extensible. The magnitude, normalize and dot functions I am utilizing will work with any number of dimensions, up to and including vectors that are so long they break your ram. Unfortunately, the pan_value function only works in 2-the 3-dimensional version absolutely requires transformation matrices, because otherwise you have to do a projection onto a plane. Obviously panning stops mattering once we get into 4, as do most games.But seriously, dont optimize until and unless it proves to be too slow. This can be microoptimized even further by not using tuples at all and getting rid of the dot and normalize functions and technically you can compute cosine with a division. But it simply does not matter. Code for clarity, not for speed.Make your game.
 bsp; When your game proves to be too slow, profile it. Then fix whichever functions are at the top of the list of total time taken. Any other optimization in Python is simply not worth it-if you are actually doing something that might actually have a performance issue of this sort at all then youre using C/C++.I could care less about Python 3-a huge number of libraries remain unported, enough that most people who use the language still use 2. This is changing and Ill start caring when Twisted and Gevent port as, if youre going to try networked games in Python, you really really want one or the other of those. 3 has some very nice features, but a lot of the useful stuff is available as backports and its just not worth it without all the stuff you can get in 2 (hint: gameobjects, possibly the ODE bindings, not sure if lxml ported yet or not...). 3 is nice in theory, but its going to stay theory until we actually see a c
 oncerted effort by all the major libraries-in practice, braking backward compatibility in an established programming language as they did means theyre lucky that Python is still popular.As for the explanation of what Im doing, I need 2 or 3 lengthy articles to teach the preliminaries. Ill probably write them over the summer when I have some time and mental energy; Im basically certain theyd be valuable at this point, given how often this kind of thing comes up. Its not that hard if you have pictures, but we dont have pictures. They are worth a whole lot more than a thousand words for this kind of thing.

URL: http://forum.audiogames.net/viewtopic.php?pid=202014#p202014




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

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

2015-01-21 Thread AudioGames . net Forum — Off-topic room : camlorn via Audiogames-reflector


  


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

I think your problem may be the integers. Is this Python 2 or 3? Because if its 2, youve got a truncating division or 10. Replace 5 with 5.0, etc, or wrap your variables in float() before using them in denominators.Also replace 3.14 with math.pi, just use math.sqrt instead of assigning it, or:from math import pi, sqrt, cosAlternatively, as a very bad practice:from math import *But this makes introspection and stuff harder and is a pretty bad habit to get into.I cant check the math without working through it with a comb. I do this sort of thing using what is known as a transformation matrix, which lets me cut down on the needed variables and number of lines that this takes by an order of magnitude. Unfortunately, this is not something that can be easily explained in a forum post, though I may try doing some tutorials at some point. The magic of transformation matrices is such that you can take
  a world like this and make it look like a world where youre standing at the origin with the y axis coming out your nose; if you get them its so, so much easier to work out the rest. In either case, Ive not gone through this with raw trig in a really, really long time.

URL: http://forum.audiogames.net/viewtopic.php?pid=201869#p201869




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

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

2015-01-21 Thread AudioGames . net Forum — Off-topic room : frastlin via Audiogames-reflector


  


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

Hello,I changed everything to floats and entered pi and I still get the wrong result.I believe with the player at 10,2 and the sound at 5,2 the result should be -90, but with the sound at 15,2 the sound should be at 90?What is a good transformation matrices library?Because I would rather use something someone else made than create my own...

URL: http://forum.audiogames.net/viewtopic.php?pid=201875#p201875




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

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

2015-01-21 Thread AudioGames . net Forum — Off-topic room : frastlin via Audiogames-reflector


  


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

I didnt even see any good documentation on gameobjects, just the API...I think Im closer to figuring this out than gameobjects...But I dont know what atan does, so dont know how to error-check it. Im actually completely lost at what any of the math is doing... I can just tell were working with circles and I want a 90 degree angle one positive and one negative I think...

URL: http://forum.audiogames.net/viewtopic.php?pid=201883#p201883




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

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

2015-01-21 Thread AudioGames . net Forum — Off-topic room : camlorn via Audiogames-reflector


  


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

A good transformation matrix library in Python is gameobjects. The tutorial I need to write is the important bit here: its like having the sine and cosine functions in that you can call them but probably have no idea whats going on. Transformation matrices are super, super useful but also kinda complicated even in library form-said library isnt giving you a pan this sound primitive, its giving you the stuff you need to work with transformation matrices. Im putting the explanation here, but you probably just want to fight with that code-there are too many prerequisites for how and why this works for me to just give you my mental model.The general approach, however, is to construct a 3d transformation matrix in which the left-most column is a unit vector in the direction which the player is facing, the middle column is a unit vector in the direction to the right of the player, and the third column is the unit vector pointing alon
 g the positive z axis. The fourth column is much more complicated, and I cant remember-but thats why we have libraries. This entire construction is usually one function call to the matrix library (usually called lookAt or similar). You then pad all your coordinates with 0 for z, feed them through it, and then compute the angle with the y axis to get the value you need.If youre wondering why Id go through all the effort, theres a few reasons: the formulas that involve dot products and cross products are usually much, much simpler than the formulas involving trig functions; this is because the dot and cross products have direct physical interpretations. The second is that literally anything you use from the sighted world is going to expect you to use 2D transformation matrices at least. The third is that moving the entire world like this is super useful for a variety of other things like radars. And fourth, this is how 
 sighted game programers have been doing it for years; I can leverage all that wonderful and highly capable code.To put it in a much simpler way. You can say that you are ten feet east of the flagpole facing northeast, which is fine. But you could also say that youre at the origin facing north and that the flagpole is 10 feet southwest of you. Which is also fine and describes exactly the same thing, just in a different way. What transformation matrices are doing is allowing you to change how you look at the world--with them, you can make the player literally the center of the universe whenever you want.This is probably the most literal interpretation of the universe revolving around you anywhere, and its a powerful concept. Just really, really complicated to learn in the first place as a blind person as we dont have all the pictures sighted people do. Most tutorials on the subject say look at this picture. Got it
 ? Good, how about this one. with barely any text.

URL: http://forum.audiogames.net/viewtopic.php?pid=201876#p201876




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

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

2015-01-21 Thread AudioGames . net Forum — Off-topic room : camlorn via Audiogames-reflector


  


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

You probably dont have the background to understand either of these fully. There is no gameobjects documentation because anyone who understands 3d transformation matrices will immediately get it from the function names. I do not know of a 3d transformation matrix library with documentation. You cant say anything useful in it-thats why I said you need the tutorials as to what these actually are in the first place. Its like how math.sin says it computes the sine function, but its still up to you to know what that means. The only ambiguity with matrix transformation libraries is what the conventions in use are, as I can point the coordinate axis in many different directions (like how positive y is north except in graphics where positive y is down, etc).Tan is tangent. Atan is inverse tangent. Same with sin and cos.Youre finding the angle between a line coming out of your nose and going straight ahead and a 
 line coming out of your head and going straight to the sound, and then using the cosine function to turn that into a value between -1 and 1. Proper explanations of what these functions do needs a trigonometry course or at least some diagrams. What Aprone is doing is performing the same exact thing youd do with a 2d transformation matrix, just hes going about it the way that doesnt involve them for simplicity.If I understand the conventions right, youre facing south and the sound is west. I think you should be getting 90 in the first case and -90 in the second case. If the final number that comes out is not reading as 90.0, youve got a floating point issue. Is this python 2.7 or 3? If its 3, I can stop wondering if its a floating point issue and try to untangle the nice if block and/or just replace the entire thing with atan2 for you. Theres basically no reason whatsoever that it cant
 ; be made to work with atan2, I think.

URL: http://forum.audiogames.net/viewtopic.php?pid=201898#p201898




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

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

2015-01-21 Thread AudioGames . net Forum — Off-topic room : camlorn via Audiogames-reflector


  


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

I think your problem may be the integers. Is this Python 2 or 3? Because if its 2, youve got a truncating division or 10. Replace 5 with 5.0, etc, or wrap your variables in float() before using them in denominators.Also replace 3.14 with math.pi, just use math.sqrt instead of assigning it, or:from math import pi, sqrt, cosAlternatively, as a very bad practice:from math import *But this makes introspection and stuff harder and is a pretty bad habit to get into.I cant check the math without working through it with a comb. I do this sort of thing using what is known as a transformation matrix, which lets me cut down on the needed variables and number of lines that this takes by an order of magnitude. Unfortunately, this is not something that can be easily explained in a forum post, though I may try doing some tutorials at some point. The magic of transformation matrices is such that you can take
  a world like this and make it look like a world where youre standing at the origin facing whatever direction; if you get them its so, so much easier to work out the rest. In either case, Ive not gone through this with raw trig in a really, really long time.

URL: http://forum.audiogames.net/viewtopic.php?pid=201869#p201869




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

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

2015-01-21 Thread AudioGames . net Forum — Off-topic room : frastlin via Audiogames-reflector


  


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

Hello,Going through the code on the first page, I just want to make sure I have the correct understanding of the terms as some could have a couple interpretations:sqr is square root and not squared correct? In most languages sqrt?Atn is arc tangentand it probably doesnt matter as it does something in python, but I cant seem to find it, what does ^ stand for? I thought it meant sqrt, but it doesnt.*note* I just realized, after speaking out what the equation is to find the Hypotenuse... and that means that ^ is ** and sqr is sqrt.thanks,

URL: http://forum.audiogames.net/viewtopic.php?pid=201787#p201787




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

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

2015-01-21 Thread AudioGames . net Forum — Off-topic room : frastlin via Audiogames-reflector


  


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

Hello,Going through the code on the first page, I just want to make sure I have the correct understanding of the terms as some could have a couple interpretations:sqr is square root and not squared correct? In most languages sqrt?Atn is arc tangentand it probably doesnt matter as it does something in python, but I cant seem to find it, what does ^ stand for? I thought it meant sqrt, but it doesnt.thanks,

URL: http://forum.audiogames.net/viewtopic.php?pid=201787#p201787




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

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

2015-01-21 Thread AudioGames . net Forum — Off-topic room : frastlin via Audiogames-reflector


  


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

Hello,So taken my assumptions from the above post, I did:#start codeimport mathsqrt = math.sqrtsound = (5,2)player = (10,2)theta = 270mya, myb = playersounda, soundb = soundtemp1 = sounda - myatemp2 = myb - soundbif temp1 == 0 and temp2 == 0:  absolutetheta = -1elif temp2  0:  absolutetheta = math.atan(temp1/temp2)elif temp2 = 0:  if temp2 == 0:absolutetheta = 3.14  else:absolutetheta = math.atan(temp1/temp2) + 3.14absolutetheta = (absolutetheta * (180 / 3.14))relativetheta = absolutetheta - thetaprint(relativetheta)#end of codeThere is something strange going on. If I change the sound coords to 15,2 the result that comes out is still -90 instead of 90.I think the problem is with the temp1 and temp2 lines, b
 ut I am not going to pretend to understand what is going on mathematically to error-check the other lines. I put in a check in the last elif statement that defaults absolutetheta to 3.14 if temp2 is 0 as most calculators really dont like dividing anything by 0, but that is the only change I did to what Aprone wrote on the first post.After this gets figured out, I went ahead and worked out the panning line:h = math.cos(relativetheta * 3.14 / 180)And it returns a positive number, even though the sound should be negative.If anyone can let me know what is going on, I would love to know!Thanks,

URL: http://forum.audiogames.net/viewtopic.php?pid=201807#p201807




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector