react-simple-game-engine 0.1.59 → 0.1.60

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.
Files changed (105) hide show
  1. package/lib/utilities.js +0 -1
  2. package/package.json +6 -2
  3. package/lib/classes/animations/animation.d.ts +0 -14
  4. package/lib/classes/animations/animation.d.ts.map +0 -1
  5. package/lib/classes/animations/animation.js +0 -35
  6. package/lib/classes/animations/avatar.animation.d.ts +0 -16
  7. package/lib/classes/animations/avatar.animation.d.ts.map +0 -1
  8. package/lib/classes/animations/avatar.animation.js +0 -45
  9. package/lib/classes/animations/color.animation.d.ts +0 -9
  10. package/lib/classes/animations/color.animation.d.ts.map +0 -1
  11. package/lib/classes/animations/color.animation.js +0 -33
  12. package/lib/classes/camera.d.ts +0 -14
  13. package/lib/classes/camera.d.ts.map +0 -1
  14. package/lib/classes/camera.js +0 -34
  15. package/lib/classes/entities/circle.entity.d.ts +0 -15
  16. package/lib/classes/entities/circle.entity.d.ts.map +0 -1
  17. package/lib/classes/entities/circle.entity.js +0 -55
  18. package/lib/classes/entities/entity-sult.d.ts +0 -34
  19. package/lib/classes/entities/entity-sult.d.ts.map +0 -1
  20. package/lib/classes/entities/entity-sult.js +0 -108
  21. package/lib/classes/entities/entity.d.ts +0 -55
  22. package/lib/classes/entities/entity.d.ts.map +0 -1
  23. package/lib/classes/entities/entity.js +0 -180
  24. package/lib/classes/entities/rect.entity.d.ts +0 -17
  25. package/lib/classes/entities/rect.entity.d.ts.map +0 -1
  26. package/lib/classes/entities/rect.entity.js +0 -56
  27. package/lib/classes/logic-component.d.ts +0 -16
  28. package/lib/classes/logic-component.d.ts.map +0 -1
  29. package/lib/classes/logic-component.js +0 -77
  30. package/lib/classes/p5.d.ts +0 -11
  31. package/lib/classes/p5.d.ts.map +0 -1
  32. package/lib/classes/p5.js +0 -58
  33. package/lib/classes/particle-system.d.ts +0 -30
  34. package/lib/classes/particle-system.d.ts.map +0 -1
  35. package/lib/classes/particle-system.js +0 -98
  36. package/lib/classes/particle.d.ts +0 -35
  37. package/lib/classes/particle.d.ts.map +0 -1
  38. package/lib/classes/particle.js +0 -117
  39. package/lib/classes/prefab.d.ts +0 -7
  40. package/lib/classes/prefab.d.ts.map +0 -1
  41. package/lib/classes/prefab.js +0 -24
  42. package/lib/classes/saver.d.ts +0 -11
  43. package/lib/classes/saver.d.ts.map +0 -1
  44. package/lib/classes/saver.js +0 -33
  45. package/lib/classes/scene-management.d.ts +0 -22
  46. package/lib/classes/scene-management.d.ts.map +0 -1
  47. package/lib/classes/scene-management.js +0 -58
  48. package/lib/classes/scene.d.ts +0 -75
  49. package/lib/classes/scene.d.ts.map +0 -1
  50. package/lib/classes/scene.js +0 -433
  51. package/lib/classes/sound-watcher.d.ts +0 -16
  52. package/lib/classes/sound-watcher.d.ts.map +0 -1
  53. package/lib/classes/sound-watcher.js +0 -33
  54. package/lib/classes/sound.d.ts +0 -14
  55. package/lib/classes/sound.d.ts.map +0 -1
  56. package/lib/classes/sound.js +0 -119
  57. package/lib/classes/sprites/avatar.sprite.d.ts +0 -20
  58. package/lib/classes/sprites/avatar.sprite.d.ts.map +0 -1
  59. package/lib/classes/sprites/avatar.sprite.js +0 -89
  60. package/lib/classes/sprites/color.sprite.d.ts +0 -7
  61. package/lib/classes/sprites/color.sprite.d.ts.map +0 -1
  62. package/lib/classes/sprites/color.sprite.js +0 -40
  63. package/lib/classes/sprites/sprite.d.ts +0 -26
  64. package/lib/classes/sprites/sprite.d.ts.map +0 -1
  65. package/lib/classes/sprites/sprite.js +0 -70
  66. package/lib/classes/watcher.d.ts +0 -11
  67. package/lib/classes/watcher.d.ts.map +0 -1
  68. package/lib/classes/watcher.js +0 -44
  69. package/lib/classes/world-management.d.ts +0 -28
  70. package/lib/classes/world-management.d.ts.map +0 -1
  71. package/lib/classes/world-management.js +0 -160
  72. package/lib/decorators/scene-tag.decor.d.ts +0 -6
  73. package/lib/decorators/scene-tag.decor.d.ts.map +0 -1
  74. package/lib/decorators/scene-tag.decor.js +0 -5
  75. package/lib/decorators/scene-ui.decor.d.ts +0 -7
  76. package/lib/decorators/scene-ui.decor.d.ts.map +0 -1
  77. package/lib/decorators/scene-ui.decor.js +0 -5
  78. package/lib/decorators/sound-from.decor.d.ts +0 -6
  79. package/lib/decorators/sound-from.decor.d.ts.map +0 -1
  80. package/lib/decorators/sound-from.decor.js +0 -17
  81. package/lib/decorators/sprite-from.decor.d.ts +0 -4
  82. package/lib/decorators/sprite-from.decor.d.ts.map +0 -1
  83. package/lib/decorators/sprite-from.decor.js +0 -13
  84. package/lib/export-enums.d.ts +0 -5
  85. package/lib/export-enums.d.ts.map +0 -1
  86. package/lib/export-interfaces.d.ts +0 -4
  87. package/lib/export-interfaces.d.ts.map +0 -1
  88. package/lib/export-types.d.ts +0 -53
  89. package/lib/export-types.d.ts.map +0 -1
  90. package/lib/index.d.ts +0 -25
  91. package/lib/index.d.ts.map +0 -1
  92. package/lib/ui-components/SceneRunner.d.ts +0 -14
  93. package/lib/ui-components/SceneRunner.d.ts.map +0 -1
  94. package/lib/ui-components/SceneRunner.js +0 -43
  95. package/lib/ui-components/ScenesProcess.d.ts +0 -9
  96. package/lib/ui-components/ScenesProcess.d.ts.map +0 -1
  97. package/lib/ui-components/ScenesProcess.js +0 -46
  98. package/lib/ui-components/Sketch.d.ts +0 -12
  99. package/lib/ui-components/Sketch.d.ts.map +0 -1
  100. package/lib/ui-components/Sketch.js +0 -33
  101. package/lib/utilities.d.ts +0 -4
  102. package/lib/utilities.d.ts.map +0 -1
  103. package/lib/utils.d.ts +0 -8
  104. package/lib/utils.d.ts.map +0 -1
  105. package/lib/utils.js +0 -97
@@ -1,180 +0,0 @@
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 __assign = (this && this.__assign) || function () {
17
- __assign = Object.assign || function(t) {
18
- for (var s, i = 1, n = arguments.length; i < n; i++) {
19
- s = arguments[i];
20
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
21
- t[p] = s[p];
22
- }
23
- return t;
24
- };
25
- return __assign.apply(this, arguments);
26
- };
27
- var __rest = (this && this.__rest) || function (s, e) {
28
- var t = {};
29
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
30
- t[p] = s[p];
31
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
32
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
33
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
34
- t[p[i]] = s[p[i]];
35
- }
36
- return t;
37
- };
38
- import { Body } from "matter-js";
39
- import { ColorSprite } from "../sprites/color.sprite";
40
- import { EntitySult } from "./entity-sult";
41
- import { copyProperties } from "../../utils";
42
- var Entity = /** @class */ (function (_super) {
43
- __extends(Entity, _super);
44
- function Entity() {
45
- var _this = _super !== null && _super.apply(this, arguments) || this;
46
- _this._props = {};
47
- _this.timerJobListeners = [];
48
- _this.isTerminate = false;
49
- _this.enabledGravity = true;
50
- return _this;
51
- }
52
- Object.defineProperty(Entity.prototype, "sprite", {
53
- get: function () {
54
- return this._sprite;
55
- },
56
- set: function (sprite) {
57
- this._sprite = sprite;
58
- this._sprite.entity = this;
59
- },
60
- enumerable: false,
61
- configurable: true
62
- });
63
- Object.defineProperty(Entity.prototype, "position", {
64
- get: function () {
65
- return this._body.position;
66
- },
67
- enumerable: false,
68
- configurable: true
69
- });
70
- Object.defineProperty(Entity.prototype, "body", {
71
- get: function () {
72
- return this._body;
73
- },
74
- enumerable: false,
75
- configurable: true
76
- });
77
- Object.defineProperty(Entity.prototype, "props", {
78
- get: function () {
79
- return this._props;
80
- },
81
- enumerable: false,
82
- configurable: true
83
- });
84
- /**
85
- * @param {TerminateOptions} options
86
- * #duration: time to disappear from the world in seconds, default: 0.2 seconds
87
- * #effect: effect to showing on duration time
88
- * @void
89
- */
90
- Entity.prototype.terminate = function (options) {
91
- var _this = this;
92
- if (options) {
93
- var _a = options.duration, duration = _a === void 0 ? 0.2 : _a, effect = options.effect;
94
- this.isTerminate = true;
95
- Body.setVelocity(this.body, {
96
- y: 0,
97
- x: 0,
98
- });
99
- this.addChild(effect);
100
- setTimeout(function () {
101
- _this.worldManagement.removeEntity(_this);
102
- }, duration * 1000);
103
- }
104
- else {
105
- this.worldManagement.removeEntity(this);
106
- }
107
- };
108
- /**
109
- * @param {number} interval in seconds
110
- * @param {TimerJobListener} job function that run per #interval
111
- * @void
112
- */
113
- Entity.prototype.onTimer = function (interval, job, defaultRun) {
114
- var _this = this;
115
- if (defaultRun === void 0) { defaultRun = false; }
116
- var listener = {
117
- timeCounter: 0,
118
- interval: interval,
119
- job: job,
120
- defaultRun: defaultRun,
121
- };
122
- this.timerJobListeners.push(listener);
123
- return function () {
124
- var index = _this.timerJobListeners.indexOf(listener);
125
- if (index > -1) {
126
- _this.timerJobListeners.splice(index, 1);
127
- }
128
- };
129
- };
130
- Entity.prototype.createBody = function (transform, options) {
131
- this._body = this.onCreateBody(transform, options);
132
- this._body.entity = this;
133
- return this._body;
134
- };
135
- Entity.prototype.initial = function (_a) {
136
- var transform = _a.transform, spriteComponent = _a.sprite, bodyOptions = _a.bodyOptions, _b = _a.props, props = _b === void 0 ? {} : _b, params = __rest(_a, ["transform", "sprite", "bodyOptions", "props"]);
137
- var _c = this.onInitial(), _d = _c.transform, _e = _d === void 0 ? {} : _d, _f = _e.x, x = _f === void 0 ? 0 : _f, _g = _e.y, y = _g === void 0 ? 0 : _g, dfTransform = __rest(_e, ["x", "y"]), dfBodyOptions = _c.bodyOptions, dfSpriteComponent = _c.sprite, _h = _c.props, dfProps = _h === void 0 ? {} : _h, dfParams = __rest(_c, ["transform", "bodyOptions", "sprite", "props"]);
138
- copyProperties(this._props, __assign(__assign({}, dfProps), props));
139
- var _j = this.onPrepare(), transformAlt = _j.transform, bodyOptionsAlt = _j.bodyOptions, spriteComponentAlt = _j.sprite, _k = _j.props, propsAlt = _k === void 0 ? {} : _k, paramsAlt = __rest(_j, ["transform", "bodyOptions", "sprite", "props"]);
140
- this.createBody(__assign(__assign(__assign({ x: x, y: y }, dfTransform), transform), transformAlt), __assign(__assign(__assign({}, dfBodyOptions), bodyOptions), bodyOptionsAlt));
141
- copyProperties(this._props, __assign({}, propsAlt));
142
- copyProperties(this, __assign(__assign(__assign({}, dfParams), params), paramsAlt));
143
- //@ts-ignore
144
- this.sprite =
145
- (dfSpriteComponent === null || dfSpriteComponent === void 0 ? void 0 : dfSpriteComponent.output()) ||
146
- (spriteComponent === null || spriteComponent === void 0 ? void 0 : spriteComponent.output()) ||
147
- (spriteComponentAlt === null || spriteComponentAlt === void 0 ? void 0 : spriteComponentAlt.output()) ||
148
- new ColorSprite();
149
- };
150
- Entity.prototype.onPrepare = function () {
151
- return {};
152
- };
153
- Entity.prototype.update = function () {
154
- if (!this.isTerminate) {
155
- this.onUpdate();
156
- }
157
- for (var _i = 0, _a = this.timerJobListeners; _i < _a.length; _i++) {
158
- var jobListener = _a[_i];
159
- var timeCounter = jobListener.timeCounter, interval = jobListener.interval, job = jobListener.job, defaultRun = jobListener.defaultRun;
160
- if (defaultRun || timeCounter / 1000 >= interval) {
161
- timeCounter = 0;
162
- job();
163
- jobListener.defaultRun = false;
164
- }
165
- timeCounter += Renderer.deltaTime;
166
- jobListener.timeCounter = timeCounter;
167
- }
168
- };
169
- Entity.prototype.onUpdate = function () { };
170
- Entity.prototype.draw = function () {
171
- if (!this.isTerminate) {
172
- this.sprite.draw();
173
- }
174
- };
175
- Entity.prototype.onCollision = function (target) { };
176
- Entity.prototype.onCollisionEnd = function (target) { };
177
- Entity.prototype.onCollisionActive = function (target) { };
178
- return Entity;
179
- }(EntitySult));
180
- export { Entity };
@@ -1,17 +0,0 @@
1
- import { Body } from "matter-js";
2
- import { CreateBodyDefine, EntityInitial } from "../../export-types";
3
- import { Entity } from "./entity";
4
- export declare class RectEntity<P extends Record<string, any> = any> extends Entity<P> {
5
- width: number;
6
- height: number;
7
- onSpriteWidthHeightBinding(): {
8
- width: number;
9
- height: number;
10
- };
11
- protected onInitial(): EntityInitial<this>;
12
- protected onCreateBody({ x, y, ...transform }: NonNullable<CreateBodyDefine<{
13
- width?: number;
14
- height?: number;
15
- }>["transform"]>, options?: CreateBodyDefine["bodyOptions"]): Body;
16
- }
17
- //# sourceMappingURL=rect.entity.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rect.entity.d.ts","sourceRoot":"","sources":["../../../src/classes/entities/rect.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,IAAI,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAErE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,qBAAa,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,CAAE,SAAQ,MAAM,CAAC,CAAC,CAAC;IACrE,KAAK,EAAG,MAAM,CAAC;IACf,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;IAS1C,SAAS,CAAC,YAAY,CACpB,EACE,CAAC,EACD,CAAC,EACD,GAAG,SAAS,EACb,EAAE,WAAW,CACZ,gBAAgB,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC,WAAW,CAAC,CAChB,EACD,OAAO,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC,GACxC,IAAI;CAIR"}
@@ -1,56 +0,0 @@
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 RectEntity = /** @class */ (function (_super) {
31
- __extends(RectEntity, _super);
32
- function RectEntity() {
33
- return _super !== null && _super.apply(this, arguments) || this;
34
- }
35
- RectEntity.prototype.onSpriteWidthHeightBinding = function () {
36
- return {
37
- width: this.width,
38
- height: this.height,
39
- };
40
- };
41
- RectEntity.prototype.onInitial = function () {
42
- return {
43
- transform: {
44
- width: 1,
45
- height: 1,
46
- },
47
- };
48
- };
49
- RectEntity.prototype.onCreateBody = function (_a, options) {
50
- var x = _a.x, y = _a.y, transform = __rest(_a, ["x", "y"]);
51
- copyProperties(this, transform);
52
- return Bodies.rectangle(x, y, this.width, this.height, options);
53
- };
54
- return RectEntity;
55
- }(Entity));
56
- export { RectEntity };
@@ -1,16 +0,0 @@
1
- import { Initialler } from "../export-interfaces";
2
- import { Configable, Configation } from "../export-types";
3
- import { WorldManagement } from "./world-management";
4
- export declare class LogicComponent<C extends Initialler = Initialler> {
5
- private readonly configale;
6
- private readonly _isPrefab?;
7
- private _worldManagement;
8
- layerIndex: number;
9
- constructor(configale: Configable<C>, _isPrefab?: boolean | undefined);
10
- get isPrefab(): boolean | undefined;
11
- set worldManagement(_worldManagement: WorldManagement);
12
- output({ worldManagement, ...targetParams }?: {
13
- worldManagement?: WorldManagement;
14
- } & Configation<C>): C;
15
- }
16
- //# sourceMappingURL=logic-component.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logic-component.d.ts","sourceRoot":"","sources":["../../src/classes/logic-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAI1D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,qBAAa,cAAc,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU;IAIzD,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC;IAJ7B,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,UAAU,EAAE,MAAM,CAAK;gBAEJ,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,EACxB,SAAS,CAAC,qBAAS;IAGtC,IAAI,QAAQ,wBAEX;IAED,IAAI,eAAe,CAAC,gBAAgB,EAAE,eAAe,EAMpD;IAED,MAAM,CAAC,EACL,eAAe,EACf,GAAG,YAAY,EAChB,GAAE;QACD,eAAe,CAAC,EAAE,eAAe,CAAC;KACnC,GAAG,WAAW,CAAC,CAAC,CAAM;CA6CxB"}
@@ -1,77 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __rest = (this && this.__rest) || function (s, e) {
13
- var t = {};
14
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
- t[p] = s[p];
16
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
- t[p[i]] = s[p[i]];
20
- }
21
- return t;
22
- };
23
- import { Entity } from "./entities/entity";
24
- import { EntitySult } from "./entities/entity-sult";
25
- var LogicComponent = /** @class */ (function () {
26
- function LogicComponent(configale, _isPrefab) {
27
- this.configale = configale;
28
- this._isPrefab = _isPrefab;
29
- this.layerIndex = 0;
30
- }
31
- Object.defineProperty(LogicComponent.prototype, "isPrefab", {
32
- get: function () {
33
- return this._isPrefab;
34
- },
35
- enumerable: false,
36
- configurable: true
37
- });
38
- Object.defineProperty(LogicComponent.prototype, "worldManagement", {
39
- set: function (_worldManagement) {
40
- if (this._worldManagement) {
41
- console.warn("Cant change worldManagement");
42
- }
43
- else {
44
- this._worldManagement = _worldManagement;
45
- }
46
- },
47
- enumerable: false,
48
- configurable: true
49
- });
50
- LogicComponent.prototype.output = function (_a) {
51
- if (_a === void 0) { _a = {}; }
52
- var worldManagement = _a.worldManagement, targetParams = __rest(_a, ["worldManagement"]);
53
- var configale = this.configale;
54
- var _b = Array.isArray(configale)
55
- ? configale
56
- : [configale], Class = _b[0], _c = _b[1], params = _c === void 0 ? {} : _c;
57
- var c = new Class();
58
- if (worldManagement) {
59
- this.worldManagement = worldManagement;
60
- }
61
- if (c instanceof EntitySult) {
62
- c["_layerIndex"] = this.layerIndex; // use _layerIndex to not trigger change index process at this step
63
- c.preInitial(this._worldManagement);
64
- }
65
- if (c instanceof Entity) {
66
- var _d = params, transform = _d.transform, bodyOptions = _d.bodyOptions, props = _d.props, restParams = __rest(_d, ["transform", "bodyOptions", "props"]);
67
- var extraTransform = targetParams.transform, extraBodyOptions = targetParams.bodyOptions, extraProps = targetParams.props, extraRestParams = __rest(targetParams, ["transform", "bodyOptions", "props"]);
68
- c.initial(__assign(__assign({ transform: __assign(__assign({}, transform), extraTransform), bodyOptions: __assign(__assign({}, bodyOptions), extraBodyOptions), props: __assign(__assign({}, props), extraProps) }, restParams), extraRestParams));
69
- }
70
- else {
71
- c.initial(__assign(__assign({}, params), targetParams));
72
- }
73
- return c;
74
- };
75
- return LogicComponent;
76
- }());
77
- export { LogicComponent };
@@ -1,11 +0,0 @@
1
- import p5 from "p5";
2
- declare type ItemWithPercent<I> = [I, number];
3
- declare type LastItem<I> = [I];
4
- export declare type Collection<I> = [...ItemWithPercent<I>[], LastItem<I>];
5
- export declare class P5 extends p5 {
6
- running: boolean;
7
- constructor(sketch: (p5: P5) => void);
8
- choose<I = any>(collection: Collection<I>): I;
9
- }
10
- export {};
11
- //# sourceMappingURL=p5.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"p5.d.ts","sourceRoot":"","sources":["../../src/classes/p5.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,aAAK,eAAe,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AACtC,aAAK,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAEvB,oBAAY,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AAEnE,qBAAa,EAAG,SAAQ,EAAE;IACxB,OAAO,UAAQ;gBAEH,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,IAAI;IAKpC,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC;CA+B9C"}
package/lib/classes/p5.js DELETED
@@ -1,58 +0,0 @@
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 p5 from "p5";
17
- var P5 = /** @class */ (function (_super) {
18
- __extends(P5, _super);
19
- function P5(sketch) {
20
- var _this = _super.call(this, sketch) || this;
21
- _this.running = true;
22
- window.Renderer = _this;
23
- return _this;
24
- }
25
- P5.prototype.choose = function (collection) {
26
- var lastItem = collection[collection.length - 1];
27
- var restItems = collection.slice(0, collection.length - 1);
28
- var totalPercentsOfRestItems = restItems.reduce(function (t, item) {
29
- return t + item[1];
30
- }, 0);
31
- if (totalPercentsOfRestItems > 1) {
32
- var overmax = totalPercentsOfRestItems - 1;
33
- var avg = 1 / restItems.length;
34
- for (var _i = 0, restItems_1 = restItems; _i < restItems_1.length; _i++) {
35
- var item = restItems_1[_i];
36
- if (item[1] > avg) {
37
- item[1] -= overmax;
38
- }
39
- }
40
- totalPercentsOfRestItems = 1;
41
- }
42
- lastItem[1] = 1 - totalPercentsOfRestItems;
43
- var items = [];
44
- var _loop_1 = function (item, percent) {
45
- Array.from({ length: Math.round(percent * 10) }).forEach(function () {
46
- items.push(item);
47
- });
48
- };
49
- for (var _a = 0, collection_1 = collection; _a < collection_1.length; _a++) {
50
- var _b = collection_1[_a], item = _b[0], percent = _b[1];
51
- _loop_1(item, percent);
52
- }
53
- this.shuffle(items, true);
54
- return this.random(items);
55
- };
56
- return P5;
57
- }(p5));
58
- export { P5 };
@@ -1,30 +0,0 @@
1
- import p5 from "p5";
2
- import { Particle, ParticleInitialParams } from "./particle";
3
- import { EntitySult } from "./entities/entity-sult";
4
- declare type ParticleClass = {
5
- new (...args: ConstructorParameters<typeof Particle>): Particle;
6
- };
7
- declare type ParticleOptions = Omit<ParticleInitialParams, "vec" | "angle" | "camera"> & {
8
- x?: number;
9
- y?: number;
10
- };
11
- declare type ParticleSystemInitialParams = {
12
- particleClass?: ParticleClass;
13
- particleOptions?: ParticleOptions;
14
- quantityPerFrame?: number;
15
- vecWeight?: number;
16
- forces?: p5.Vector[];
17
- };
18
- export declare class ParticleSystem extends EntitySult<ParticleSystemInitialParams> {
19
- private particles;
20
- private forces;
21
- private particleOptions;
22
- private particleClass;
23
- quantityPerFrame: number;
24
- vecWeight: number;
25
- initial({ forces, particleOptions, ...params }: ParticleSystemInitialParams): void;
26
- update(): void;
27
- draw(): void;
28
- }
29
- export {};
30
- //# sourceMappingURL=particle-system.d.ts.map
@@ -1 +0,0 @@
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,QAAQ,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,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"}
@@ -1,98 +0,0 @@
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 __assign = (this && this.__assign) || function () {
17
- __assign = Object.assign || function(t) {
18
- for (var s, i = 1, n = arguments.length; i < n; i++) {
19
- s = arguments[i];
20
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
21
- t[p] = s[p];
22
- }
23
- return t;
24
- };
25
- return __assign.apply(this, arguments);
26
- };
27
- var __rest = (this && this.__rest) || function (s, e) {
28
- var t = {};
29
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
30
- t[p] = s[p];
31
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
32
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
33
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
34
- t[p[i]] = s[p[i]];
35
- }
36
- return t;
37
- };
38
- import p5 from "p5";
39
- import { copyProperties } from "../utils";
40
- import { Particle } from "./particle";
41
- import { EntitySult } from "./entities/entity-sult";
42
- var ParticleSystem = /** @class */ (function (_super) {
43
- __extends(ParticleSystem, _super);
44
- function ParticleSystem() {
45
- var _this = _super !== null && _super.apply(this, arguments) || this;
46
- _this.particles = [];
47
- _this.forces = [];
48
- _this.particleOptions = {
49
- x: 0,
50
- y: 0,
51
- };
52
- _this.particleClass = Particle;
53
- _this.quantityPerFrame = 50;
54
- _this.vecWeight = 5;
55
- return _this;
56
- }
57
- ParticleSystem.prototype.initial = function (_a) {
58
- var _b;
59
- var forces = _a.forces, _c = _a.particleOptions, particleOptions = _c === void 0 ? {} : _c, params = __rest(_a, ["forces", "particleOptions"]);
60
- copyProperties(this.particleOptions, particleOptions);
61
- copyProperties(this, params);
62
- if (forces) {
63
- (_b = this.forces).push.apply(_b, forces);
64
- }
65
- };
66
- ParticleSystem.prototype.update = function () {
67
- var ParticleClass = this.particleClass;
68
- var _a = this.particleOptions, x = _a.x, y = _a.y, particleOptions = __rest(_a, ["x", "y"]);
69
- for (var _i = 0, _b = Array.from({ length: this.quantityPerFrame }); _i < _b.length; _i++) {
70
- var _ = _b[_i];
71
- var p = new ParticleClass(x, y);
72
- var vec = p5.Vector.random2D();
73
- vec.mult(Renderer.random(this.vecWeight));
74
- var angle = Renderer.random(Renderer.TWO_PI);
75
- p.initial(__assign(__assign({}, particleOptions), { camera: this.camera, vec: vec, angle: angle }));
76
- this.particles.push(p);
77
- }
78
- for (var i = this.particles.length - 1; i > -1; i--) {
79
- var p = this.particles[i];
80
- for (var _c = 0, _d = this.forces; _c < _d.length; _c++) {
81
- var force = _d[_c];
82
- p.applyForce(force);
83
- }
84
- p.update();
85
- if (p.isDead()) {
86
- this.particles.splice(i, 1);
87
- }
88
- }
89
- };
90
- ParticleSystem.prototype.draw = function () {
91
- for (var _i = 0, _a = this.particles; _i < _a.length; _i++) {
92
- var particle = _a[_i];
93
- particle.draw();
94
- }
95
- };
96
- return ParticleSystem;
97
- }(EntitySult));
98
- export { ParticleSystem };
@@ -1,35 +0,0 @@
1
- import p5 from "p5";
2
- import { Initialler } from "../export-interfaces";
3
- import { Avatar, Color } from "../export-types";
4
- import { Camera } from "./camera";
5
- export declare type ParticleInitialParams = {
6
- vec?: p5.Vector;
7
- angle?: number;
8
- sprite?: Avatar;
9
- color?: Color;
10
- size?: number;
11
- lifetime?: number;
12
- camera: Camera;
13
- forceSpriteSize?: boolean;
14
- };
15
- export declare class Particle extends p5.Vector implements Initialler<ParticleInitialParams> {
16
- private vec;
17
- private acc;
18
- private angle;
19
- camera: Camera;
20
- sprite?: Avatar;
21
- color: Color;
22
- size: number;
23
- lifetimeRemain: number;
24
- private forceSpriteSize;
25
- private _lifetime;
26
- set lifetime(lifetime: number);
27
- get lifetime(): number;
28
- initial({ vec, ...params }: ParticleInitialParams): void;
29
- applyForce(force: p5.Vector): void;
30
- isDead(): boolean;
31
- update(): void;
32
- draw(): void;
33
- onDraw(_: Color): void;
34
- }
35
- //# sourceMappingURL=particle.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"particle.d.ts","sourceRoot":"","sources":["../../src/classes/particle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,oBAAY,qBAAqB,GAAG;IAClC,GAAG,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,qBAAa,QACX,SAAQ,EAAE,CAAC,MACX,YAAW,UAAU,CAAC,qBAAqB,CAAC;IAE5C,OAAO,CAAC,GAAG,CAAsC;IACjD,OAAO,CAAC,GAAG,CAAsC;IACjD,OAAO,CAAC,KAAK,CAAa;IACnB,MAAM,EAAG,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,KAAK,CAAmB;IAC/B,IAAI,EAAE,MAAM,CAAK;IACjB,cAAc,EAAE,MAAM,CAAiB;IAE9C,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,SAAS,CAAa;IAE9B,IAAI,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAG5B;IAED,IAAI,QAAQ,IALW,MAAM,CAO5B;IAED,OAAO,CAAC,EAAE,GAAG,EAAE,GAAG,MAAM,EAAE,EAAE,qBAAqB;IAOjD,UAAU,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM;IAI3B,MAAM;IAIN,MAAM;IAQN,IAAI;IAmCJ,MAAM,CAAC,CAAC,EAAE,KAAK;CAGhB"}