Swapping gems for real

We already have everything we need to swap gems only when a successful streak will be made, so this will be a five minutes walk. Take a break because the hardest is yet to come.

The idea: When you are about to swap two gems, check if the game field with the swapped gems has a successful streak. Only in this case, proceed swap the gems.

The development: Creating a script to foresee if two swapped gems would form a successful streak would be a bit complicated as it would require more temporary variables to come into play, so we will follow a simpler approach.

When the player swaps two adjacent gems, we will update jewels array to effectively swap the gems. Then we'll check for successful streaks. If a successful streak is ...

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.