-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbasicobject.js
More file actions
54 lines (45 loc) · 1.5 KB
/
basicobject.js
File metadata and controls
54 lines (45 loc) · 1.5 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
var BasicObject = (function () {
function BasicObject() {
this.x = 0;
this.y = 0;
this.width = 0;
this.height = 0;
this.trackedByCamera = false;
this.imperviousToShootingRay = true;
}
BasicObject.prototype.update = function (dt) {};
BasicObject.prototype.render = function (viewportContext) {};
BasicObject.prototype.resolveCollision = function (collided, dt) {};
BasicObject.prototype.getLinesForm = function () {
return [
{
a: {x: this.x, y: this.y},
b: {x: this.x + this.width, y: this.y}
},
{
a: {x: this.x + this.width, y: this.y},
b: {x: this.x + this.width, y: this.y + this.height}
},
{
a: {x: this.x + this.width, y: this.y + this.height},
b: {x: this.x, y: this.y + this.height}
},
{
a: {x: this.x, y: this.y + this.height},
b: {x: this.x, y: this.y}
}
];
};
BasicObject.prototype.getRightX = function () {
return this.x + this.width;
};
BasicObject.prototype.getBottomY = function () {
return this.y + this.height;
};
BasicObject.prototype.setPos = function (x, y) {
if(typeof x != 'number' && typeof y != 'number') { console.log('ERR: x and y must be numbers'); return; }
this.x = x;
this.y = y;
};
return BasicObject;
})();