Crash Blocks: a simple Puzzle Fighter clone

Show off your games, demos and other (playable) creations.
Post Reply
User avatar
clofresh
Citizen
Posts: 87
Joined: Sun Jul 26, 2009 4:21 pm
Contact:

Crash Blocks: a simple Puzzle Fighter clone

Post by clofresh »

Hey guys,

I created a simple Puzzle Fighter clone called Crash Blocks. For people who've never played Puzzle Fighter, it's kind of like Tetris, except instead of completing lines to clear them, you need to match colors with the same colored crash gem. Also, it's meant to be 2 players, and when you clear blocks, they get sent over as junk blocks to the other player. My version is only single player, I haven't tried creating multiplayer or an AI yet. Also, I tried to add a bloom shader but it doesn't look so hot, not sure why.

Even though it's very basic, I think it's probably the most complete game I created in that I can keep playing it for a while without getting bored :cool:

Screenshot:
Crash Blocks-1.png
Crash Blocks-1.png (16.68 KiB) Viewed 3277 times
What do you guys think I should work on to make it more fun/polished?
Attachments
crashblocks-0.1.love
(4.55 KiB) Downloaded 138 times
----------------------------------------
Sluicer Games
User avatar
verilog
Citizen
Posts: 97
Joined: Thu Nov 03, 2011 3:15 am
Contact:

Re: Crash Blocks: a simple Puzzle Fighter clone

Post by verilog »

Hi, clofresh

I love Puzzle Fighter (I especially like Mortal Kombat's take on it, both puzzle games are great). Your version is looking pretty solid for now, I played for a while and it seems you got all the basic functionality ironed out. 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.

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. 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! :D
User avatar
clofresh
Citizen
Posts: 87
Joined: Sun Jul 26, 2009 4:21 pm
Contact:

Re: Crash Blocks: a simple Puzzle Fighter clone

Post by clofresh »

Thanks for the feedback verilog! :D
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! :D
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?
----------------------------------------
Sluicer Games
User avatar
verilog
Citizen
Posts: 97
Joined: Thu Nov 03, 2011 3:15 am
Contact:

Re: Crash Blocks: a simple Puzzle Fighter clone

Post by verilog »

Here’s MK’s version.

Thanks for the detailed algorithm explanation! It really resembles a stack implented flood-fill algorithm; if I recall correctly, the complexity for the flood-fill algorithm is O(n) where n is the number of target-color nodes. Power gems are stacked blocks of the same color, in Puzzle Fighter stacked blocks of the same color produce a “blob” or “power gem” of size equal to the neighboring blocks:

Image

“Rainbow gems” or diamond “gem” is the special power-up that appears every determined number of drops and clears all blocks with the same color as the block the diamond is dropped on:

Image
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: Crash Blocks: a simple Puzzle Fighter clone

Post by Roland_Yonaba »

Awesome.
For what it's worth, I have been experimenting different floodfill algorithms (9 variations, actually). It went quite well, then I packed it as a command line program, in plain Lua, to be used by anyone.
Find it on Github, detailed instructions are all in the Readme.
Post Reply

Who is online

Users browsing this forum: No registered users and 174 guests