add https://github.com/mgarciaisaia mention to readme
[2048.git] / js / tile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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
  };
};
 
comments