Looking For Match 3 Help
by John Nangle · in Torque Game Builder · 10/02/2007 (10:51 pm) · 3 replies
Hi all,
I'm an artist who's just getting into scripting with TGB. I've done the tutorials that come with TGB and am looking to move on a bit, specifically, I want to work on a match 3 style game. I know it's probably "groan, not more match 3", but it seems like a simple enough genre to play around in for a rookie like me.
The problem is I don't know how to check the entire board for matches. I've looked around for tutorials but haven't come across anything and was hoping someone here could point me in the right direction.
Thanks in advance!
I'm an artist who's just getting into scripting with TGB. I've done the tutorials that come with TGB and am looking to move on a bit, specifically, I want to work on a match 3 style game. I know it's probably "groan, not more match 3", but it seems like a simple enough genre to play around in for a rookie like me.
The problem is I don't know how to check the entire board for matches. I've looked around for tutorials but haven't come across anything and was hoping someone here could point me in the right direction.
Thanks in advance!
#2
TGB Learning Project
TGB Learning Project (Continued) <- this one has my email address
10/24/2007 (12:38 pm)
If you drop me a note, I can send you my learning project which is a Match-3 'game' focused on getting key features working and not really worrying about making a fun game.TGB Learning Project
TGB Learning Project (Continued) <- this one has my email address
#3
Tilelayers are something important to check out in general.
10/24/2007 (4:52 pm)
If you decide to represent your game board / pieces as a tilemap / tilelayer then you can use that object to check for matches as well, since a tilelayer is essentially a 2d array.Tilelayers are something important to check out in general.
Ricardo Vladimiro
Default Studio Name
In order to keep the pieces, you could use arrays with lists, for instance (and this is just an example, the actual lists would have to be created by your game logic):
new scriptObject (Board) { Line[1] = "1 2 3"; Line[2] = "3 3 3"; Line[3] = "1 1 1"; }This means that in the line 1 column 1 the color of the object would be 1, in the line 2, column 2 it would be 3.
You can also use bidimensional arrays, like this:
new scriptObject (Board) { Pos[1,1] = "1"; Pos[1,2] = "2"; Pos[1,3] = "3; (bla bla bla) Pos[3,3] = "1"; }In any of those you could access the values directly, using Board.Line[ %lineNumber ] for the whole line or, the second example Board.Pos[ %X, %Y ]. Assuming you would do all the logic inside Board functions access would be %this.Line[ %lineNumber ] or %this.Pos[ %X, %Y ].
To check the values, the easiest and worst way would be to recursivelly check every piece using a for statement inside another for statement and run all board checking left and right, up and down.
Hope this gets you started.