add movement check, score addition

This commit is contained in:
Gabriele Cirulli
2014-03-09 23:24:17 +01:00
parent f18f7cee22
commit 4b3055fcd0
4 changed files with 94 additions and 6 deletions
+9 -1
View File
@@ -103,11 +103,15 @@ GameManager.prototype.move = function (direction) {
// Update the score
self.score += merged.value;
// Something's moved for sure
} else {
self.moveTile(tile, positions.farthest);
}
moved = true;
if (!self.positionsEqual(cell, tile)) {
moved = true; // The tile moved from its original cell!
}
}
});
});
@@ -201,3 +205,7 @@ GameManager.prototype.tileMatchesAvailable = function () {
return false;
};
GameManager.prototype.positionsEqual = function (first, second) {
return first.x === second.x && first.y === second.y;
};