Detecting bubble chains

When the player forms a chain of at least three bubbles of the same color, they have to disappear from the game.

Before we make them disappear we have to detect if we have chains.

The idea: Once a new bubble is placed on the game field, we can use a variant of the flood fill algorithm that we used during the creation of Minesweeper to check if the bubble is a part of a chain.

The development: We worked on the visual part of the game until now. It's time to add some code to be executed behind the scene to check for chains.

First, we need to save the game field status in an array, and we'll need another array to store all bubbles that are part of a chain. Add two new class level variables:

private const ROT_SPEED:uint=2; private ...

Get Flash Game Development by Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.