# how to script a match 3 game without waiting for matches to finish

I have developed a full match 3 game without the ability of making another move until all cascading is finished.

I was stuck trying to figure out how to do it with the ability of making moves even if the previous moves have not finished yet. I can't figure out the programing logic behind it, I tried different approaches with no luck so far, the results came up messy.

Can any one help.

-
I'm curious: if a piece is about to fall, do you want to be able to use it in a match (by moving another piece) before that piece starts falling, or is your question only related to parts of the board that aren't affected by moves currently being resolved? – sam hocevar Dec 8 '11 at 14:27

You should have a model that represents the board, typically an array with rows and cols. As the tiles fall, they may do so at the same or even different rates, once they have completed traveling the distance required to cover one space, they de-list themselves from their starting location, and list themselves with their new location.

Some notes:

• It is wise to measure this based on the center of the tile, such that once the center has moved into the next cell, you count it as in that next cell. This will look better overall.
• Separate the model of where the tile is, from how the tile falls. Once you've detected that the tile is above an empty cell, have it enter the free-fall mode, sending off 'I've switched cells' notices as it moves down a cell. Falling more than one cell down will naturally arise from this and you will not need to create logic to control that.
• This all assumes you don't have a rotating board or anything fancy like that.
• This is by no means the only way to do it, it just is one way to do what most match-3 games do.
-
If you want an interesting twist on the game play, slow the falling down significantly and have the tile count as if in both spots. This will give players some interesting choices based on timing, and add time pressure to a game that typically has none or only a countdown timer. – DampeS8N Dec 8 '11 at 16:02
Thanks a lot, that was helpful. – Amjad Yahya Dec 9 '11 at 8:41
Thanks a lot, that was helpful. I already have an array that holds the info about the board, the only thing I did not do right and made my board get messy is that I did not store a flag of the falling tile in the array but rather in the object itself. Thanks to you I realized that now and the game is working nice. Good job. – Amjad Yahya Dec 9 '11 at 8:49
@AmjadYahya I'm glad, perhaps you can select this as the correct answer then? – DampeS8N Dec 9 '11 at 15:45