How do I match a group of connecting blocks

Get help using Construct 2

Post » Mon Aug 08, 2016 2:49 pm

Hi

I'm wondering how to do a check to see if a group of the same items are connected. Like this:

Image

I want the blue ones to be destroyed. I have looked at some match3 tutorials, but they don't do grouping like this, and they are insanely complicated. If possible, I need it to be as lightweight as possible, it's for the Wii U.
B
10
S
3
Posts: 65
Reputation: 780

Post » Mon Aug 08, 2016 6:12 pm

I guess by using plugins and this is about as simple as it gets:
https://www.scirra.com/tutorials/5000/r ... ion/page-1

Match 2, incredibly easy. Match 3, yeah that's going to require some logic.
B
47
S
17
G
81
Posts: 2,230
Reputation: 48,107

Post » Mon Aug 08, 2016 7:32 pm

Basically it's done by looping over all the pieces and flood filling to the other pieces of the same color. Use a variable to label each group and to make the pieces that were processed already.

The only optimization is to use an array to do a piece lookup instead of picking by collision or general picking.

Here's an example to peruse:
https://dl.dropboxusercontent.com/u/542 ... match.capx
B
94
S
33
G
114
Posts: 5,359
Reputation: 73,779

Post » Mon Aug 08, 2016 8:26 pm

Oooooo nice :D
B
47
S
17
G
81
Posts: 2,230
Reputation: 48,107

Post » Tue Aug 09, 2016 10:05 am

Thanks!
B
10
S
3
Posts: 65
Reputation: 780

Post » Fri Sep 16, 2016 11:56 am

R0J0hound wrote:Basically it's done by looping over all the pieces and flood filling to the other pieces of the same color. Use a variable to label each group and to make the pieces that were processed already.

The only optimization is to use an array to do a piece lookup instead of picking by collision or general picking.

Here's an example to peruse:
https://dl.dropboxusercontent.com/u/542 ... match.capx


I have tried to analyze you example the best I can, but I just cannot get it to work with anything, nor how to modify it to suit my needs. Here's the capx I'm using - https://www.dropbox.com/s/t2yce9669c21g ... .capx?dl=0

I need the matching to happen once the icons have stopped falling, if there's at least three or more in group. I'd be forever grafeful for any assistance.
B
10
S
3
Posts: 65
Reputation: 780

Post » Fri Sep 16, 2016 5:50 pm

@Xeeko

Here is an example that matches clusters of 3 or more pieces and then applies gravity.

The Matching bit is based on an example posted by ROJOhound (flood fill) but I don't have a link to the original.


ClusterMatch capx-

https://drive.google.com/open?id=0B4jH2 ... E1aV2xqZDg
Last edited by chrisbrobs on Sat Sep 17, 2016 5:18 pm, edited 1 time in total.
B
21
S
5
G
8
Posts: 1,215
Reputation: 7,834

Post » Sat Sep 17, 2016 7:26 am

chrisbrobs wrote:@Xeeko

Here is an example that matches clusters of 3 or more pieces and then applies gravity.
It is based on an example posted by ROJOhound (flood fill) but I don't have a link to the original.

ClusterMatch capx-

https://drive.google.com/open?id=0B4jH2 ... E1aV2xqZDg


This looks like it should work, thanks!
B
10
S
3
Posts: 65
Reputation: 780

Post » Sat Sep 17, 2016 4:59 pm

FloodFill, how it works a bit explained.

https://googledrive.com/host/0BxsKkJ-_V ... index.html
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 21 guests