Game Development Community

Match check function?

by Tom Biagioni · in Technical Issues · 11/07/2008 (12:58 pm) · 3 replies

How would i go about making a match check function similar to that of bejewed, or even tic tac toe. What im looking for is to have an algorythm that checks each row and column for matches and potential matches, and if a match is found it deletes the matching objects and gives a score.

Thanks!

#1
11/10/2008 (5:08 pm)
In general, go through each jewel on the board. At each jewel, count how many like jewels there are to the East, Southeast and South (ie, looking North from the bottom jewel is just like looking South from the top jewel). When you have that count, you can determine what to do. In tic-tac-toe you need exactly three and then you win. In Gomoku you need exactly five and then you win. In Bejeweled, you need three or more for a match. You could have those matched jewels animate away or morph into new jewels, drop jewels, anything you want.

In terms of looking, use a recursive function like "look(%x, %y, %direction)" that returns the number of jewels that match.
#2
11/24/2008 (6:53 pm)
Isaac released his Match-3 code here
#3
12/04/2008 (9:32 am)
Thanks! THis gives me some good insight:)