Selecting which gems to remove

Once the player swapped two gems it means there is at least a successful streak, that is, there are at least three gems to remove. We need to know which gems have to be removed.

The idea: At this time it's important to know which one of the two swapped gems is part of a successful streak, or, if the player really made a good move, if both gems are part of a successful streak. Anyway, for every successful streak, we have to remove all gems included.

The development: To keep things easy, we are going to create a function that scans jewels array almost in the same way rowStreaks and colStreaks functions do. The main difference is we will save the names of the gems to be removed in an array, for a later use.

Create this ...

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.