react-simple-game-engine 0.1.0 → 0.1.3
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 +2 -1
- package/lib/classes/entities/entity-sult.d.ts.map +1 -1
- package/lib/classes/entities/entity-sult.js +2 -1
- package/lib/classes/p5.d.ts +1 -4
- package/lib/classes/p5.d.ts.map +1 -1
- package/lib/classes/p5.js +1 -10
- package/lib/classes/world-management.d.ts +1 -0
- package/lib/classes/world-management.d.ts.map +1 -1
- package/lib/classes/world-management.js +4 -0
- package/lib/ui-components/Sketch.js +4 -3
- package/package.json +1 -1
@@ -4,10 +4,11 @@ import { Scene } from "../scene";
|
|
4
4
|
import { WorldManagement } from "../world-management";
|
5
5
|
export declare abstract class EntitySult<P = any> implements Initialler<P> {
|
6
6
|
camera: Camera;
|
7
|
-
private readonly id;
|
8
7
|
readonly tag: string;
|
8
|
+
private readonly id;
|
9
9
|
private _scene;
|
10
10
|
private _worldManagement;
|
11
|
+
name: string;
|
11
12
|
constructor();
|
12
13
|
abstract update(): void;
|
13
14
|
abstract draw(): void;
|
@@ -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,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,
|
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,SAAgB,GAAG,EAAG,MAAM,CAAC;IAE7B,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAsD;IACzE,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,gBAAgB,CAAmB;IACpC,IAAI,SAAW;;IAMtB,QAAQ,CAAC,MAAM,IAAI,IAAI;IACvB,QAAQ,CAAC,IAAI,IAAI,IAAI;IAErB,IAAI,KAAK,eAER;IAED,IAAI,eAAe,oBAElB;IAED,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"}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
var EntitySult = /** @class */ (function () {
|
2
2
|
function EntitySult() {
|
3
3
|
this.id = "".concat(Math.random(), "-").concat(new Date().getTime());
|
4
|
+
this.name = this.id;
|
4
5
|
this.tag = this.constructor.tag;
|
5
6
|
}
|
6
7
|
Object.defineProperty(EntitySult.prototype, "scene", {
|
@@ -31,7 +32,7 @@ var EntitySult = /** @class */ (function () {
|
|
31
32
|
this._scene = worldManagement.scene;
|
32
33
|
this.camera = worldManagement.camera;
|
33
34
|
}
|
34
|
-
console.log("Active ".concat(this.tag, " entity (
|
35
|
+
console.log("Active ".concat(this.tag, " entity (name : ").concat(this.name, ")"));
|
35
36
|
this.onActive();
|
36
37
|
};
|
37
38
|
EntitySult.prototype.onActive = function () { };
|
package/lib/classes/p5.d.ts
CHANGED
@@ -1,12 +1,9 @@
|
|
1
1
|
import p5 from "p5";
|
2
|
-
import { Camera } from "./camera";
|
3
2
|
declare type ItemWithPercent<I> = [I, number];
|
4
3
|
declare type LastItem<I> = [I];
|
5
4
|
export declare type Collection<I> = [...ItemWithPercent<I>[], LastItem<I>];
|
6
5
|
export declare class P5 extends p5 {
|
7
|
-
|
8
|
-
constructor(sketch: (p5: P5) => void, width: number, height: number);
|
9
|
-
get simpleCamera(): Camera;
|
6
|
+
constructor(sketch: (p5: P5) => void);
|
10
7
|
choose<I = any>(collection: Collection<I>): I;
|
11
8
|
}
|
12
9
|
export {};
|
package/lib/classes/p5.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"p5.d.ts","sourceRoot":"","sources":["../../src/classes/p5.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;
|
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;gBACZ,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,IAAI;IAKpC,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC;CAgC9C"}
|
package/lib/classes/p5.js
CHANGED
@@ -14,22 +14,13 @@ var __extends = (this && this.__extends) || (function () {
|
|
14
14
|
};
|
15
15
|
})();
|
16
16
|
import p5 from "p5";
|
17
|
-
import { Camera } from "./camera";
|
18
17
|
var P5 = /** @class */ (function (_super) {
|
19
18
|
__extends(P5, _super);
|
20
|
-
function P5(sketch
|
19
|
+
function P5(sketch) {
|
21
20
|
var _this = _super.call(this, sketch) || this;
|
22
21
|
window.Renderer = _this;
|
23
|
-
_this._simpleCamera = new Camera(width, height);
|
24
22
|
return _this;
|
25
23
|
}
|
26
|
-
Object.defineProperty(P5.prototype, "simpleCamera", {
|
27
|
-
get: function () {
|
28
|
-
return this._simpleCamera;
|
29
|
-
},
|
30
|
-
enumerable: false,
|
31
|
-
configurable: true
|
32
|
-
});
|
33
24
|
P5.prototype.choose = function (collection) {
|
34
25
|
var lastItem = collection[collection.length - 1];
|
35
26
|
var restItems = collection.slice(0, collection.length - 1);
|
@@ -13,6 +13,7 @@ export declare class WorldManagement {
|
|
13
13
|
get camera(): Camera;
|
14
14
|
get scene(): Scene<any>;
|
15
15
|
destructor(): void;
|
16
|
+
getEntity<T extends EntitySult = EntitySult>(name: string): T;
|
16
17
|
addEntity(entity: EntitySult): void;
|
17
18
|
removeEntity(entity: EntitySult): void;
|
18
19
|
update(): void;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"world-management.d.ts","sourceRoot":"","sources":["../../src/classes/world-management.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAuB,MAAM,WAAW,CAAC;AAIxD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,qBAAa,eAAe;IAId,OAAO,CAAC,OAAO;IAAU,OAAO,CAAC,MAAM;IAHnD,OAAO,CAAC,SAAS,CAAoB;IACrC,OAAO,CAAC,OAAO,CAAU;gBAEL,OAAO,EAAE,MAAM,EAAU,MAAM,EAAE,KAAK;IAgD1D,IAAI,QAAQ,sBAEX;IAED,IAAI,MAAM,WAET;IAED,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
|
+
{"version":3,"file":"world-management.d.ts","sourceRoot":"","sources":["../../src/classes/world-management.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAuB,MAAM,WAAW,CAAC;AAIxD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,qBAAa,eAAe;IAId,OAAO,CAAC,OAAO;IAAU,OAAO,CAAC,MAAM;IAHnD,OAAO,CAAC,SAAS,CAAoB;IACrC,OAAO,CAAC,OAAO,CAAU;gBAEL,OAAO,EAAE,MAAM,EAAU,MAAM,EAAE,KAAK;IAgD1D,IAAI,QAAQ,sBAEX;IAED,IAAI,MAAM,WAET;IAED,IAAI,MAAM,WAET;IAED,IAAI,KAAK,eAER;IAED,UAAU;IAKV,SAAS,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC;IAK7D,SAAS,CAAC,MAAM,EAAE,UAAU;IAS5B,YAAY,CAAC,MAAM,EAAE,UAAU;IAa/B,MAAM;IAON,IAAI;CAKL"}
|
@@ -79,6 +79,10 @@ var WorldManagement = /** @class */ (function () {
|
|
79
79
|
World.clear(this.engine.world, false);
|
80
80
|
Engine.clear(this.engine);
|
81
81
|
};
|
82
|
+
WorldManagement.prototype.getEntity = function (name) {
|
83
|
+
//@ts-ignore
|
84
|
+
return this.entities.find(function (entity) { return entity.name === name; });
|
85
|
+
};
|
82
86
|
WorldManagement.prototype.addEntity = function (entity) {
|
83
87
|
// temp pass modifier
|
84
88
|
this.entities.push(entity);
|
@@ -1,20 +1,21 @@
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
2
2
|
import { useEffect, useRef } from "react";
|
3
|
+
import { Camera } from "../classes/camera";
|
3
4
|
import { P5 } from "../classes/p5";
|
4
5
|
export function Sketch(_a) {
|
5
6
|
var onSetup = _a.onSetup, onDraw = _a.onDraw, onPreload = _a.onPreload, width = _a.width, height = _a.height;
|
6
7
|
var refContainer = useRef(null);
|
7
8
|
useEffect(function () {
|
8
9
|
var sketch = function (s) {
|
10
|
+
var camera = new Camera(width, height);
|
9
11
|
s.preload = function () {
|
10
12
|
return onPreload === null || onPreload === void 0 ? void 0 : onPreload();
|
11
13
|
};
|
12
14
|
s.setup = function () {
|
13
15
|
s.createCanvas(width, height).parent(refContainer.current);
|
14
|
-
onSetup(
|
16
|
+
onSetup(camera);
|
15
17
|
};
|
16
18
|
s.draw = function () {
|
17
|
-
var camera = s.simpleCamera;
|
18
19
|
s.scale(camera.scaleX, camera.scaleY);
|
19
20
|
s.background(0);
|
20
21
|
s.imageMode(s.CENTER);
|
@@ -22,7 +23,7 @@ export function Sketch(_a) {
|
|
22
23
|
onDraw();
|
23
24
|
};
|
24
25
|
};
|
25
|
-
new P5(sketch
|
26
|
+
new P5(sketch);
|
26
27
|
// eslint-disable-next-line
|
27
28
|
}, []);
|
28
29
|
return _jsx("div", { style: { backgroundColor: "#000" }, ref: refContainer });
|