Hello everyone,
I am new to Box2D and I am working on a little game with it on XNA/c#.
I would like to know how to approach this problem:
I have a world full of circular objects (marbles), I've been able to make them fall and bounce and draw and whatnot, but the thing I am not sure how to approach is how to get all the surrounding marbles of one of them.
What I want is a marble touches another one, I want to see if they are of the same color and if that is the case, keep on looking for adjacent marbles of the same color, if I find 4 or more with the same color connected, I'll destroy them.
So far I just know how to get the whole world using something like this:
for (var b = _physicsWorld.GetBodyList(); b != null; b = b.GetNext())
But this would be very inefficient to go through for each marble, so I will appreciate any lead, input, help, you name it, to solve this problem.
Thank you for such a great library.
David.
I am new to Box2D and I am working on a little game with it on XNA/c#.
I would like to know how to approach this problem:
I have a world full of circular objects (marbles), I've been able to make them fall and bounce and draw and whatnot, but the thing I am not sure how to approach is how to get all the surrounding marbles of one of them.
What I want is a marble touches another one, I want to see if they are of the same color and if that is the case, keep on looking for adjacent marbles of the same color, if I find 4 or more with the same color connected, I'll destroy them.
So far I just know how to get the whole world using something like this:
for (var b = _physicsWorld.GetBodyList(); b != null; b = b.GetNext())
But this would be very inefficient to go through for each marble, so I will appreciate any lead, input, help, you name it, to solve this problem.
Thank you for such a great library.
David.