Hi to all,
i've started to work on a Bubble Shooter game, i've managed to develop the part regarding destruction between bubbles with same color. Now the only issue is how to find/destroy bubbles and group of bubbles which does not have any neighbor, like the group marked with red from this image:
<img src="http://img33.imageshack.us/img33/9600/w8h0.png" border="0" />
Any advice is welcome.
By the way, Construct 2 is a great game engine. Well done Scirra!
Edit: image broken link.
Check your image link, this forum seems to have some sort of black list for hosting.
If you use DropBox or Google drive, you may want to choose a different image host.
I do not have any problems using Dropbox or google drive on any other forum but this one, I have no idea why anyone would black list them.
Pretty ironic having my C2 html5 projects unplayable from the C2 forum.
Thank you for your advice jojoe, i've fixed it.
Try using the collision at offset to check what is adjacent to your bubble sprite.
You might also want to use an array to draw your bubbles, and use the array matrix to check what is next to the bubble in question.
RegEx might also be really helpful for this, but I can not find any good regex tutorials on the forums.
Thank you jojoe, i will give it a try <img src="smileys/smiley1.gif" border="0" align="middle" />
Glad you find it useful.
Here is my favorite (tiny) tutorial on arrays:
For a quick-n-dirty way of doing things, have your "bullet-bubble" spawn an invisible Kill sprite, in all 8 directions around the "bullet-bubble" that kills all other bubbles of the same color.
Player shoots a RED "bullet-bubble",
bubble collides with another bubble, triggers the "bullet-bubble" to stop, RED "bullet-bubble" spawns a "Kill-red-bubble" sprite in all 8 directions.
When the stationary bubbles get hit by a kill red sprite, and it is red, it destroys itself, and spawns 8 kill-red sprites like the bullet bubble did.
This will cause a chain reaction, like puzzle bobble, but will leave some bubbles floating, and unattached. (in puzzle bobble, floating islands of bubbles destroys, and gives player score)
Develop games in your browser. Powerful, performant & highly capable.
joejoe your idea with "kill-bubble" is interesting, for destroying the bubbles with same color i've used a "flood fill" technique, now, the only issue is with finding the "floating bubbles". My ideea is to use the object's matrix array, to search for "floating bubbles" and groups of bubbles. To find individual bubbles with no neighbors is easy, but the hard part is to find the groups of bubbles.
ok, maybe the chain reaction idea again. only with a sensor for the top of the game board.
PLayer shoots bullet-bubble, hits a stationary bubble and stops.
Sets a local variable for "selected,
Spawns sensor sprites in all 8 directions.
If a bubble collides with a sensor sprite, it spawns sensor sprites in all 8 directions. after setting its own "selected instance variable"
If after the chain reaction is over, and the top sensor bar does not receive a sensor sprite collision , then all selected sprites destroy.
The top sensor will only be hit by connected chain reactions.
Hope that helps.
it looks like a good method, also i will give it a try. Thank you for your ideas jojoe, they really helped me a lot <img src="smileys/smiley1.gif" border="0" align="middle" />
You are welcome. Make sure you make the sensor sprites smaller than the bubble sprites to avoid "collision overflow". A sensor sprite about half the size will do just fine.
Hi again jojoe, still cannot find a solution for destroying unconnected group of bubbles, in this moment i have a 3d array which contains the bubbles and zones without bubbles (i store x and y positions of a bubble, and 1 if there is a bubble, and 0 if there is not a bubble). The problem is that i don't know how to destroy the bubbles which are isolated, like the blue ones from this screenshot:
<img src="http://img5.imageshack.us/img5/9729/8kqm.jpg" border="0" />
I've tryied a solution with filling the white spaces with another objects and them move them down, and when they colides with bubbles to destroy the bubbles, in the case from the screenshot it is working like a charm, but in other complicated cases there are destroyed another bubbles which are not disconnected.
If anyone have a solution, please, let me know :)
hey! I have a similar issue, is there a method to do this? C2 seems like a great engine apart from not being able to solve simple problems like this.
I believe that there must be a solution for this, i'm also waiting to find it :D
A solution is do a flood fill from the top row of bubbles. Mark the the top bubbles and then mark all the connected bubbles. After that any unmarked bubbles are not connected.
Here is an example of the concept with squares:
Click to add/remove squares. They will be destroyed if not connected to the center square. This can be adapted any way you like. Just change the function that marks the connected objects.
Hi R0J0hound, a similiar thechnique i've started to implement, seems to work, thank you for your answer.