mirror of
https://gitee.com/gfdgd-xi/deep-wine-runner
synced 2025-12-14 02:52:03 +08:00
2048
This commit is contained in:
27
2048/js/tile.js
Normal file
27
2048/js/tile.js
Normal 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
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user