2017-01-17 13:24:45 +01:00
|
|
|
GameLib.API.Vector2 = function (x, y) {
|
2016-12-07 15:20:41 +01:00
|
|
|
|
2016-12-15 14:53:39 +01:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(x)) {
|
2016-12-07 15:20:41 +01:00
|
|
|
x = 0;
|
|
|
|
}
|
|
|
|
this.x = x;
|
|
|
|
|
2016-12-15 14:53:39 +01:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(y)) {
|
2016-12-07 15:20:41 +01:00
|
|
|
y = 0;
|
|
|
|
}
|
|
|
|
this.y = y;
|
|
|
|
|
2016-12-02 16:03:03 +01:00
|
|
|
};
|
|
|
|
|
2016-12-15 14:53:39 +01:00
|
|
|
GameLib.API.Vector2.prototype.copy = function () {
|
|
|
|
return new GameLib.API.Vector2(
|
2016-12-02 16:03:03 +01:00
|
|
|
this.x,
|
|
|
|
this.y
|
|
|
|
);
|
2017-01-05 19:34:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an API vector from an Object vector
|
|
|
|
* @param objectVector
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
GameLib.API.Vector2.FromObjectVector = function (objectVector) {
|
|
|
|
return new GameLib.API.Vector2(
|
|
|
|
objectVector.x,
|
|
|
|
objectVector.y
|
|
|
|
)
|
|
|
|
};
|