I’ve been struggling with my remake of sega’s “Columns” match 3 game . I want to use a 2d array to store the grid, and unity 3d objects to store the “visual” of the grid. Including the use of a 3d perspective camera, not a 2d orthographic view.
“Rules”: Its consists of a grid 6 tiles wide and 13 tiles tall. 6 different color gems. The gems drop in a set of three from the top. You have to match 3 or more same color gems in ANY of the 8 directions (horz,vert, diagonals). You can SHIFT the gems vertically in there “3 cell space” before you hit a gem or the bottom of the board below it. When a match of 3 or more either horz, vert, or diagonally is found, the gems destroy and the gems there were above the destroyed ones, slide vertically (only) downward to fill the gaps.
.Im sure you’ve heard of it? Lol
“The Question”: What I would like to discuss is: What is the best way to setup or organize memory arrangement (I’m using a 2d array for the grid and no rigid body for collision), to accomplish match making and grid “resettling” after gems are removed?
“My Thoughts”:
0,0 (x,y) starting at lower left most square of 2d grid.
I was thinking of making my gems each be a different integer for each different color on the grid…red=1,green=2 ,3 = blue, 4 = yellow etc…etc. 0 = an EMPTY tile. I will not be using rigid bodies for the collision detection.When the dropping gem hits the bottom of the board or another gem below. Then it starts the check for say, all 1’s (red) or all 3’s (blue gems) in a row, each match has to be connected by 3 or more of the same numbers (gems), that way you only have to check and see if there is anything in the tile if so, the “color” is based on the Integer. Then check for neighbor tiles of same type and so on. I was going to use Generic LISTS to save all the matches in for final destroying and removal. I was tying to think about how to set this up by kind of starting partially “backwards” with the process. I.E. all the gems have already matched, and have been destroyed, now its time to take the board and “resettle” all gems on it, making a rolling list of the new “base” gems as we will need somewhere to start our new “start match check” from… To update the actual Visual aspect of this, I was thinking of having a “copy grid” of the array, but this one containing the actual GAME OBJECTS instead of just a bunch of integers. This way when it came time to destroy and resettle gems on the screen, we can just “tell” every block where to move as it is setup the same way as our grid we use for matching the integers (which represent the gem gameobjects in memory) (see the pics) So hypothetically if going by my crafty (crappy) picture , and we needed to destroy the gem in the tile at (0,0), and since the “4” on the grid on the left has the same index as the “yellow heart shape” as the grid on the right, we just destroy the object in the “game object array” ,reorganize the gems, indexes, and REPEAT?
I tried writing this a few different ways before I posted this message. I have not written it the way I am speculating of doing above…
“Notes”: I am using the same method to detect “collision” and “move” my blocks around as did the author of the UNITY TUTORIAL of TETRIS.
Looking for some serious thought or experience on this?
Thanks King