[How Do I] Match 3 ?

0 favourites
  • 5 posts
From the Asset Store
snake and ladder game with two characters: turtle and rabbit!
  • Hello everyone!

    Last night, I worked on a capx from 7:00PM to 3:00 AM and didn't get what I wanted.

    I need to create Match3 mechanics for my game.

    I began with creating an array (6,6,1) where the values are Int(Random(4)).

    Then, for each XY, I create an instance of "Gem" (sprite with 4 animations, each being a color). The color is decided by the Int(Random(4)) value (0=Blue, 1=Yellow, 2=Red, 3=Green).

    So, I got a 6x6 board of gems.

    But I need to know if 3 or more cells of the same color are touching.

    So I created an instance var for "gem" that stores the animation name (color), a Global variable called "PreviousColor" and another called "clickCount".

    If clickCount = 0, create a "selection" object over the clicked Gem, store the Gem color in the PreviousColor global var, set clickCount to 1.

    If clickCount =/= 0, check if PreviousColor = Gemme.Color

    The rest of the code is gibberish: newbie attempts to check when same color if both gems are connected, and that doesn't work.

    Since I'm a Newbie and don't know any javascript, I'm wondering if it is possible to make a Match3 game at all, especially when it comes to checking same and adjascent array values.


  • Check out these plugins, courtesy of rexrainbow, they make doing games like that quite effortless: scirra.com/forum/plugin-matcher_topic57512.html

    Demo: scirra.com/forum/bejeweled-plugins-demo_topic62447.html

  • I'm trying to do a game, which uses Match 3 mechanics too. Yesterday I found:


    It takes only five events to generate grid with random objects. Shame there isn't part two (and most likely won't appear), because I'm a beginner too.

    Now I struggle with proper swaping of them.

    EDIT: Thanks, vee41, for these links!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Meh. My previous message hasn't been sent and was deleted on refresh...

    vee41: I'll try that, but I would prefer to understand what I'm doing. Thanks, though, it could be interesting.

    Bluehardt: been there. I think the trick of the "string to generate randomness" is a little bit too much, though. Did the same thing with the Array value at (X,Y) is (Int(random(4)) and the random integer determines the color.

    I wonder if adding a Z-axis to my array could help if I do this:

    the value at (X,Y,2) is 0 on start of layout.

    Then, for each element of the array, I compare the value with the previous, the next, the one above and the one below (so I compare (X,Y) with (X-1,Y), (X+1,Y), (X,Y-1) and (X,Y+1). If the value at (X,Y) and any of those is the same, I add 1 on (X,Y,2).

    That way, I could trigger events if Z>=3...

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