react-simple-game-engine 0.1.61 → 0.1.64
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/animations/animation.d.ts +14 -0
- package/lib/classes/animations/animation.d.ts.map +1 -0
- package/lib/classes/animations/animation.js +35 -0
- package/lib/classes/animations/avatar.animation.d.ts +16 -0
- package/lib/classes/animations/avatar.animation.d.ts.map +1 -0
- package/lib/classes/animations/avatar.animation.js +45 -0
- package/lib/classes/animations/color.animation.d.ts +9 -0
- package/lib/classes/animations/color.animation.d.ts.map +1 -0
- package/lib/classes/animations/color.animation.js +33 -0
- package/lib/classes/camera.d.ts +14 -0
- package/lib/classes/camera.d.ts.map +1 -0
- package/lib/classes/camera.js +34 -0
- package/lib/classes/entities/circle.entity.d.ts +15 -0
- package/lib/classes/entities/circle.entity.d.ts.map +1 -0
- package/lib/classes/entities/circle.entity.js +55 -0
- package/lib/classes/entities/entity-sult.d.ts +34 -0
- package/lib/classes/entities/entity-sult.d.ts.map +1 -0
- package/lib/classes/entities/entity-sult.js +108 -0
- package/lib/classes/entities/entity.d.ts +55 -0
- package/lib/classes/entities/entity.d.ts.map +1 -0
- package/lib/classes/entities/entity.js +180 -0
- package/lib/classes/entities/rect.entity.d.ts +17 -0
- package/lib/classes/entities/rect.entity.d.ts.map +1 -0
- package/lib/classes/entities/rect.entity.js +56 -0
- package/lib/classes/logic-component.d.ts +16 -0
- package/lib/classes/logic-component.d.ts.map +1 -0
- package/lib/classes/logic-component.js +77 -0
- package/lib/classes/p5.d.ts +11 -0
- package/lib/classes/p5.d.ts.map +1 -0
- package/lib/classes/p5.js +58 -0
- package/lib/classes/particle-system.d.ts +30 -0
- package/lib/classes/particle-system.d.ts.map +1 -0
- package/lib/classes/particle-system.js +98 -0
- package/lib/classes/particle.d.ts +35 -0
- package/lib/classes/particle.d.ts.map +1 -0
- package/lib/classes/particle.js +117 -0
- package/lib/classes/prefab.d.ts +7 -0
- package/lib/classes/prefab.d.ts.map +1 -0
- package/lib/classes/prefab.js +24 -0
- package/lib/classes/saver.d.ts +11 -0
- package/lib/classes/saver.d.ts.map +1 -0
- package/lib/classes/saver.js +33 -0
- package/lib/classes/scene-management.d.ts +22 -0
- package/lib/classes/scene-management.d.ts.map +1 -0
- package/lib/classes/scene-management.js +58 -0
- package/lib/classes/scene.d.ts +75 -0
- package/lib/classes/scene.d.ts.map +1 -0
- package/lib/classes/scene.js +433 -0
- package/lib/classes/sound-watcher.d.ts +16 -0
- package/lib/classes/sound-watcher.d.ts.map +1 -0
- package/lib/classes/sound-watcher.js +33 -0
- package/lib/classes/sound.d.ts +14 -0
- package/lib/classes/sound.d.ts.map +1 -0
- package/lib/classes/sound.js +119 -0
- package/lib/classes/sprites/avatar.sprite.d.ts +20 -0
- package/lib/classes/sprites/avatar.sprite.d.ts.map +1 -0
- package/lib/classes/sprites/avatar.sprite.js +89 -0
- package/lib/classes/sprites/color.sprite.d.ts +7 -0
- package/lib/classes/sprites/color.sprite.d.ts.map +1 -0
- package/lib/classes/sprites/color.sprite.js +40 -0
- package/lib/classes/sprites/sprite.d.ts +26 -0
- package/lib/classes/sprites/sprite.d.ts.map +1 -0
- package/lib/classes/sprites/sprite.js +70 -0
- package/lib/classes/watcher.d.ts +11 -0
- package/lib/classes/watcher.d.ts.map +1 -0
- package/lib/classes/watcher.js +44 -0
- package/lib/classes/world-management.d.ts +28 -0
- package/lib/classes/world-management.d.ts.map +1 -0
- package/lib/classes/world-management.js +160 -0
- package/lib/decorators/scene-tag.decor.d.ts +6 -0
- package/lib/decorators/scene-tag.decor.d.ts.map +1 -0
- package/lib/decorators/scene-tag.decor.js +5 -0
- package/lib/decorators/scene-ui.decor.d.ts +7 -0
- package/lib/decorators/scene-ui.decor.d.ts.map +1 -0
- package/lib/decorators/scene-ui.decor.js +5 -0
- package/lib/decorators/sound-from.decor.d.ts +6 -0
- package/lib/decorators/sound-from.decor.d.ts.map +1 -0
- package/lib/decorators/sound-from.decor.js +17 -0
- package/lib/decorators/sprite-from.decor.d.ts +4 -0
- package/lib/decorators/sprite-from.decor.d.ts.map +1 -0
- package/lib/decorators/sprite-from.decor.js +13 -0
- package/lib/export-enums.d.ts.map +1 -0
- package/lib/export-enums.js +5 -0
- package/lib/export-interfaces.d.ts.map +1 -0
- package/lib/export-interfaces.js +1 -0
- package/lib/export-types.d.ts.map +1 -0
- package/lib/export-types.js +1 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/ui-components/SceneRunner.d.ts +14 -0
- package/lib/ui-components/SceneRunner.d.ts.map +1 -0
- package/lib/ui-components/SceneRunner.js +43 -0
- package/lib/ui-components/ScenesProcess.d.ts +9 -0
- package/lib/ui-components/ScenesProcess.d.ts.map +1 -0
- package/lib/ui-components/ScenesProcess.js +46 -0
- package/lib/ui-components/Sketch.d.ts +12 -0
- package/lib/ui-components/Sketch.d.ts.map +1 -0
- package/lib/ui-components/Sketch.js +33 -0
- package/lib/utilities.d.ts.map +1 -0
- package/lib/utilities.js +2 -0
- package/lib/utils.d.ts +8 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +97 -0
- package/package.json +2 -6
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Sprite } from "../sprites/sprite";
|
|
2
|
+
export declare abstract class AnimationSprite<S extends Sprite<any>> {
|
|
3
|
+
protected currentFrame: number;
|
|
4
|
+
protected _isRunning: boolean;
|
|
5
|
+
protected timeCounter: number;
|
|
6
|
+
delatime: number;
|
|
7
|
+
sprite: S;
|
|
8
|
+
set isRunning(_isRunning: boolean);
|
|
9
|
+
abstract initial(params: any): void;
|
|
10
|
+
draw(): void;
|
|
11
|
+
protected abstract checkFrameMax(): boolean;
|
|
12
|
+
protected abstract onDraw(): void;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=animation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animation.d.ts","sourceRoot":"","sources":["../../../src/classes/animations/animation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,8BAAsB,eAAe,CAAC,CAAC,SAAS,MAAM,CAAC,GAAG,CAAC;IACzD,SAAS,CAAC,YAAY,EAAE,MAAM,CAAK;IACnC,SAAS,CAAC,UAAU,UAAQ;IAC5B,SAAS,CAAC,WAAW,SAAK;IAE1B,QAAQ,SAAU;IAClB,MAAM,EAAG,CAAC,CAAC;IAEX,IAAI,SAAS,CAAC,UAAU,EAAE,OAAO,EAOhC;IAED,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI;IAEnC,IAAI;IAgBJ,SAAS,CAAC,QAAQ,CAAC,aAAa,IAAI,OAAO;IAC3C,SAAS,CAAC,QAAQ,CAAC,MAAM,IAAI,IAAI;CAClC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var AnimationSprite = /** @class */ (function () {
|
|
2
|
+
function AnimationSprite() {
|
|
3
|
+
this.currentFrame = 0;
|
|
4
|
+
this._isRunning = true;
|
|
5
|
+
this.timeCounter = 0;
|
|
6
|
+
this.delatime = 1 / 30;
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(AnimationSprite.prototype, "isRunning", {
|
|
9
|
+
set: function (_isRunning) {
|
|
10
|
+
this._isRunning = _isRunning;
|
|
11
|
+
if (!_isRunning) {
|
|
12
|
+
// stop
|
|
13
|
+
this.timeCounter = 0;
|
|
14
|
+
this.currentFrame = 0;
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
enumerable: false,
|
|
18
|
+
configurable: true
|
|
19
|
+
});
|
|
20
|
+
AnimationSprite.prototype.draw = function () {
|
|
21
|
+
if (this.checkFrameMax()) {
|
|
22
|
+
this.currentFrame = 0;
|
|
23
|
+
}
|
|
24
|
+
this.onDraw();
|
|
25
|
+
if (this.timeCounter / 1000 >= this.delatime) {
|
|
26
|
+
this.timeCounter = 0;
|
|
27
|
+
if (this._isRunning) {
|
|
28
|
+
this.currentFrame++;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
this.timeCounter += Renderer.deltaTime;
|
|
32
|
+
};
|
|
33
|
+
return AnimationSprite;
|
|
34
|
+
}());
|
|
35
|
+
export { AnimationSprite };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AvatarSprite } from "../sprites/avatar.sprite";
|
|
2
|
+
import { AnimationSprite } from "./animation";
|
|
3
|
+
declare type Offset = {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
};
|
|
9
|
+
export declare class AvatarAnimationSprite extends AnimationSprite<AvatarSprite> {
|
|
10
|
+
private offset;
|
|
11
|
+
initial({ x, y, width, height }: Partial<Offset>): void;
|
|
12
|
+
protected checkFrameMax(): boolean;
|
|
13
|
+
onDraw(): void;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=avatar.animation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"avatar.animation.d.ts","sourceRoot":"","sources":["../../../src/classes/animations/avatar.animation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,aAAK,MAAM,GAAG;IACZ,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,qBAAa,qBAAsB,SAAQ,eAAe,CAAC,YAAY,CAAC;IACtE,OAAO,CAAC,MAAM,CAAU;IAExB,OAAO,CAAC,EAAE,CAAK,EAAE,CAAK,EAAE,KAAS,EAAE,MAAU,EAAE,EAAE,OAAO,CAAC,MAAM,CAAC;IAShE,SAAS,CAAC,aAAa,IAAI,OAAO;IAKlC,MAAM;CAgBP"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
import { AnimationSprite } from "./animation";
|
|
17
|
+
var AvatarAnimationSprite = /** @class */ (function (_super) {
|
|
18
|
+
__extends(AvatarAnimationSprite, _super);
|
|
19
|
+
function AvatarAnimationSprite() {
|
|
20
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
21
|
+
}
|
|
22
|
+
AvatarAnimationSprite.prototype.initial = function (_a) {
|
|
23
|
+
var _b = _a.x, x = _b === void 0 ? 0 : _b, _c = _a.y, y = _c === void 0 ? 0 : _c, _d = _a.width, width = _d === void 0 ? 0 : _d, _e = _a.height, height = _e === void 0 ? 0 : _e;
|
|
24
|
+
this.offset = {
|
|
25
|
+
x: x,
|
|
26
|
+
y: y,
|
|
27
|
+
width: width,
|
|
28
|
+
height: height,
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
AvatarAnimationSprite.prototype.checkFrameMax = function () {
|
|
32
|
+
var _a = this.offset, width = _a.width, x = _a.x;
|
|
33
|
+
return this.currentFrame * width + x >= this.sprite.source.width;
|
|
34
|
+
};
|
|
35
|
+
AvatarAnimationSprite.prototype.onDraw = function () {
|
|
36
|
+
var _a = this.offset, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
|
|
37
|
+
Renderer.image(this.sprite.source,
|
|
38
|
+
// position on canvas
|
|
39
|
+
0, 0, this.sprite.width, this.sprite.height,
|
|
40
|
+
//crop on source image
|
|
41
|
+
this.currentFrame * width + x, y, width, height);
|
|
42
|
+
};
|
|
43
|
+
return AvatarAnimationSprite;
|
|
44
|
+
}(AnimationSprite));
|
|
45
|
+
export { AvatarAnimationSprite };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ColorSprite } from "../sprites/color.sprite";
|
|
2
|
+
import { AnimationSprite } from "./animation";
|
|
3
|
+
export declare class ColorAnimationSprite extends AnimationSprite<ColorSprite> {
|
|
4
|
+
private colors;
|
|
5
|
+
initial(colors: ColorSprite["source"][]): void;
|
|
6
|
+
protected checkFrameMax(): boolean;
|
|
7
|
+
protected onDraw(): void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=color.animation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color.animation.d.ts","sourceRoot":"","sources":["../../../src/classes/animations/color.animation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,qBAAa,oBAAqB,SAAQ,eAAe,CAAC,WAAW,CAAC;IACpE,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,EAAE;IAIvC,SAAS,CAAC,aAAa,IAAI,OAAO;IAIlC,SAAS,CAAC,MAAM,IAAI,IAAI;CAGzB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
import { AnimationSprite } from "./animation";
|
|
17
|
+
var ColorAnimationSprite = /** @class */ (function (_super) {
|
|
18
|
+
__extends(ColorAnimationSprite, _super);
|
|
19
|
+
function ColorAnimationSprite() {
|
|
20
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
21
|
+
}
|
|
22
|
+
ColorAnimationSprite.prototype.initial = function (colors) {
|
|
23
|
+
this.colors = colors;
|
|
24
|
+
};
|
|
25
|
+
ColorAnimationSprite.prototype.checkFrameMax = function () {
|
|
26
|
+
return this.currentFrame >= this.colors.length;
|
|
27
|
+
};
|
|
28
|
+
ColorAnimationSprite.prototype.onDraw = function () {
|
|
29
|
+
Renderer.fill.apply(Renderer, this.colors[this.currentFrame]);
|
|
30
|
+
};
|
|
31
|
+
return ColorAnimationSprite;
|
|
32
|
+
}(AnimationSprite));
|
|
33
|
+
export { ColorAnimationSprite };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class Camera {
|
|
2
|
+
private _width;
|
|
3
|
+
private _height;
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
scaleX: number;
|
|
7
|
+
scaleY: number;
|
|
8
|
+
constructor(_width: number, _height: number);
|
|
9
|
+
get width(): number;
|
|
10
|
+
get height(): number;
|
|
11
|
+
set width(width: number);
|
|
12
|
+
set height(height: number);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=camera.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"camera.d.ts","sourceRoot":"","sources":["../../src/classes/camera.ts"],"names":[],"mappings":"AAAA,qBAAa,MAAM;IAML,OAAO,CAAC,MAAM;IAAU,OAAO,CAAC,OAAO;IALnD,CAAC,EAAE,MAAM,CAAK;IACd,CAAC,EAAE,MAAM,CAAK;IACd,MAAM,EAAE,MAAM,CAAK;IACnB,MAAM,EAAE,MAAM,CAAK;gBAEC,MAAM,EAAE,MAAM,EAAU,OAAO,EAAE,MAAM;IAE3D,IAAI,KAAK,IAQQ,MAAM,CANtB;IAED,IAAI,MAAM,IASS,MAAM,CAPxB;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,EAGtB;IAED,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,EAGxB;CACF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
var Camera = /** @class */ (function () {
|
|
2
|
+
function Camera(_width, _height) {
|
|
3
|
+
this._width = _width;
|
|
4
|
+
this._height = _height;
|
|
5
|
+
this.x = 0;
|
|
6
|
+
this.y = 0;
|
|
7
|
+
this.scaleX = 1;
|
|
8
|
+
this.scaleY = 1;
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(Camera.prototype, "width", {
|
|
11
|
+
get: function () {
|
|
12
|
+
return this._width;
|
|
13
|
+
},
|
|
14
|
+
set: function (width) {
|
|
15
|
+
this._width = width;
|
|
16
|
+
Renderer.resizeCanvas(this._width, this._height);
|
|
17
|
+
},
|
|
18
|
+
enumerable: false,
|
|
19
|
+
configurable: true
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(Camera.prototype, "height", {
|
|
22
|
+
get: function () {
|
|
23
|
+
return this._height;
|
|
24
|
+
},
|
|
25
|
+
set: function (height) {
|
|
26
|
+
this._height = height;
|
|
27
|
+
Renderer.resizeCanvas(this._width, this._height);
|
|
28
|
+
},
|
|
29
|
+
enumerable: false,
|
|
30
|
+
configurable: true
|
|
31
|
+
});
|
|
32
|
+
return Camera;
|
|
33
|
+
}());
|
|
34
|
+
export { Camera };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Body } from "matter-js";
|
|
2
|
+
import { CreateBodyDefine, EntityInitial } from "../../export-types";
|
|
3
|
+
import { Entity } from "./entity";
|
|
4
|
+
export declare class CircleEntity<P extends Record<string, any> = Record<string, any>> extends Entity<P> {
|
|
5
|
+
radius: number;
|
|
6
|
+
onSpriteWidthHeightBinding(): {
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
};
|
|
10
|
+
protected onInitial(): EntityInitial<this>;
|
|
11
|
+
protected onCreateBody({ x, y, ...transform }: NonNullable<CreateBodyDefine<{
|
|
12
|
+
radius: number;
|
|
13
|
+
}>["transform"]>, options?: CreateBodyDefine["bodyOptions"]): Body;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=circle.entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"circle.entity.d.ts","sourceRoot":"","sources":["../../../src/classes/entities/circle.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAU,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAErE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,qBAAa,YAAY,CACvB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CACnD,SAAQ,MAAM,CAAC,CAAC,CAAC;IACV,MAAM,EAAG,MAAM,CAAC;IAEvB,0BAA0B,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAO/D,SAAS,CAAC,SAAS,IAAI,aAAa,CAAC,IAAI,CAAC;IAQ1C,SAAS,CAAC,YAAY,CACpB,EACE,CAAC,EACD,CAAC,EACD,GAAG,SAAS,EACb,EAAE,WAAW,CAAC,gBAAgB,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,WAAW,CAAC,CAAC,EACjE,OAAO,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC,GACxC,IAAI;CAIR"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
17
|
+
var t = {};
|
|
18
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
19
|
+
t[p] = s[p];
|
|
20
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
21
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
22
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
23
|
+
t[p[i]] = s[p[i]];
|
|
24
|
+
}
|
|
25
|
+
return t;
|
|
26
|
+
};
|
|
27
|
+
import { Bodies } from "matter-js";
|
|
28
|
+
import { copyProperties } from "../../utils";
|
|
29
|
+
import { Entity } from "./entity";
|
|
30
|
+
var CircleEntity = /** @class */ (function (_super) {
|
|
31
|
+
__extends(CircleEntity, _super);
|
|
32
|
+
function CircleEntity() {
|
|
33
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
34
|
+
}
|
|
35
|
+
CircleEntity.prototype.onSpriteWidthHeightBinding = function () {
|
|
36
|
+
return {
|
|
37
|
+
width: this.radius * 2,
|
|
38
|
+
height: this.radius * 2,
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
CircleEntity.prototype.onInitial = function () {
|
|
42
|
+
return {
|
|
43
|
+
transform: {
|
|
44
|
+
radius: 1,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
CircleEntity.prototype.onCreateBody = function (_a, options) {
|
|
49
|
+
var x = _a.x, y = _a.y, transform = __rest(_a, ["x", "y"]);
|
|
50
|
+
copyProperties(this, transform);
|
|
51
|
+
return Bodies.circle(x, y, this.radius, options);
|
|
52
|
+
};
|
|
53
|
+
return CircleEntity;
|
|
54
|
+
}(Entity));
|
|
55
|
+
export { CircleEntity };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Initialler } from "../../export-interfaces";
|
|
2
|
+
import { Camera } from "../camera";
|
|
3
|
+
import { LogicComponent } from "../logic-component";
|
|
4
|
+
import { Scene } from "../scene";
|
|
5
|
+
import { WorldManagement } from "../world-management";
|
|
6
|
+
export declare abstract class EntitySult<P = any> implements Initialler<P> {
|
|
7
|
+
camera: Camera;
|
|
8
|
+
readonly id: string;
|
|
9
|
+
private _layerIndex;
|
|
10
|
+
private _name;
|
|
11
|
+
private _scene;
|
|
12
|
+
private _worldManagement;
|
|
13
|
+
private _children;
|
|
14
|
+
private _parent?;
|
|
15
|
+
abstract update(): void;
|
|
16
|
+
abstract draw(): void;
|
|
17
|
+
get children(): EntitySult<any>[];
|
|
18
|
+
get layerIndex(): number;
|
|
19
|
+
get name(): string;
|
|
20
|
+
set layerIndex(_layerIndex: number);
|
|
21
|
+
set name(_name: string);
|
|
22
|
+
get parent(): EntitySult<any> | undefined;
|
|
23
|
+
get scene(): Scene<any>;
|
|
24
|
+
get worldManagement(): WorldManagement;
|
|
25
|
+
addChild(target: EntitySult | LogicComponent<EntitySult>): void;
|
|
26
|
+
removeChild(entity: EntitySult): void;
|
|
27
|
+
unChild(entity: EntitySult): void;
|
|
28
|
+
getProperty<T>(name: string): T;
|
|
29
|
+
preInitial(worldManagement: WorldManagement): void;
|
|
30
|
+
active(worldManagement: WorldManagement): void;
|
|
31
|
+
onActive(): void;
|
|
32
|
+
initial(params: P): void;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=entity-sult.d.ts.map
|
|
@@ -0,0 +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,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,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,SAAgB,EAAE,EAAE,MAAM,CAA8C;IAExE,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,SAAS,CAAoB;IACrC,OAAO,CAAC,OAAO,CAAC,CAAa;IAE7B,QAAQ,CAAC,MAAM,IAAI,IAAI;IACvB,QAAQ,CAAC,IAAI,IAAI,IAAI;IAErB,IAAI,QAAQ,sBAEX;IAED,IAAI,UAAU,IAQc,MAAM,CANjC;IAED,IAAI,IAAI,IAWQ,MAAM,CATrB;IAED,IAAI,UAAU,CAAC,WAAW,EAAE,MAAM,EAKjC;IAED,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,EAUrB;IAED,IAAI,MAAM,gCAET;IAED,IAAI,KAAK,eAER;IAED,IAAI,eAAe,oBAElB;IAED,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC;IAWxD,WAAW,CAAC,MAAM,EAAE,UAAU;IAK9B,OAAO,CAAC,MAAM,EAAE,UAAU;IAO1B,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC;IAI/B,UAAU,CAAC,eAAe,EAAE,eAAe;IAM3C,MAAM,CAAC,eAAe,EAAE,eAAe;IAUvC,QAAQ;IACR,OAAO,CAAC,MAAM,EAAE,CAAC;CAClB"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
var EntitySult = /** @class */ (function () {
|
|
2
|
+
function EntitySult() {
|
|
3
|
+
this.id = "".concat(Math.random(), "-").concat(new Date().getTime());
|
|
4
|
+
this._layerIndex = 0;
|
|
5
|
+
this._name = this.id;
|
|
6
|
+
this._children = [];
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(EntitySult.prototype, "children", {
|
|
9
|
+
get: function () {
|
|
10
|
+
return this._children;
|
|
11
|
+
},
|
|
12
|
+
enumerable: false,
|
|
13
|
+
configurable: true
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(EntitySult.prototype, "layerIndex", {
|
|
16
|
+
get: function () {
|
|
17
|
+
return this._layerIndex;
|
|
18
|
+
},
|
|
19
|
+
set: function (_layerIndex) {
|
|
20
|
+
if (this._layerIndex !== _layerIndex) {
|
|
21
|
+
this.worldManagement.changeEntityLayerIndex(this, _layerIndex);
|
|
22
|
+
}
|
|
23
|
+
this._layerIndex = _layerIndex;
|
|
24
|
+
},
|
|
25
|
+
enumerable: false,
|
|
26
|
+
configurable: true
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(EntitySult.prototype, "name", {
|
|
29
|
+
get: function () {
|
|
30
|
+
return this._name;
|
|
31
|
+
},
|
|
32
|
+
set: function (_name) {
|
|
33
|
+
var _a;
|
|
34
|
+
var isDuplicated = (_a = this.worldManagement) === null || _a === void 0 ? void 0 : _a.getEntity(_name);
|
|
35
|
+
if (isDuplicated) {
|
|
36
|
+
console.warn("Name ".concat(_name, " is already in use"));
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
if (this._name !== _name) {
|
|
40
|
+
this.worldManagement.changeEntityName(this, _name);
|
|
41
|
+
}
|
|
42
|
+
this._name = _name;
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
enumerable: false,
|
|
46
|
+
configurable: true
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(EntitySult.prototype, "parent", {
|
|
49
|
+
get: function () {
|
|
50
|
+
return this._parent;
|
|
51
|
+
},
|
|
52
|
+
enumerable: false,
|
|
53
|
+
configurable: true
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(EntitySult.prototype, "scene", {
|
|
56
|
+
get: function () {
|
|
57
|
+
return this._scene;
|
|
58
|
+
},
|
|
59
|
+
enumerable: false,
|
|
60
|
+
configurable: true
|
|
61
|
+
});
|
|
62
|
+
Object.defineProperty(EntitySult.prototype, "worldManagement", {
|
|
63
|
+
get: function () {
|
|
64
|
+
return this._worldManagement;
|
|
65
|
+
},
|
|
66
|
+
enumerable: false,
|
|
67
|
+
configurable: true
|
|
68
|
+
});
|
|
69
|
+
EntitySult.prototype.addChild = function (target) {
|
|
70
|
+
var entity = target instanceof EntitySult
|
|
71
|
+
? target
|
|
72
|
+
: target.output({ worldManagement: this.worldManagement });
|
|
73
|
+
entity._parent = this;
|
|
74
|
+
this.children.push(entity);
|
|
75
|
+
this.worldManagement.addEntity(entity);
|
|
76
|
+
};
|
|
77
|
+
EntitySult.prototype.removeChild = function (entity) {
|
|
78
|
+
this.unChild(entity);
|
|
79
|
+
this.worldManagement.removeEntity(entity);
|
|
80
|
+
};
|
|
81
|
+
EntitySult.prototype.unChild = function (entity) {
|
|
82
|
+
var delIndex = this.children.indexOf(entity);
|
|
83
|
+
if (delIndex > -1) {
|
|
84
|
+
this.children.splice(delIndex, 1);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
EntitySult.prototype.getProperty = function (name) {
|
|
88
|
+
return this[name];
|
|
89
|
+
};
|
|
90
|
+
EntitySult.prototype.preInitial = function (worldManagement) {
|
|
91
|
+
this._worldManagement = worldManagement;
|
|
92
|
+
this._scene = worldManagement.scene;
|
|
93
|
+
this.camera = worldManagement.camera;
|
|
94
|
+
};
|
|
95
|
+
EntitySult.prototype.active = function (worldManagement) {
|
|
96
|
+
if (!this._worldManagement) {
|
|
97
|
+
this._worldManagement = worldManagement;
|
|
98
|
+
this._scene = worldManagement.scene;
|
|
99
|
+
this.camera = worldManagement.camera;
|
|
100
|
+
}
|
|
101
|
+
console.log("Active entity (name : ".concat(this._name, ")"));
|
|
102
|
+
this.onActive();
|
|
103
|
+
};
|
|
104
|
+
EntitySult.prototype.onActive = function () { };
|
|
105
|
+
EntitySult.prototype.initial = function (params) { };
|
|
106
|
+
return EntitySult;
|
|
107
|
+
}());
|
|
108
|
+
export { EntitySult };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import Matter from "matter-js";
|
|
2
|
+
import { Sprite } from "../sprites/sprite";
|
|
3
|
+
import { CreateBodyDefine, EntityInitial, EntityPrepare, MasterBody } from "../../export-types";
|
|
4
|
+
import { EntitySult } from "./entity-sult";
|
|
5
|
+
import { LogicComponent } from "../logic-component";
|
|
6
|
+
import { Sound } from "../sound";
|
|
7
|
+
declare type TimerJobListener = () => void;
|
|
8
|
+
declare type TerminateOptions = {
|
|
9
|
+
duration?: number;
|
|
10
|
+
effect: EntitySult | LogicComponent<EntitySult>;
|
|
11
|
+
};
|
|
12
|
+
export declare abstract class Entity<P extends Record<string, any> = Record<string, any>> extends EntitySult<EntityInitial<Entity>> {
|
|
13
|
+
private _body;
|
|
14
|
+
private _sprite;
|
|
15
|
+
private _props;
|
|
16
|
+
private timerJobListeners;
|
|
17
|
+
private isTerminate;
|
|
18
|
+
enabledGravity: boolean;
|
|
19
|
+
sound?: Sound;
|
|
20
|
+
set sprite(sprite: Sprite<any>);
|
|
21
|
+
get sprite(): Sprite<any>;
|
|
22
|
+
get position(): Matter.Vector;
|
|
23
|
+
get body(): MasterBody;
|
|
24
|
+
get props(): P;
|
|
25
|
+
/**
|
|
26
|
+
* @param {TerminateOptions} options
|
|
27
|
+
* #duration: time to disappear from the world in seconds, default: 0.2 seconds
|
|
28
|
+
* #effect: effect to showing on duration time
|
|
29
|
+
* @void
|
|
30
|
+
*/
|
|
31
|
+
terminate(options?: TerminateOptions): void;
|
|
32
|
+
/**
|
|
33
|
+
* @param {number} interval in seconds
|
|
34
|
+
* @param {TimerJobListener} job function that run per #interval
|
|
35
|
+
* @void
|
|
36
|
+
*/
|
|
37
|
+
onTimer(interval: number, job: TimerJobListener, defaultRun?: boolean): () => void;
|
|
38
|
+
createBody(transform: CreateBodyDefine["transform"], options?: CreateBodyDefine["bodyOptions"]): MasterBody;
|
|
39
|
+
protected abstract onCreateBody(transform: CreateBodyDefine["transform"], options?: CreateBodyDefine["bodyOptions"]): Matter.Body;
|
|
40
|
+
initial({ transform, sprite: spriteComponent, bodyOptions, props, ...params }: EntityInitial<this>): void;
|
|
41
|
+
protected abstract onInitial(): EntityInitial<this>;
|
|
42
|
+
protected onPrepare(): EntityPrepare<this>;
|
|
43
|
+
update(): void;
|
|
44
|
+
onUpdate(): void;
|
|
45
|
+
draw(): void;
|
|
46
|
+
abstract onSpriteWidthHeightBinding(): {
|
|
47
|
+
width: number;
|
|
48
|
+
height: number;
|
|
49
|
+
};
|
|
50
|
+
onCollision(target: Entity): void;
|
|
51
|
+
onCollisionEnd(target: Entity): void;
|
|
52
|
+
onCollisionActive(target: Entity): void;
|
|
53
|
+
}
|
|
54
|
+
export {};
|
|
55
|
+
//# sourceMappingURL=entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../../src/classes/entities/entity.ts"],"names":[],"mappings":"AAAA,OAAO,MAAwB,MAAM,WAAW,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,UAAU,EACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,aAAK,gBAAgB,GAAG,MAAM,IAAI,CAAC;AAEnC,aAAK,gBAAgB,GAAG;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;CACjD,CAAC;AAEF,8BAAsB,MAAM,CAC1B,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CACnD,SAAQ,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IACzC,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,iBAAiB,CAKhB;IACT,OAAO,CAAC,WAAW,CAAS;IAErB,cAAc,EAAE,OAAO,CAAQ;IAC/B,KAAK,CAAC,EAAE,KAAK,CAAC;IAErB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,EAG7B;IAED,IAAI,MAAM,IALS,MAAM,CAAC,GAAG,CAAC,CAO7B;IAED,IAAI,QAAQ,kBAEX;IAED,IAAI,IAAI,eAEP;IAED,IAAI,KAAK,MAER;IAED;;;;;OAKG;IACH,SAAS,CAAC,OAAO,CAAC,EAAE,gBAAgB;IAkBpC;;;;OAIG;IACH,OAAO,CACL,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,gBAAgB,EACrB,UAAU,UAAQ,GACjB,MAAM,IAAI;IAiBb,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,EACxC,OAAO,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC,GACxC,MAAM,CAAC,IAAI;IAEd,OAAO,CAAC,EACN,SAAS,EACT,MAAM,EAAE,eAAe,EACvB,WAAW,EACX,KAAU,EACV,GAAG,MAAM,EACV,EAAE,aAAa,CAAC,IAAI,CAAC;IAiDtB,SAAS,CAAC,QAAQ,CAAC,SAAS,IAAI,aAAa,CAAC,IAAI,CAAC;IACnD,SAAS,CAAC,SAAS,IAAI,aAAa,CAAC,IAAI,CAAC;IAI1C,MAAM;IAeN,QAAQ;IAER,IAAI;IAMJ,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"}
|