This commit is contained in:
2023-05-13 13:14:30 +08:00
parent 896214d2b7
commit 31aeb66cd4
60 changed files with 4904 additions and 54 deletions

View File

@@ -0,0 +1,27 @@
function Tile(position, value) {
this.x = position.x;
this.y = position.y;
this.value = value || 2;
this.previousPosition = null;
this.mergedFrom = null; // Tracks tiles that merged together
}
Tile.prototype.savePosition = function () {
this.previousPosition = { x: this.x, y: this.y };
};
Tile.prototype.updatePosition = function (position) {
this.x = position.x;
this.y = position.y;
};
Tile.prototype.serialize = function () {
return {
position: {
x: this.x,
y: this.y
},
value: this.value
};
};