2014-03-08 12:50:45 +01:00
|
|
|
function Tile(position, value) {
|
|
|
|
this.x = position.x;
|
|
|
|
this.y = position.y;
|
|
|
|
this.value = value || 2;
|
|
|
|
|
|
|
|
this.previousPosition = null;
|
2014-03-09 20:03:04 +01:00
|
|
|
this.mergedFrom = null; // Tracks tiles that merged together
|
2014-03-08 12:50:45 +01:00
|
|
|
}
|
2014-03-09 14:32:30 +01:00
|
|
|
|
|
|
|
Tile.prototype.savePosition = function () {
|
|
|
|
this.previousPosition = { x: this.x, y: this.y };
|
|
|
|
};
|
2014-03-09 20:03:04 +01:00
|
|
|
|
|
|
|
Tile.prototype.updatePosition = function (position) {
|
|
|
|
this.x = position.x;
|
|
|
|
this.y = position.y;
|
|
|
|
};
|
2014-03-18 19:48:55 +01:00
|
|
|
|
2014-03-22 16:24:11 +01:00
|
|
|
Tile.prototype.serialize = function () {
|
|
|
|
return {
|
|
|
|
position: {
|
|
|
|
x: this.x,
|
|
|
|
y: this.y
|
|
|
|
},
|
|
|
|
value: this.value
|
|
|
|
};
|
|
|
|
};
|