Auto showing adjacent empty tiles

In every respectable version of Minesweeper, if the player clicks a tile whose value is zero, the game automatically shows all its surrounding tiles, and if any of these tiles has a zero value, then its surrounding tiles are revealed too, and if one of its surrounding tiles has a zero, it continues this way.

The idea: There is a well known algorithm that can help you to do this task: it is called flood fill and it's commonly used in paint programs when you use the "bucket" fill tool. We'll apply the same principle to the game, because we have to "fill" the empty tiles as if we were painting them with a bucket tool.

This is how the flood fill works:

In the first step, the node (a tile, a pixel, or whatever) selected ...

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.