add small code tweaks
This commit is contained in:
@@ -211,8 +211,6 @@ GameManager.prototype.tileMatchesAvailable = function () {
|
|||||||
var cell = { x: x + vector.x, y: y + vector.y };
|
var cell = { x: x + vector.x, y: y + vector.y };
|
||||||
|
|
||||||
var other = self.grid.cellContent(cell);
|
var other = self.grid.cellContent(cell);
|
||||||
if (other) {
|
|
||||||
}
|
|
||||||
|
|
||||||
if (other && other.value === tile.value) {
|
if (other && other.value === tile.value) {
|
||||||
return true; // These two tiles can be merged
|
return true; // These two tiles can be merged
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ KeyboardInputManager.prototype.listen = function () {
|
|||||||
// Listen to swipe events
|
// Listen to swipe events
|
||||||
var touchStartClientX, touchStartClientY;
|
var touchStartClientX, touchStartClientY;
|
||||||
var gameContainer = document.getElementsByClassName("game-container")[0];
|
var gameContainer = document.getElementsByClassName("game-container")[0];
|
||||||
|
|
||||||
gameContainer.addEventListener("touchstart", function (event) {
|
gameContainer.addEventListener("touchstart", function (event) {
|
||||||
if (event.touches.length > 1) return;
|
if (event.touches.length > 1) return;
|
||||||
|
|
||||||
@@ -66,13 +67,14 @@ KeyboardInputManager.prototype.listen = function () {
|
|||||||
touchStartClientY = event.touches[0].clientY;
|
touchStartClientY = event.touches[0].clientY;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
gameContainer.addEventListener("touchmove", function (event) {
|
gameContainer.addEventListener("touchmove", function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
gameContainer.addEventListener("touchend", function (event) {
|
gameContainer.addEventListener("touchend", function (event) {
|
||||||
if (event.touches.length > 0) {
|
if (event.touches.length > 0) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
var dx = event.changedTouches[0].clientX - touchStartClientX;
|
var dx = event.changedTouches[0].clientX - touchStartClientX;
|
||||||
var absDx = Math.abs(dx);
|
var absDx = Math.abs(dx);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
window.fakeStorage = {
|
window.fakeStorage = {
|
||||||
_data : {},
|
_data : {},
|
||||||
setItem : function (id, val) {
|
setItem : function (id, val) {
|
||||||
console.log('set');
|
console.log("set");
|
||||||
return this._data[id] = String(val);
|
return this._data[id] = String(val);
|
||||||
},
|
},
|
||||||
getItem : function (id) {
|
getItem : function (id) {
|
||||||
@@ -13,7 +13,8 @@ window.fakeStorage = {
|
|||||||
|
|
||||||
function LocalScoreManager() {
|
function LocalScoreManager() {
|
||||||
var localSupported = !!window.localStorage;
|
var localSupported = !!window.localStorage;
|
||||||
this.key = 'bestScore';
|
|
||||||
|
this.key = "bestScore";
|
||||||
this.storage = localSupported ? window.localStorage : window.fakeStorage;
|
this.storage = localSupported ? window.localStorage : window.fakeStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user