Array Pattern Check

This forum is currently in read-only mode.
0 favourites
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • I am using an Array to create a play field. I want to see if objects on the field are arranged next one another in different patterns that I make. Can I make a .txt file or something like that and have the array read it to see if objects are arranged in that pattern? Is there a better way to do this with or without using an array?

    Bonus question, but not really my focus.(yet) How would I go about being able to check and see if the objects in question are matching either by animation frame or multiple instances of an object?

  • So what exactly are you trying to do? something like the puyo puyo game you brought back from the dead? It would be a radically different system than say, bejeweled.

    Plus there's normally always more than one way to solve a problem, and the best choice is based on context.

  • I am trying to do something like the Puyo Puyo game yes. I originally thought the two where pretty much the same. But Puyo Puyo has a more appealing and dynamic realtime matching system.

  • I cant post to much, I'm at work I'll get in trouble <img src="smileys/smiley2.gif" border="0" align="middle" />

    later this evening ill explain more.

    but to get you started, seriously look at my array astar system, and TRY to get whats going on, what your going to need to do is actually rather similar. its going to be a checking algorithm.

    actually your whole game will run best if its mostly done in an array. then later represented on the screen.

    it's going to be hard, but i think you'll really like what you learn.

    Arrays are seriously one of the most powerful things in construct.

  • It basically is done with a floodfill. You can get the algorithm off of Wikipedia.

    I don't have any examples for CC but here are a few for C2 which can serve as a guide to do it in CC.

    http://www.scirra.com/forum/matching-more-than-3-sprites-gem-matching_topic51703_post326543.html#326543

    http://www.scirra.com/forum/in-something-enclosed-or-is-it-just-me_topic53841_post340661.html#340661

  • [Earlier I meant tetras, not bejeweled, bejeweled is handled the same] sorry.

    Damn, i was getting exited for the big reveal.

    The only thing I can add is, when it comes to data storage, .txt are best for lots of specific complex information that needs to be called with precision.

    so object specific data, or story elements.

    and Arrays are best for lots of similar simple data that needs to be searched as a whole, normally numbers.

    so anything using tiles.

    ---------------------------------------------------------------------

    I was thinking of making some sort of tutorial for you about filling, but apparently It's well documented.

    Seems like every time i do something like that, its just a practice in futility.

    Since C2 always has a plugin or a something.

    No bitterness or anything, big props to R0J0hound for taking the time to come down and help.

    But I'm beginning to think the best method for someone using Construct Classic to get help is to just learn the slight differences between CC and C2 and post your problem over in the C2 help section. It gets a lot more traffic. and it seems like the only place the big boys stomp around anymore.

    ------------------------------------------------------------------------

    ....I got my 2,000 points YEAH! LOL

    And with that, I'm dropping the mic.

    I believe I'm done with the CC help forum

    And I think I got only 2 more post to make, then I'm gone.

    But while I'm getting that ready over the next weekend, if anybody has any questions about arrays, picking problems , or just general ideas on how to go about a large project. Just PM me. I know probably more than I should.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks to both of you for the help. (And I forgot to thank Bartosh for helping me with a post a long while back so thanks again.)

    Assuming that either of you guys come back. I had questions for you both:

    R0J0hound: I understood your flood fill example up until action #5. I don't understand why the detector doesn't check other sprite separated by the gaps while having a pick all sprite action. Also didn't get how changing the size to 32x16 for horizontal and 16x32 for vertical makes a difference for an overlapping check when the sprite is 32x32.

    Edit: Tried in CC. Unless I did something wrong it wont work. There is no system pick all objects so I tried substituting it with pick by comparison "animationframe" = #

    Bartosh: If I understand your A* example correctly you use a 3d array to store multiple variables for objects in the same space am I correct? So going with the Puyo Puyo example, I am guessing that I would:

    1) Check to see if a color block/blob is moving and if not, search for the array coordinates that correspond to the block's position. Maybe set some PV for the block to stores which array it is representing.

    2) Set array (x,y,Z1) to represent the color of the block,

    3) Run an array loop and check to see if the colors next to it match.

    4) Set array (x,y,Z2) to represent a pseudo var "match"

    And probably a lot of other things I can't think of right now.

    I would say my biggest issue is figuring out how to match individual blocks, group them together without their values bleeding into other groups, and mark specific groups for destruction. The grouping is important because in most games like this, the score bonus is dependent on how many matches of a group of colors you get. So if I get groups of (6 red, 4 blue, 3 red) the score bonus would be something like (x6, x4, x3). -> calculate bonus then destroy each group.

    Thanks again for the help and I think I'll take your advise and post in the C2 forums and transfer my issue back to CC from now on.

  • Everyone is so mournful in the CC forums. For the record I read new postings in the CC section just as often as the C2 section if anyone thinks they go unread. Unfortunately I usually only reply after implementing a solution that works.

    Anyway,

    RandomDood in C2 two objects that are touching but not overlapping count as an overlap. So when the the sprite is 32x32 other sprites in all 8 directions are overlapping. With 16x32 others above and below will overlap, and with 32x16 only horizontal will overlap.

    When converting from C2 to CC or vise versa the subtle differences can pose a problem so I usually try to understand what one is doing an then implement it from scratch into the other.

    I need to get to sleep now, but I'll try to wip up an example in CC tomorrow.

  • Well I guess I jumped the gun as far as being done with this particular post. I don't want to leave you hanging and confused.

    your right about the z variables

    but my point of the A* search was to get you thinking in terms of doing EVERYTHING in side an array. To the point you could destroy all the sprites,and re-create them, and the game would still be running fine.

    falling, stacking,checking, filling, flipping ext.

    It would be a process more akin to how they actually programmed those games, however its a little more abstract, and requires you to think like a computer.

    I've been working so much with arrays,functions, and loops, I forget how confusing they can be to work with.

    R0J0hound's method is object oriented, and takes advantage of the features of construct. Its probably alot easier to rap your head around whats going on. even if its not working the "same way" .The ideas the same, and people wouldn't be able to tell the differences.

    so ether ways fine, but since your new, I'd go with R0J0hound's.

    He's been around the block. and has a lot more experience helping people than me.

    ----------------------------------------------------------------------

    It's pretty rough when one of the key creators of the project says he plans on letting the CC forum die.

    I think its a good reason to be mournful.

    But whatever, for me personally, its kinda a good thing.

    --------------------------------------------------------------

    "Unfortunately I usually only reply after implementing a solution that works."

    I don't know if that was a jab at me personally, but

    If not:

    -----> I think the best method to help teach people is one of cooperation and joint trial and error. Teach a man to fish and all that.

    if so:

    ----->go &*@# yourself.

    -------------------

    NOW I'm done.

  • -------------------------------------------------------------

    "Unfortunately I usually only reply after implementing a solution that works."

    I don't know if that was a jab at me personally, but

    If not:

    -----> I think the best method to help teach people is one of cooperation and joint trial and error. Teach a man to fish and all that.

    if so:

    ----->go &*@# yourself.

    -------------------

    There was no jab intended. I was simply stating how I operate.

    EDIT:

    RandomDood here is the flood fill cap example:

    http://dl.dropbox.com/u/5426011/examples16/floodfill.cap

  • well then I'm sorry for any perceived ill will.

    I know feeling in text can be easily misunderstood

    thus my boolean response

  • Both of you helped me out a lot. I am actually going to see if I can use both of these. I'm an artist and not very good with programming so R0J0hound's example is a bit easier to understand. But I do have some basic programming knowledge and experience with arrays so I have an idea how I can use arrays to add in a bonus feature I have been thinking about.

    I may have more array questions down the road though.

    Just out of curiosity, does it make a difference when using either an object focused "coding" or an array/programmer focused "coding" in construct 2 and or classic? Is one faster than the other, less errors, less processor heavy, or more optimized?

    Thanks again

  • Using an array would be faster for the flood fill, but it may take more events.

  • Cool It works. Now all i need to do is figure out a way to group the objects if they are matching and I'll be done.(mostly) Kind of like:

    scirra.com/forum/picking_topic62950.html

    but updating each block to a group in real time.

    Edit: This is possible right? It would make me feel better knowing I have just be doing something and not something impossible.

    Update: Finally figured out something that works. Its not perfect but at least its something.

    Thanks again for your help.

  • I actually got a little off topic from this post title. How would I go about getting an array to reading a bunch of different patterns? Would I have multiple .txt files each with a pattern in it?

    IE.

    file 1

    -111-

    --1--

    -111-

    file 2

    11111

    1----

    111--

    etc.

    Also I am assuming it is possible to offset the pattern check right?

    IE.

    Pattern

    1---1

    11-11

    -111-

    Array with the pattern.

    -------

    -------

    --1---1

    --11-11

    ---111-

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