Game Development Community

Planet puzzle league style matrix checks

by Backman · in Torque Game Builder · 05/25/2007 (1:28 pm) · 2 replies

Ok, that title must confuse most of you..

Basicly I'm wondering the best way to tackle the issue that comes when playing games such as planet puzzle league ->

http://uk.ds.ign.com/objects/887/887109.html

You drop a box, and then you check all 4 directions for a match in a tetris type playing field. If there's a line that gets taken out and the blocks above drops down, the game should check those new block positions for further lines.

What I'm doing is causing me a bit of trouble so would like a fresh new take on it by you guys if possible : )

Thanks!

#1
05/25/2007 (6:58 pm)
I never tried to implement this, but what comes to mind would be this:

1) walk along each block in a single row, keeping track of matching blocks
2) when you reach enough blocks to make a valid delete, flag all the appropriate blocks for deletion
3) repeat for all rows
4) repeat same process for all columns
5) perform the actual deletes, update scores, etc
6) update block positions to fill the gap (make the blocks "fall")

this should be pretty easy assuming you're keeping track of all the blocks and their grid positions
#2
05/26/2007 (4:45 am)
Thanks Matt, that's quite like how I am trying to do it but it's getting a bit complicated.. I think it's my code rather than the logical thinking behind it. Will try to clear it up and see how it goes..

Just about flagging the blocks for deletion, I'm using a matrix for that called $solutions[x], so 1st solution (line for deletion) contains starting block pos and end block pos. Then I'd go through this matrix until $solutions[x] equals 0, which'd mean no solutions left.

Is that the best way to do it?

Also, I'd like the blocks falling to be in tetris like formations, but using TGB sprites stuck together (not a la the TGB tetris example on this site so I can have smooth movement), and those sprites of blocks should break apart when landing, so they need to be seperate objects.

I'm not sure how to do this best.. mounting eg 4 blocks to a hidden point? Spinning these blocks around could give me problems with collisions against each other since I'm using TGB's collisions.. maybe switching collisions for falling and landed blocks could work.

Just want to see if I'm going down the right route here. Thanks again! :)