Thanks for the feedback verilog!
verilog wrote:
I love Puzzle Fighter (I especially like Mortal Kombat's take on it, both puzzle games are great).
Ah cool, didn't realize Mortal Kombat did a version, I gotta check it out.
verilog wrote:
I haven't looked at the code yet, but may I ask how are you clearing same-color blocks? I tried to create a puzzle fighter clone myself a few years ago, and I remember trying to implement a flood-fill like-algorithm, as traversing the complete block matrix would become pretty slow under certain conditions.
The block-clearing part was the most fun to implement, didn't realize what I wrote had a name though. I was thinking of it as a modified breadth first search. Basically it works like this:
* Whenever you place a crash block, store it in a special index mapping color to a table of references the crash blocks with that color.
* After placing any block, apply gravity first so that if you place the block pair horizontally with only one block having a solid floor, the other will fall before trying to clear block chains.
* Once everything is settle, start clearing blocks:
* Using each crash block in the crash block index as a starting point, find the chain of blocks with the same color. I use a table as a LIFO stack to keep track of the potential members of the chain (called the fringe). The find chain algorithm goes like this:
* For each iteration, pop a block off the fringe
* If it's the right color, and I haven't seen the block before, add it to the chain, mark it as seen, and add its neighbors to the fringe if they're the right color and I haven't seen them before.
* I apply the find chain function to each block in the crash block index, and share the lookup of seen blocks between the blocks of the crash blocks of the same color to avoid redundant chains, while still allowing for catching disjoint chains.
* After each found chain, remove the blocks in the chain if the chain is > 1, making sure to remove crash blocks from the index as well.
* If any blocks were removed, apply gravity, then repeat the block clearing until no blocks got cleared
I think it's pretty efficient because of the crash block index, not re-checking the already checked blocks, having O(1) lookups for the already checked blocks and the finding of neighbors, though I probably should profile it on larger grids with complex chains.
verilog wrote:
I know this is an early iteration, probably you'll fix this in the future, but I was expecting the blocks to fall automatically and be cleared as soon as they contact same-color blocks.
I think it does this, no? Well, they only start getting cleared after it hits a floor, if there are blocks of the same color next to a crash block that's still falling, it won't start clearing the blocks out until the crash block finishes falling.
verilog wrote:
Also, are you thinking about adding “power/rainbow/counter gems” or other power ups? Mortal Kombat's version offers some interesting variations on these. Other than those details, I think it's looking pretty good so far!
Yeah, I wanna do counter gems, though that means adding adding a second player, either computer or human. Although now that I think about it, I could just have them appear randomly as the blocks you're placing. What are rainbow and power games?