2017-11-05 13:59:11 +14:00
|
|
|
function Pos(x,y)
|
|
|
|
|
{
|
|
|
|
|
this.x = x;
|
|
|
|
|
this.y = y;
|
|
|
|
|
|
|
|
|
|
this.toString = function()
|
|
|
|
|
{
|
|
|
|
|
return x+","+y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.sub = function(pos2)
|
|
|
|
|
{
|
|
|
|
|
return new Pos(this.x - pos2.x,this.y - pos2.y)
|
|
|
|
|
}
|
2017-11-05 17:33:04 +13:00
|
|
|
|
2017-11-06 13:18:57 +13:00
|
|
|
this.add = function(pos2)
|
|
|
|
|
{
|
|
|
|
|
return new Pos(this.x + pos2.x,this.y + pos2.y)
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-05 17:33:04 +13:00
|
|
|
this.is_equal = function(pos2)
|
|
|
|
|
{
|
2017-11-08 10:40:13 +13:00
|
|
|
return Math.abs(pos2.x) == Math.abs(this.x) && Math.abs(pos2.y) == Math.abs(this.y);
|
2017-11-05 17:33:04 +13:00
|
|
|
}
|
2017-11-12 13:47:34 -08:00
|
|
|
|
|
|
|
|
this.scale = function(a)
|
|
|
|
|
{
|
|
|
|
|
return new Pos(this.x*a,this.y*a)
|
|
|
|
|
}
|
2017-11-05 13:59:11 +14:00
|
|
|
}
|