Array Pattern Check

For questions about using Classic.

Post » Thu Feb 07, 2013 6:40 pm

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?
B
3
S
1
Posts: 59
Reputation: 568

Post » Fri Feb 08, 2013 3:00 pm

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.
B
6
S
2
G
5
Posts: 249
Reputation: 2,323

Post » Fri Feb 08, 2013 3:45 pm

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.
B
3
S
1
Posts: 59
Reputation: 568

Post » Fri Feb 08, 2013 8:23 pm

I cant post to much, I'm at work I'll get in trouble
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.
Bartosh2013-02-08 20:29:18
B
6
S
2
G
5
Posts: 249
Reputation: 2,323

Post » Fri Feb 08, 2013 8:40 pm

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
B
79
S
24
G
54
Posts: 4,752
Reputation: 40,767

Post » Sat Feb 09, 2013 12:19 am

[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.

Bartosh2013-02-09 00:43:31
B
6
S
2
G
5
Posts: 249
Reputation: 2,323

Post » Sat Feb 09, 2013 1:13 am

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.RandomDood2013-02-09 04:16:39
B
3
S
1
Posts: 59
Reputation: 568

Post » Sat Feb 09, 2013 12:52 pm

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.
B
79
S
24
G
54
Posts: 4,752
Reputation: 40,767

Post » Sat Feb 09, 2013 5:41 pm


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.
B
6
S
2
G
5
Posts: 249
Reputation: 2,323

Post » Sat Feb 09, 2013 7:29 pm

[quote]--------------------------------------------------------------
"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.

-------------------[/quote]
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.capR0J0hound2013-02-09 19:47:54
B
79
S
24
G
54
Posts: 4,752
Reputation: 40,767

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest