# Puzzle Piece Match Mechanic

I need help figuring out how to make the match mechanic for each individual color. In this game you match 2 of the same color to gain points. Think of this game as puyo puyo at it’s core foundation, or as in the industry we call Minimum Viable Products (MVP). I’m still having trouble with the flip mechanic for the pieces, but right now I’ll focus on the match mechanic. What kind of code do I need in order to make the match 2 mechanic fully operational?

Your code should use a 2D array to keep track of where things are. this way you can use x and y coordinates to look at squares and check things. when you check things you use a loop inside a loop to page through every coordinate. here is an example of setting up a grid of colors, setting some colors on the grid, and finally printing where the matches are:

``````   public Color[,] c;
void Start () {

c = new Color[10, 10];
c [1, 2] = Color.red;
c [8, 8] = Color.green;
c [8, 2] = Color.blue;
c [1, 3] = Color.red;

findmatch ();
}

void findmatch(){
int x = 10;
while(x>1){x--;
int y = 10;
while(y>1){y--;

if(c[x,y]==c[x-1,y]||c[x,y]==c[x,y-1]){
if(c[x,y]!=new Color(0,0,0,0)){
print ("found match next to  "+x+","+y);}
}

}} }
``````