We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi there, I am having problems making a ball-line collision method work for an array of balls and a seperate array of lines.
it works for the first element of the movers array if i call the function like so:
for (var t = 0; t < superLines.length; t++ {
superLines[t].collision(movers[0].position.x, movers[0].position.y, movers[0].mass*16);
}
however, when I have a nested loop, like the following:
for (var t = 0; t < superLines.length; t++ {
for (var q = 0; q < movers.length; q++ {
superLines[t].collision(movers[q].position.x, movers[q].position.y, movers[q].mass*16);
}
the method doesn't even work for the first element in the movers array!
I haven't used a var called q anywhere else in the code :S anyway, I've been stuck for a couple of days on this and googling hasn't helped, although its likely i'm searching the wrong terms.
I'm really confused about the whole thing as I thought that was how you would call such a function and would greatly appreciate any clarity anyone can offer!
I can include the whole code if necessary, but I didn't want to pollute the page as it's about 600 lines long.
Thanks a lot for reading, Leon
Answers
for ( ;; )
loops I can't pinpoint any further bugs.for ( : )
approach can make things clearer for bug hunt.show your entire code please
you can change the method
collision
and make it so that you can pass the object
movers[q]
to itthe
collision
method can then accessposition.x
andposition.y
etc.;-)