Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
FogNetwork
GitHub Repository: FogNetwork/Tsunami
Path: blob/main/public/games/files/garbage-collector/js/entities/entity.js
1036 views
1
/*globals define*/
2
define([
3
'object2d'
4
], function( Object2D ) {
5
'use strict';
6
7
function Entity( x, y ) {
8
Object2D.call( this, x, y );
9
10
this.shapes = [];
11
this.game = null;
12
}
13
14
Entity.prototype = new Object2D();
15
Entity.prototype.constructor = Entity;
16
17
Entity.prototype.update = function() {};
18
19
Entity.prototype.drawPath = function( ctx ) {
20
this.shapes.forEach(function( shape ) {
21
shape.draw( ctx );
22
});
23
};
24
25
Entity.prototype.add = function( shape ) {
26
this.shapes.push( shape );
27
};
28
29
Entity.prototype.remove = function( shape ) {
30
var index = this.shapes.indexOf ( shape );
31
if ( index !== -1 ) {
32
this.shapes.splice( index, 1 );
33
}
34
};
35
36
return Entity;
37
});
38
39