Hey everyone,
First of all thank you all very much for your tips and tricks I’ve learned here. I have a dilema right now with a tile game, Hexic.
Currently, I have my pieces properly adding to the grid.
for (var a:Number=0; a<nTotalRows; a++) {
gridArray.push(new Array() );
}
for (var A:Number=0; A<nTotalRows; A++) {
for (var B:Number=0; B<colNum[A]; B++) {
if (A%2!=0) {
addPiece(A,B);
} else {
addPiece(A,B+0.5);
}
}
}
The extra 0.5 in addPiece is an offset for every odd row. If it is odd, the pieces in that column will be offset by half in the y direction.
I am having some major trouble checking for matches of 3 or more. The problem I am having is that when the user clicks and changes the location, row and col of 3 different tiles, I don’t know the best method of checking for matches.
Originally I was checking the currentTile[row][col].type and comparing it to tiles in the above col, or below col, and if there were more than 3 of the same type I would push them to their own array. Vertical checking has been Okay because they vertical pieces do not have a X offset. The horizontal checking is messing me up because every second column is offset by half of a piece.
So, my grid is technically set up like this:
gridArray[row][col] … where row is 0 - 9 across and col is 0 - 9 (but depending on the row, the column is either whole number or decimal number (from the offset))…
Yea, it’s confusing. I would greatly appreciate if anyone could give me a little direction on how I should go about checking for matches in all 6 directions of each tile, or any tips.
Thanks in advance…