playMaker

Author Topic: Need help with "Tetris" or "Match 3" puzzle logic  (Read 2881 times)

spiralKing

  • Junior Playmaker
  • **
  • Posts: 50
Need help with "Tetris" or "Match 3" puzzle logic
« on: January 20, 2014, 03:54:01 PM »
So I'm stuck trying to figure out how to get Unity to tell when the right blocks are matching


Example:

I get 3 identical blocks in a row (one next to the other), how do I get Unity recognize that these blocks are aligned and it's ok to destroy them (like Tetris or Match 3)

Collision, Tags, maybe?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Need help with "Tetris" or "Match 3" puzzle logic
« Reply #1 on: February 03, 2014, 03:38:55 AM »
Hi,

 I would use ArrayMaker:

https://hutonggames.fogbugz.com/default.asp?W715

 maintain Lists of all your possible lines, and when a block is on a final position, inject that block reference into the appropriate list. then it's either case of checking the number of items on a list or going through the list content and validate that the blocks matches.

you can also take a more harcoded approach, like for Tetris, everytime a block is reaching it's final position, go over each line starting from the left block and if it matches the block on its right, you record them block as potential blocks for clearance, if the next block is still matching, then it will be cleaned up, if not, you lower the clearance flag and keep checking for the next item until the line if done, and then you do the same for the next line.

 The other option would be to search the web for some proper algorythm, maybe a solution exists already to ease that process already.


bye,

 Jean

spiralKing

  • Junior Playmaker
  • **
  • Posts: 50
Re: Need help with "Tetris" or "Match 3" puzzle logic
« Reply #2 on: February 05, 2014, 05:54:52 PM »
Thanks

didn't know playmaker had add-ons

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Need help with "Tetris" or "Match 3" puzzle logic
« Reply #3 on: February 06, 2014, 02:52:08 AM »
Hi,

 Yep, very important!! There are tons of goodies and productive tools for you on the wiki.

bye,

 Jean