PageSourceSearch

https://custom2048.github.io/js/tile.js

js custom2048.github.io collected 2026-10-03 08:50:50 UTC 886 bytes, 41 lines download raw bytes

1function Tile(position, value) {
2  this.x                = position.x;
3  this.y                = position.y;
4  this.value            = value || 2;
5
6  this.previousPosition = null;
7  this.mergedFrom       = null; // Tracks tiles that merged together
8}
9
10Tile.prototype.savePosition = function () {
11  this.previousPosition = { x: this.x, y: this.y };
12};
13
14Tile.prototype.updatePosition = function (position) {
15  this.x = position.x;
16  this.y = position.y;
17};
18
19Tile.prototype.serialize = function () {
20  return {
21    position: {
22      x: this.x,
23      y: this.y
24    },
25    value: this.value
26  };
27};
28
29Tile.prototype.save = function (next) {
30  var copy = {}
31  copy.x = this.x;
32  copy.y = this.y;
33  copy.value = this.value;
34  copy.previousPosition = {
35    // In order to reverse the animation, we store the
36    // next position as the previous
37    x: next.x,
38    y: next.y
39  }
40  return copy;
41}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.