react-simple-game-engine 0.0.45 → 0.0.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/classes/entities/entity-sult.d.ts +10 -1
- package/lib/classes/entities/entity-sult.d.ts.map +1 -1
- package/lib/classes/entities/entity-sult.js +24 -0
- package/lib/classes/entities/entity.d.ts +1 -8
- package/lib/classes/entities/entity.d.ts.map +1 -1
- package/lib/classes/entities/entity.js +1 -9
- package/lib/classes/particle-system.d.ts +0 -1
- package/lib/classes/particle-system.d.ts.map +1 -1
- package/lib/classes/particle-system.js +0 -3
- package/lib/classes/scene.js +1 -1
- package/lib/classes/world-management.d.ts +6 -2
- package/lib/classes/world-management.d.ts.map +1 -1
- package/lib/classes/world-management.js +17 -3
- package/package.json +1 -1
@@ -1,11 +1,20 @@
|
|
1
1
|
import { Initialler } from "../../export-interfaces";
|
2
2
|
import { Camera } from "../camera";
|
3
|
+
import { Scene } from "../scene";
|
3
4
|
import { WorldManagement } from "../world-management";
|
4
5
|
export declare abstract class EntitySult<P = any> implements Initialler<P> {
|
5
6
|
camera: Camera;
|
7
|
+
private readonly id;
|
8
|
+
readonly tag: string;
|
9
|
+
private _scene;
|
10
|
+
private _worldManagement;
|
11
|
+
constructor();
|
6
12
|
abstract update(): void;
|
7
13
|
abstract draw(): void;
|
8
|
-
|
14
|
+
get scene(): Scene<any>;
|
15
|
+
get worldManagement(): WorldManagement;
|
16
|
+
active(worldManagement: WorldManagement): void;
|
17
|
+
onActive(): void;
|
9
18
|
initial(params: P): void;
|
10
19
|
}
|
11
20
|
//# sourceMappingURL=entity-sult.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"entity-sult.d.ts","sourceRoot":"","sources":["../../../src/classes/entities/entity-sult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,8BAAsB,UAAU,CAAC,CAAC,GAAG,GAAG,CAAE,YAAW,UAAU,CAAC,CAAC,CAAC;IACzD,MAAM,EAAG,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,IAAI,IAAI;IACvB,QAAQ,CAAC,IAAI,IAAI,IAAI;
|
1
|
+
{"version":3,"file":"entity-sult.d.ts","sourceRoot":"","sources":["../../../src/classes/entities/entity-sult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,8BAAsB,UAAU,CAAC,CAAC,GAAG,GAAG,CAAE,YAAW,UAAU,CAAC,CAAC,CAAC;IACzD,MAAM,EAAG,MAAM,CAAC;IACvB,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAsD;IACzE,SAAgB,GAAG,EAAG,MAAM,CAAC;IAE7B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,gBAAgB,CAAmB;;IAM3C,QAAQ,CAAC,MAAM,IAAI,IAAI;IACvB,QAAQ,CAAC,IAAI,IAAI,IAAI;IAErB,IAAI,KAAK,eAER;IAED,IAAI,eAAe,oBAElB;IAED,MAAM,CAAC,eAAe,EAAE,eAAe;IAQvC,QAAQ;IACR,OAAO,CAAC,MAAM,EAAE,CAAC;CAClB"}
|
@@ -1,6 +1,30 @@
|
|
1
1
|
var EntitySult = /** @class */ (function () {
|
2
2
|
function EntitySult() {
|
3
|
+
this.id = "".concat(Math.random(), "-").concat(new Date().getTime());
|
4
|
+
this.tag = this.constructor.tag;
|
3
5
|
}
|
6
|
+
Object.defineProperty(EntitySult.prototype, "scene", {
|
7
|
+
get: function () {
|
8
|
+
return this._scene;
|
9
|
+
},
|
10
|
+
enumerable: false,
|
11
|
+
configurable: true
|
12
|
+
});
|
13
|
+
Object.defineProperty(EntitySult.prototype, "worldManagement", {
|
14
|
+
get: function () {
|
15
|
+
return this._worldManagement;
|
16
|
+
},
|
17
|
+
enumerable: false,
|
18
|
+
configurable: true
|
19
|
+
});
|
20
|
+
EntitySult.prototype.active = function (worldManagement) {
|
21
|
+
console.log("Initted ".concat(this.tag, " entity (id : ").concat(this.id, ")"));
|
22
|
+
this._worldManagement = worldManagement;
|
23
|
+
this._scene = this.scene;
|
24
|
+
this.camera = worldManagement.camera;
|
25
|
+
this.onActive();
|
26
|
+
};
|
27
|
+
EntitySult.prototype.onActive = function () { };
|
4
28
|
EntitySult.prototype.initial = function (params) { };
|
5
29
|
return EntitySult;
|
6
30
|
}());
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import Matter from "matter-js";
|
2
|
-
import { WorldManagement } from "../world-management";
|
3
2
|
import { Sprite } from "../sprites/sprite";
|
4
3
|
import { CreateBodyDefine, EntityInitial, EntityPrepare, MasterBody, Sound } from "../../export-types";
|
5
4
|
import { EntitySult } from "./entity-sult";
|
@@ -7,11 +6,7 @@ export declare abstract class Entity<SpriteType extends Sprite<any> = any> exten
|
|
7
6
|
private _body;
|
8
7
|
private _sprite;
|
9
8
|
private _children;
|
10
|
-
|
11
|
-
readonly tag: string;
|
12
|
-
protected worldManagement: WorldManagement;
|
13
|
-
protected sound?: Sound;
|
14
|
-
constructor();
|
9
|
+
sound?: Sound;
|
15
10
|
set sprite(sprite: SpriteType);
|
16
11
|
get sprite(): SpriteType;
|
17
12
|
get position(): Matter.Vector;
|
@@ -19,8 +14,6 @@ export declare abstract class Entity<SpriteType extends Sprite<any> = any> exten
|
|
19
14
|
get children(): EntitySult<any>[];
|
20
15
|
addChild(entity: EntitySult): void;
|
21
16
|
removeChild(entity: EntitySult): void;
|
22
|
-
active(worldManagement: WorldManagement): void;
|
23
|
-
onActive(): void;
|
24
17
|
createBody(transform: CreateBodyDefine["transform"], options?: CreateBodyDefine["bodyOptions"]): MasterBody;
|
25
18
|
protected abstract onCreateBody(transform: CreateBodyDefine["transform"] | undefined, options?: CreateBodyDefine["bodyOptions"]): Matter.Body;
|
26
19
|
initial({ sound, transform, sprite: spriteComponent, bodyOptions, }: EntityInitial<this>): void;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../../src/classes/entities/entity.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,WAAW,CAAC;
|
1
|
+
{"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../../src/classes/entities/entity.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,WAAW,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,UAAU,EACV,KAAK,EACN,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,8BAAsB,MAAM,CAC1B,UAAU,SAAS,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,CACpC,SAAQ,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IACzC,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,SAAS,CAAoB;IAE9B,KAAK,CAAC,EAAE,KAAK,CAAC;IAErB,IAAI,MAAM,CAAC,MAAM,EAAE,UAAU,EAG5B;IAED,IAAI,MAAM,IALS,UAAU,CAO5B;IAED,IAAI,QAAQ,kBAEX;IAED,IAAI,IAAI,eAEP;IAED,IAAI,QAAQ,sBAEX;IAED,QAAQ,CAAC,MAAM,EAAE,UAAU;IAK3B,WAAW,CAAC,MAAM,EAAE,UAAU;IAQ9B,UAAU,CACR,SAAS,EAAE,gBAAgB,CAAC,WAAW,CAAC,EACxC,OAAO,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC;IAO3C,SAAS,CAAC,QAAQ,CAAC,YAAY,CAC7B,SAAS,EAAE,gBAAgB,CAAC,WAAW,CAAC,GAAG,SAAS,EACpD,OAAO,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC,GACxC,MAAM,CAAC,IAAI;IAEd,OAAO,CAAC,EACN,KAAK,EACL,SAAc,EACd,MAAM,EAAE,eAAe,EACvB,WAAgB,GACjB,EAAE,aAAa,CAAC,IAAI,CAAC;IAgCtB,SAAS,CAAC,QAAQ,CAAC,SAAS,IAAI,aAAa,CAAC,IAAI,CAAC;IACnD,SAAS,CAAC,SAAS,IAAI,aAAa,CAAC,IAAI,CAAC;IAI1C,MAAM;IAGN,QAAQ;IAER,IAAI;IAIJ,QAAQ,CAAC,0BAA0B,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAExE,WAAW,CAAC,MAAM,EAAE,MAAM;IAC1B,cAAc,CAAC,MAAM,EAAE,MAAM;IAC7B,iBAAiB,CAAC,MAAM,EAAE,MAAM;CACjC"}
|
@@ -40,10 +40,8 @@ import { EntitySult } from "./entity-sult";
|
|
40
40
|
var Entity = /** @class */ (function (_super) {
|
41
41
|
__extends(Entity, _super);
|
42
42
|
function Entity() {
|
43
|
-
var _this = _super.
|
43
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
44
44
|
_this._children = [];
|
45
|
-
_this.id = "".concat(Math.random(), "-").concat(new Date().getTime());
|
46
|
-
_this.tag = _this.constructor.tag;
|
47
45
|
return _this;
|
48
46
|
}
|
49
47
|
Object.defineProperty(Entity.prototype, "sprite", {
|
@@ -89,12 +87,6 @@ var Entity = /** @class */ (function (_super) {
|
|
89
87
|
this.worldManagement.removeEntity(entity);
|
90
88
|
}
|
91
89
|
};
|
92
|
-
Entity.prototype.active = function (worldManagement) {
|
93
|
-
console.log("Initted ".concat(this.tag, " entity (id : ").concat(this.id, ")"));
|
94
|
-
this.worldManagement = worldManagement;
|
95
|
-
this.onActive();
|
96
|
-
};
|
97
|
-
Entity.prototype.onActive = function () { };
|
98
90
|
Entity.prototype.createBody = function (transform, options) {
|
99
91
|
this._body = this.onCreateBody(transform, options);
|
100
92
|
this._body.entity = this;
|
@@ -22,7 +22,6 @@ export declare class ParticleSystem extends EntitySult<ParticleSystemInitialPara
|
|
22
22
|
private particleClass;
|
23
23
|
quantityPerFrame: number;
|
24
24
|
vecWeight: number;
|
25
|
-
active(): void;
|
26
25
|
initial({ forces, particleOptions, ...params }: ParticleSystemInitialParams): void;
|
27
26
|
update(): void;
|
28
27
|
draw(): void;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"particle-system.d.ts","sourceRoot":"","sources":["../../src/classes/particle-system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;
|
1
|
+
{"version":3,"file":"particle-system.d.ts","sourceRoot":"","sources":["../../src/classes/particle-system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAE7D,aAAK,aAAa,GAAG;IACnB,KAAK,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,QAAQ,CAAC,GAAG,QAAQ,CAAC;CACjE,CAAC;AAEF,aAAK,eAAe,GAAG,IAAI,CACzB,qBAAqB,EACrB,KAAK,GAAG,OAAO,GAAG,QAAQ,CAC3B,GAAG;IACF,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,aAAK,2BAA2B,GAAG;IACjC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF,qBAAa,cAAe,SAAQ,UAAU,CAAC,2BAA2B,CAAC;IACzE,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,eAAe,CAGrB;IACF,OAAO,CAAC,aAAa,CAA2B;IAEzC,gBAAgB,EAAE,MAAM,CAAM;IAC9B,SAAS,EAAE,MAAM,CAAK;IAE7B,OAAO,CAAC,EACN,MAAM,EACN,eAAoB,EACpB,GAAG,MAAM,EACV,EAAE,2BAA2B;IAS9B,MAAM;IAyBN,IAAI;CAKL"}
|
@@ -54,9 +54,6 @@ var ParticleSystem = /** @class */ (function (_super) {
|
|
54
54
|
_this.vecWeight = 5;
|
55
55
|
return _this;
|
56
56
|
}
|
57
|
-
ParticleSystem.prototype.active = function () {
|
58
|
-
console.log("Initted particle system", this.particles.length);
|
59
|
-
};
|
60
57
|
ParticleSystem.prototype.initial = function (_a) {
|
61
58
|
var _b;
|
62
59
|
var forces = _a.forces, _c = _a.particleOptions, particleOptions = _c === void 0 ? {} : _c, params = __rest(_a, ["forces", "particleOptions"]);
|
package/lib/classes/scene.js
CHANGED
@@ -116,7 +116,7 @@ var Scene = /** @class */ (function () {
|
|
116
116
|
}); });
|
117
117
|
};
|
118
118
|
Scene.prototype.bootstrap = function (camera) {
|
119
|
-
this.worldManagement = new WorldManagement(camera);
|
119
|
+
this.worldManagement = new WorldManagement(camera, this);
|
120
120
|
var components = this.getComponents(camera);
|
121
121
|
for (var _i = 0, components_1 = components; _i < components_1.length; _i++) {
|
122
122
|
var component = components_1[_i];
|
@@ -1,10 +1,14 @@
|
|
1
1
|
import { Camera } from "./camera";
|
2
2
|
import { EntitySult } from "./entities/entity-sult";
|
3
|
+
import { Scene } from "./scene";
|
3
4
|
export declare class WorldManagement {
|
4
|
-
private
|
5
|
+
private _camera;
|
6
|
+
private _scene;
|
5
7
|
private entities;
|
6
8
|
private engine;
|
7
|
-
constructor(
|
9
|
+
constructor(_camera: Camera, _scene: Scene);
|
10
|
+
get camera(): Camera;
|
11
|
+
get scene(): Scene<any>;
|
8
12
|
destructor(): void;
|
9
13
|
addEntity(entity: EntitySult): void;
|
10
14
|
removeEntity(entity: EntitySult): void;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"world-management.d.ts","sourceRoot":"","sources":["../../src/classes/world-management.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;
|
1
|
+
{"version":3,"file":"world-management.d.ts","sourceRoot":"","sources":["../../src/classes/world-management.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,qBAAa,eAAe;IAId,OAAO,CAAC,OAAO;IAAU,OAAO,CAAC,MAAM;IAHnD,OAAO,CAAC,QAAQ,CAAoB;IACpC,OAAO,CAAC,MAAM,CAAU;gBAEJ,OAAO,EAAE,MAAM,EAAU,MAAM,EAAE,KAAK;IAqC1D,IAAI,MAAM,WAET;IAED,IAAI,KAAK,eAER;IAED,UAAU;IAKV,SAAS,CAAC,MAAM,EAAE,UAAU;IAS5B,YAAY,CAAC,MAAM,EAAE,UAAU;IAa/B,MAAM;IAON,IAAI;CAKL"}
|
@@ -1,8 +1,9 @@
|
|
1
1
|
import { Engine, World, Events } from "matter-js";
|
2
2
|
import { Entity } from "./entities/entity";
|
3
3
|
var WorldManagement = /** @class */ (function () {
|
4
|
-
function WorldManagement(
|
5
|
-
this.
|
4
|
+
function WorldManagement(_camera, _scene) {
|
5
|
+
this._camera = _camera;
|
6
|
+
this._scene = _scene;
|
6
7
|
this.entities = [];
|
7
8
|
this.engine = Engine.create();
|
8
9
|
Events.on(this.engine, "collisionStart", function (event) {
|
@@ -33,13 +34,26 @@ var WorldManagement = /** @class */ (function () {
|
|
33
34
|
}
|
34
35
|
});
|
35
36
|
}
|
37
|
+
Object.defineProperty(WorldManagement.prototype, "camera", {
|
38
|
+
get: function () {
|
39
|
+
return this._camera;
|
40
|
+
},
|
41
|
+
enumerable: false,
|
42
|
+
configurable: true
|
43
|
+
});
|
44
|
+
Object.defineProperty(WorldManagement.prototype, "scene", {
|
45
|
+
get: function () {
|
46
|
+
return this._scene;
|
47
|
+
},
|
48
|
+
enumerable: false,
|
49
|
+
configurable: true
|
50
|
+
});
|
36
51
|
WorldManagement.prototype.destructor = function () {
|
37
52
|
World.clear(this.engine.world, false);
|
38
53
|
Engine.clear(this.engine);
|
39
54
|
};
|
40
55
|
WorldManagement.prototype.addEntity = function (entity) {
|
41
56
|
// temp pass modifier
|
42
|
-
entity["camera"] = this.camera;
|
43
57
|
this.entities.push(entity);
|
44
58
|
if (entity instanceof Entity) {
|
45
59
|
World.add(this.engine.world, entity.body);
|