Okay I have a game I’m working on that sets a 12×16 grid on the screen and then draws a pattern on the screen like so http://oi49.tinypic.com/53odih.jpg
I’m just wondering if there is a way using code to see if the box exists inside of the pattern or not?
This is how I’m looping though my grid boxes
//Set all blocks to default
for(int i=0;i<tilesX;i++){
for(int j=0;j<tilesY;j++){
blocks[i][j] = 0;
}
}
If a block is part of a pattern I set the block to 1. I want the blocks inside the pattern set to 2, but I can’t think of a way to do this programmatically. The pattern will always be a complete shape and will always connect back to the starting point.
I hope that’s not too confusing and I’m willing to provide you with what ever you need but I’m just lost on how to do it. Thanks
You need to implement the flood fill algorithm. Depending on how you draw the state of 2, you can flood fill the area starting at a known point inside the shape. Then check to see if its 0 (outside), 1 (border), or 2 (inside).
I think I’m grasping what you want here, but let me know if I’m off base.