Best way to generate pieces in match-3 games, and then tracking them?

Posted by JonLim on Game Development See other posts from Game Development or by JonLim
Published on 2012-11-05T22:02:36Z Indexed on 2012/11/05 23:20 UTC
Read the original article Hit count: 151

Filed under:
|
|

I've been working on a match-3 style game in Actionscript using Flixel, and so far, I've been able to build the core mechanics of the game, including board generation, piece generation, piece swapping and movement, and checking algorithms.

However, I am now running into issues with clearing out pieces and letting the above pieces fall down and generating new pieces.

The reason I'm running into these issues is that when all of the pieces are generated, the pertinent values (position, sprite ID, and sprite object) are pushed into an array that helps me track everything, all the time. When pieces are moved, I swap the values of the corresponding arrays and life goes on.

And that array is the core of my problem: if a row in the middle of the board clears out, ideally, all of the pieces above the cleared pieces should fall down to take their place and new pieces are generated at the top and also fall into place. Except if I try to do that now, all the pieces can fall down, but then I'd have to bump all of their values into the right arrays (oh god my head) and then generate new pieces and fit THOSE into the correct place in the array.

Am I overthinking this? Or is there a far better way to track these pieces?

Thanks guys!

© Game Development or respective owner

Related posts about flash

Related posts about actionscript-3