"Find all tiles connected to this one" project

Posted by Omega on Stack Overflow See other posts from Stack Overflow or by Omega
Published on 2011-01-29T23:24:11Z Indexed on 2011/01/29 23:25 UTC
Read the original article Hit count: 152

Filed under:
|
|

Remember MS Paint? The bucket tool? If you used it and clicked on a pixel, all pixels connected to this pixel that are the same are affected. The theory is, I suppose, to check if there is any pixel adjacent to the selected one. If such pixel is the same type as the selected one, check for more adjacent pixels in this one, and so on.

I want to implement something similar in VB.NET. Basically I have a 2D array map which represents the map. Let's assume there are only two types of tile: 0 and 1.

Now, I got pretty much everything ready: I got my 2d map and I can tell which tile is clicked and tell what array indexes are the ones that represent such tile.

Now for the "painting" process. Whenever I think about it, I can't figure a convenient way to execute such iteration. Can someone help me choosing a correct design/way/tip to achieve this?

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about 2d-array