checking groups in a 2d array
Posted: Mon Nov 09, 2009 6:10 am
Hey,
I'm working on a puzzle game of the puyo-puyo style falling colored blocks variety. I've got the graphics set up and all the dropping action in place, but now I seem to be a bit stumped on how to test if the blocks are in groups of four together.
The board is currently represented by a 2d array that I just set up in load like this:
row[1] = {0,0,0,0,0,0,0,0}
...
row[8] = {0,0,0,0,0,0,0,0}
There's four colors, so each color is represented by a 1-4 in that space, and 0 is empty. Simple, right? Unfortunately now I can't seem to think of an efficient way to handle checking if the blocks are in groups of four or larger (any shape is fine, square, L-shape, line, whatever). I've sort of come up with ideas, but they all seem to take huge amounts of coding and processes that I feel should be able to be handled more...efficiently? Has anyone else done something like this? Does it just take more work than it seems like it would?
I'm working on a puzzle game of the puyo-puyo style falling colored blocks variety. I've got the graphics set up and all the dropping action in place, but now I seem to be a bit stumped on how to test if the blocks are in groups of four together.
The board is currently represented by a 2d array that I just set up in load like this:
row[1] = {0,0,0,0,0,0,0,0}
...
row[8] = {0,0,0,0,0,0,0,0}
There's four colors, so each color is represented by a 1-4 in that space, and 0 is empty. Simple, right? Unfortunately now I can't seem to think of an efficient way to handle checking if the blocks are in groups of four or larger (any shape is fine, square, L-shape, line, whatever). I've sort of come up with ideas, but they all seem to take huge amounts of coding and processes that I feel should be able to be handled more...efficiently? Has anyone else done something like this? Does it just take more work than it seems like it would?