-
Notifications
You must be signed in to change notification settings - Fork 0
/
entities.js
72 lines (58 loc) · 1.54 KB
/
entities.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
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*********************
* Object structures *
*********************/
(function(exports){
exports.hello = function() {
console.log('hello');
};
exports.Entity = function(game, mesh) {
this.game = game;
this.mesh = mesh;
this.removeFromWorld = false;
}
/*
* Entity
*/
exports.Entity = function(game, mesh) {
this.game = game;
this.mesh = mesh;
this.removeFromWorld = false;
}
exports.Entity.prototype.update = function() {}
exports.Entity.prototype.draw = function() {}
/*
* Player
*/
exports.Player = function(game, id, mesh, dir, velocity, active) {
exports.Entity.call(this, game, mesh);
this.id = id;
this.dir = dir;
this.velocity = velocity;
this.active = active;
}
exports.Player.prototype = new exports.Entity();
exports.Player.prototype.constructor = exports.Player;
exports.Player.prototype.update = function() {
Entity.prototype.update.call(this);
}
exports.Player.prototype.draw = function(ctx) {
Entity.prototype.draw.call(this, ctx);
}
/*
* Bullet
*/
exports.Bullet = function(game, velocity, mesh) {
exports.Entity.call(this, game, mesh);
this.velocity = velocity;
this.mesh = mesh;
this.life = CONFIG.BULLET_LIFE;
}
exports.Bullet.prototype = new exports.Entity();
exports.Bullet.prototype.constructor = exports.Bullet;
exports.Bullet.prototype.update = function() {
Entity.prototype.update.call(this);
}
exports.Bullet.prototype.draw = function(ctx) {
Entity.prototype.draw.call(this, ctx);
}
}) (typeof exports === 'undefined' ? this['TYPE'] = {}: exports);