# Bubble shooter: disconnected bubbles fall down

Get help using Construct 2

### » Wed Jan 16, 2013 3:22 pm

Hello fellas,

May be there are some effective algorithms how to achieve this mechanics in bubble shooter:

- bubbles or bubble groups, which don't connect to neighbors fall down

Right now I'm using a recursive function which goes through all the bubbles in the hex-grid and checks with a flood-fill if bubbles connect to the upper border. It works, but the problem is, that this calculation is very resource intensive and there is a lag each time this calculation takes place. So it is called for each bubble recursively.

Do you have any ideas how to do it in a different way?

xoros2013-01-16 15:23:54
B
42
S
11
G
4
Posts: 505
Reputation: 7,267

### » Sun Apr 07, 2013 5:13 pm

im looking this too
B
93
S
19
G
34
Posts: 1,840
Reputation: 27,958

### » Sun Apr 07, 2013 7:32 pm

I made a bubble shooter capx a while ago. It also found connected bubbles with a flood fill algorithm. It only did it when a bubble landed as there is no reason to do it continuously. I also thought the lag to not be a problem because of when it occurs.

Some ideas to make it faster:
1. Lookup the capx I made and see if my implementation of flood fill is more efficient than yours.
2. You could limit the amount of lag by doing the flood fill over multiple frames.
3. As a last resort you could come up with some type of data structure to make the flood fill more efficient by making the picking of a bubble's neighbors a simple lookup instead of a collision check against all the other bubbles. In theory it will be much faster, but it will require a lot of events and be very tedious to setup.R0J0hound2013-04-07 19:32:46
B
79
S
24
G
52
Posts: 4,724
Reputation: 39,711

### » Thu Jun 06, 2013 10:11 pm

Distributing a heavy recursion/loop over multiple ticks is a clever technique, indeed.
B
42
S
11
G
4
Posts: 505
Reputation: 7,267

### » Tue Oct 08, 2013 2:11 pm

Hi xoros,

i'm working at a Buble Shooter like game, until now i've managed the mechanics for picking/distroing connected bubbles, but now i need to destroy the groups of bubbles which are not connected with any bubbles. As i see in your first post, have you found a solution for this issue?
B
5
Posts: 10
Reputation: 270

### » Fri Oct 18, 2013 10:55 am

Hi,
I've this problem too for bubble shoot, anyone can help?
B
4
Posts: 3
Reputation: 256

### » Fri Oct 18, 2013 2:20 pm

Guys, this post will be helpful for you. There's a very good capx. example by R0J0hound:

http://www.scirra.com/forum/bubble-shooter-ball-colisions-placement_topic62091.html
B
42
S
11
G
4
Posts: 505
Reputation: 7,267