Match 3 Array Help

Not favoritedFavorited Favorited 0 favourites
  • 12 posts
From the Asset Store
Match 3 Game Gem Pixel Art work for any kind of Match Games.
  • I have been struggling with making an array to check for matches and then destroy those matching colors that are next to each other. Basically, how would I check each cell of my array to look for a match 3 based on color. In the screenshot below you can see how the block comes down the board and then uses boardarray to store its color based on its location in sheet 0. Then on sheet 1 it stores it UID, which could be used to destroy the matches when they are matching.

    The issue I have is that I cannot figure out an check the array for 3 cells that match next to each other then destroy those 3. I did try checking when the block stopped and looked at x-1 and x+1 to see if the colors next to it matched but it never worked right.

    Thank you so much in advance for any help!

    Tagged:

  • It's interesting that you shared a screenshot of the part that works and not of the function that doesn't work.

  • It's interesting that you shared a screenshot of the part that works and not of the function that doesn't work.

    The function doesn't work, and has nothing because I'm not sure if I should us a function. Thanks for the reply though.

  • Maybe this could help you: construct.net/en/forum/construct-3/your-construct-creations-9/match3-template-98-events-186335

    Thank you so much, I will take a look.

  • > It's interesting that you shared a screenshot of the part that works and not of the function that doesn't work.

    The function doesn't work, and has nothing because I'm not sure if I should us a function. Thanks for the reply though.

    If the function has nothing in it then can confirm this is why it's not working :P

  • > > It's interesting that you shared a screenshot of the part that works and not of the function that doesn't work.

    >

    > The function doesn't work, and has nothing because I'm not sure if I should us a function. Thanks for the reply though.

    If the function has nothing in it then can confirm this is why it's not working

    What i meant is that everything I try has not worked. So at this point the function is empty and does not work. I am asking for advice for what I should put in the function to make it work based on what i put in my original post.

  • I would try what you described in the original post checking x-1 and x+1 for a matching type that's why I wanted to see what you tried and isn't working. Also try testing it with delays so you know everything is working as it should. Also rather than a for each block, a for each ordered by something may work better for tracking which block is being checked. Did you check that the array looks correct and as expected btw?

  • I would try what you described in the original post checking x-1 and x+1 for a matching type that's why I wanted to see what you tried and isn't working. Also try testing it with delays so you know everything is working as it should. Also rather than a for each block, a for each ordered by something may work better for tracking which block is being checked. Did you check that the array looks correct and as expected btw?

    Here is what the function did, as it would load the UIDs into another array if they lined up in 3 with a matching color. Then I would destroy those blocks based on their UIDs. I was getting it to load the UIDs into the "horizontalmatch" array but not correctly.

    Thank you again and sorry for the confusion.

  • So we don't need for each block, in fact I don't think we need to pick block at all since we are only dealing with the array. I don't think we need a second array either so you can drop that. The comparison on the left looks good so then for the action you need to change them to empty I guess? and then destroy the blocks that match the array co-ords.

  • So, we have:

    1. An "Array" object, which represents a board with colors. Each cell of the array is a color number.

    2. A "matchedCells" array, where each cell stores the coordinates of cells marked as "Matched".

    Now, all that remains is to check for matches of 3+ colors vertically and horizontally. This is done using loops. Every time the color of the current cell matches the color of the previous cell, we add +1 to the local variable "n".

    Here’s a visual example of how the function that finds matches of 3+ elements in the array works:

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thank you so much for your help and reply. I am going to try this out and report back.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)