How do I fix my awful flood fill in this Puzzle Bobble clone

Get help using Construct 2

Post » Wed Aug 05, 2015 12:17 am

I'm working on a Puzzle Bobble clone for a web design client, and I've got the basic mechanics in - but I couldn't get any of the flood fill examples provided by forumgoers to work right. I eventually devised a flood fill method that works, but very poorly - it's slow and system-intensive, and doesn't loop right. This means that there can be a delay before a bubble match is recognized, and an especially long delay for bubbles that are no longer connected to be recognized as such and be forced to fall - especially when the screen is full of bubbles.

Here's the capx:

https://www.dropbox.com/s/3pb7uwssfw9fs ... .capx?dl=0

And here's a live web demonstration:

http://battlestudio.com/bubblepop/

The controls are - left click to shoot a bubble, middle click to make a new bubble row on the top. There are also touch controls implemented, but no touch debug key for making new bubbles yet.

I can probably make a workable full game with this imperfect method, but I'd really appreciate it if anyone could help me put together something more solid! And of course, feel free to learn from my code if you were curious about making your own game of this type!
B
9
S
2
Posts: 28
Reputation: 649

Post » Wed Aug 05, 2015 10:00 am

OK, I wrote some functions that do the absolute minimum work - no extra looping. The match testing only runs when needed (when a bubble has settled), and the connected testing only runs if bubbles have been destroyed. Both tests set a flag on each bubble so that it knows which ones have been tested and which ones still need to be tested.

For the match testing, it starts with the bubble that has just settled, and only tests the ones around it that are the same color, and stops when it can't find any more - so there is no wasted testing. Then, if bubbles are destroyed it calls the connected test - which uses a very similar technique starting at the top, and working its way down, all in one pass.

It runs nice and fast on my iPhone...

http://www.rieperts.com/games/forum/CBPuzBob.capx
B
95
S
33
G
20
Posts: 438
Reputation: 17,640

Post » Wed Aug 05, 2015 8:02 pm

@BattleJenkins I might see if I can do it without using collisions, but that would mean finding another way to keep track of where bubbles are...
B
95
S
33
G
20
Posts: 438
Reputation: 17,640

Post » Thu Aug 06, 2015 5:48 am

Aahhh! This is perfect! Thank you so much, I really owe you one! Once I have a bit more time, I'm gonna really delve into this and try to puzzle out how it works - switching to one big circular tester instead of a bunch of tiny ones was definitely a really good call.

Let me know if there's anything I can do for you in return! Once this project is done and I get paid for it, I wouldn't mind sending you a pizza or something, hehehe
B
9
S
2
Posts: 28
Reputation: 649


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 17 guests