How do I analyze an array grid for 3 or more matching values

0 favourites
  • 9 posts
From the Asset Store
Snap to visible grid - perfect solution for any game genre
  • Can't be much more specific then the subject line lol. I'm trying to detect 3 or more matching values in an array grid, vertically and horizontally... then flagging the value of the x/y in the grid with -1 or something, so the entity corresponding to that point on the array can destroy itself, add points, and reset the position on the array/grid back to empty. If that makes sense... my brain hurts.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • i have the same question, arrays are hard, i dont know if this will help you but this piece of code works perfectly to me:

    With this code i can find 1 value in the array but i need to find another value in the array and if two values are matching then -> action (spawn enemies in this case)

    i am reading this:

    http://www.gamechange5.com/devpage/10

    maybe the answer its here, maybe we need nested loops.. i am still reading

  • I think I might have the wrong idea of how loops work, as well as local variables. I wish the debug panel could should array values in a grid or something..

  • I think I might have the wrong idea of how loops work, as well as local variables. I wish the debug panel could should array values in a grid or something..

    Yes, the debug panel helps you to check if the array is modified, but the next array tool helps me a lot to understand and handle the arrays:

    I partially solved my problem with the array, check the part of the code that solves my problem, maybe can help you too:

    Now i can find two values in the array and if are matching then spawn new enemies, but sometimes didn't work because sometimes just spawn 4 objects instead 5.

  • Can't be much more specific then the subject line lol. I'm trying to detect 3 or more matching values in an array grid, vertically and horizontally... then flagging the value of the x/y in the grid with -1 or something, so the entity corresponding to that point on the array can destroy itself, add points, and reset the position on the array/grid back to empty. If that makes sense... my brain hurts.

    Sounds to me like you're looking for Match-3 mechanics. Rexrainbow has made an example using his own plugins. It's very flexible, but may not be too well suited for beginners.

    I also made a little plugin using the jMatch3 lib. It is less flexible, but easier to use in my opinion.

    Of course you can do this purely with events. I've done several Match-3 engines this way. Basically you just loop through a row/column (pretty much like Majinboo shows with the For-loop), have a variable hold the number of matches, which you get by comparing to the previous piece. If you reach a number of three are greater you have a match.

  • I can't seem to figure out how to pull a value from an array at a 2D position, like variable = (value x-3/y-5)

    edit:

    https://www.scirra.com/tutorials/307/ar ... ers/page-4

    hahaha wow I suck

  • Can any of you see a bust in logic in this? I can't seem to figure out why this wont work...

  • Just thought I'd mention that you can do loopindex("loopheight") to get the value of a specific loop. That way you won't have to store those values in local variables.

  • Are the events in the loop actually cycling or is the engine duplicating the function with each having a progressing loopindex value - running at the same time - making counting cycles with a local variable pointless.

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