Match Game Question
I have a game where there is a grid of 3x3 tiles and each tile is randomly X or O. The user chooses 3 tiles and if all three are X or O regardless of position, they disappear and new random tiles appear. The way I have it set up now, is when the user touches a tile, it increase an integer "Lettercount" +1 and if the user deselects a tile, it decreases "Lettercount" -1. "Lettercount" integer is determining the row on the table that gets populated with whatever the tile is (X or O). If all three rows are a match, they disappear and new ones spawn. This works fine for most instances (user chooses three of the same tiles or user chooses three, deselects the last one he chose and picks a new one).
Here is the bug:
If a user selects three tiles making "Lettercount" = 3, then deselects the first tile he chose, "Lettercount" will -1 to 2 and when the user reselects a tile, "Lettercount" will +1 to 3 and populate row 3 overriding that row and leaving row 1 with old data.
So my question is, how can I prevent this from happening? Is there a better way to structure this?
Any help would be much appreciated as I have literally spent 8+ today trying to solve this and going to bed now just totally frustrated.
Comments
anyone?