Team:

Sean
Maninder

How to play:

When you run out of moves, you can submit your score to the leaderboards.

Short Documentation:

Loader.js loads sprites, sounds, and then starts the game
The board is completely random each time. It is ensured that no matches exist on the board at the start of the game.
When a gem is swapped, it follows this order:

  1. Remove control from user
  2. Check if new locations have any matches, if not unswap
  3. Clear matches from board
  4. Make gems fall down
  5. Check matches on board
  6. Repeat at step #3 until there are no matches left
Sounds played are based on the current combo. As of now there are only 3 different sounds, varied in pitch and tempo.

Documentation:

Loader.js__
Loader.js loads all sprites, sounds, and then calls Game.start() when done


Game.js__
Game.start() resets variables (in case it was just reset), and registers appropriate event handlers for gem swaps
When a gem swap occurs, GemMouseUp() is called. This detects what gem called it and where the gem should swap to.
If this is alright, it calls swapGemPositions([x,y] of gem one, [x,y] of gem two)
swapGemPositions applies an animation (tween) to both swapping gems and waits for them to finish using a callback (swapGemPositionsCallback)
swapGemPositionsCallback moves the gems to their new positions on the grid. It checks to see if there are any matches for either gem
If matches exist:

If matches don't exist: clearMatches goes through each match, adds the column to a list, and then kills the gem (explodes, create particle effect, adds to score)
fallMatches goes through each column starting at the bottom. When it moves up, it checks if the current spot on the grid is null (needs to fall)
If so, it: Otherwise, it continues going up until it is out of the grid.
getGemToFall starts at a given position and goes up until it finds a spot in the grid that is not null. It returns this gem.
gemFallCallback confirms the grid position and screen position, and calls gemsFinishedFalling if all gems are finished falling
gemsFinishedFalling calls checkBoard checkBoard goes through each gem on the board (grid), and if it has at least 2 matches (3-in-a-row) it clears those matches, starting back at swapGemPositionsCallback.
If checkBoard finds no matches, control is returned to the user and they can make another move.

Globals.js__
Globals.js contains global variables used across the code, including options and the grid of gems


Helper.js__
Helper.js initializes the Crafty.js classes (Gem, GemDrag, Selector, HotSelector, Playspace) and contains the particleExplosion function