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

0 favourites
  • 4 posts
From the Asset Store
An amazing and interesting puzzle game for kids!
  • 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!

  • 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

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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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

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