1
0
mirror of https://github.com/danog/2048.git synced 2024-12-02 17:27:57 +01:00
2048/js/tile.js

28 lines
594 B
JavaScript
Raw Normal View History

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-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-22 16:24:11 +01:00
Tile.prototype.serialize = function () {
return {
position: {
x: this.x,
y: this.y
},
value: this.value
};
};