Dealing with combos

Although gems are currently moved and added after a successful streak, we don't check if the falling-on added gems create some streaks and need to be removed. This is a very important feature in Bejeweled as it allows players to make combos and earn more points.

The idea: After any gem is moved or added, check for successful streaks.

The development: Gems are added with replaceGems function, and moved with adjustGems.

We simply have to include an if statement in both the functions to see if the last added/adjusted gem is part of a successful streak.

Change replaceGems function this way:

private function replaceGems():void { for (var i:int=7; i>=0; i--) { for (var j:uint=0; j<8; j++) { if (jewels[i][j]==-1) { jewels[i][j]=Math.floor(Math.random()*7); ...

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.