react-simple-game-engine 0.1.57 → 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.
- package/lib/index.js +2 -1
- package/lib/utilities.js +0 -1
- package/package.json +6 -2
- package/lib/classes/animations/animation.d.ts +0 -14
- package/lib/classes/animations/animation.d.ts.map +0 -1
- package/lib/classes/animations/animation.js +0 -35
- package/lib/classes/animations/avatar.animation.d.ts +0 -16
- package/lib/classes/animations/avatar.animation.d.ts.map +0 -1
- package/lib/classes/animations/avatar.animation.js +0 -45
- package/lib/classes/animations/color.animation.d.ts +0 -9
- package/lib/classes/animations/color.animation.d.ts.map +0 -1
- package/lib/classes/animations/color.animation.js +0 -33
- package/lib/classes/camera.d.ts +0 -14
- package/lib/classes/camera.d.ts.map +0 -1
- package/lib/classes/camera.js +0 -34
- package/lib/classes/entities/circle.entity.d.ts +0 -15
- package/lib/classes/entities/circle.entity.d.ts.map +0 -1
- package/lib/classes/entities/circle.entity.js +0 -55
- package/lib/classes/entities/entity-sult.d.ts +0 -34
- package/lib/classes/entities/entity-sult.d.ts.map +0 -1
- package/lib/classes/entities/entity-sult.js +0 -108
- package/lib/classes/entities/entity.d.ts +0 -55
- package/lib/classes/entities/entity.d.ts.map +0 -1
- package/lib/classes/entities/entity.js +0 -180
- package/lib/classes/entities/rect.entity.d.ts +0 -17
- package/lib/classes/entities/rect.entity.d.ts.map +0 -1
- package/lib/classes/entities/rect.entity.js +0 -56
- package/lib/classes/logic-component.d.ts +0 -16
- package/lib/classes/logic-component.d.ts.map +0 -1
- package/lib/classes/logic-component.js +0 -77
- package/lib/classes/p5.d.ts +0 -11
- package/lib/classes/p5.d.ts.map +0 -1
- package/lib/classes/p5.js +0 -58
- package/lib/classes/particle-system.d.ts +0 -30
- package/lib/classes/particle-system.d.ts.map +0 -1
- package/lib/classes/particle-system.js +0 -98
- package/lib/classes/particle.d.ts +0 -35
- package/lib/classes/particle.d.ts.map +0 -1
- package/lib/classes/particle.js +0 -117
- package/lib/classes/prefab.d.ts +0 -7
- package/lib/classes/prefab.d.ts.map +0 -1
- package/lib/classes/prefab.js +0 -24
- package/lib/classes/saver.d.ts +0 -11
- package/lib/classes/saver.d.ts.map +0 -1
- package/lib/classes/saver.js +0 -33
- package/lib/classes/scene-management.d.ts +0 -22
- package/lib/classes/scene-management.d.ts.map +0 -1
- package/lib/classes/scene-management.js +0 -58
- package/lib/classes/scene.d.ts +0 -67
- package/lib/classes/scene.d.ts.map +0 -1
- package/lib/classes/scene.js +0 -338
- package/lib/classes/sound-watcher.d.ts +0 -16
- package/lib/classes/sound-watcher.d.ts.map +0 -1
- package/lib/classes/sound-watcher.js +0 -33
- package/lib/classes/sound.d.ts +0 -14
- package/lib/classes/sound.d.ts.map +0 -1
- package/lib/classes/sound.js +0 -119
- package/lib/classes/sprites/avatar.sprite.d.ts +0 -20
- package/lib/classes/sprites/avatar.sprite.d.ts.map +0 -1
- package/lib/classes/sprites/avatar.sprite.js +0 -89
- package/lib/classes/sprites/color.sprite.d.ts +0 -7
- package/lib/classes/sprites/color.sprite.d.ts.map +0 -1
- package/lib/classes/sprites/color.sprite.js +0 -40
- package/lib/classes/sprites/sprite.d.ts +0 -26
- package/lib/classes/sprites/sprite.d.ts.map +0 -1
- package/lib/classes/sprites/sprite.js +0 -70
- package/lib/classes/watcher.d.ts +0 -11
- package/lib/classes/watcher.d.ts.map +0 -1
- package/lib/classes/watcher.js +0 -44
- package/lib/classes/world-management.d.ts +0 -28
- package/lib/classes/world-management.d.ts.map +0 -1
- package/lib/classes/world-management.js +0 -160
- package/lib/decorators/scene-sound.decor.d.ts +0 -6
- package/lib/decorators/scene-sound.decor.d.ts.map +0 -1
- package/lib/decorators/scene-sound.decor.js +0 -17
- package/lib/decorators/scene-tag.decor.d.ts +0 -6
- package/lib/decorators/scene-tag.decor.d.ts.map +0 -1
- package/lib/decorators/scene-tag.decor.js +0 -5
- package/lib/decorators/scene-ui.decor.d.ts +0 -7
- package/lib/decorators/scene-ui.decor.d.ts.map +0 -1
- package/lib/decorators/scene-ui.decor.js +0 -5
- package/lib/export-enums.d.ts +0 -5
- package/lib/export-enums.d.ts.map +0 -1
- package/lib/export-interfaces.d.ts +0 -4
- package/lib/export-interfaces.d.ts.map +0 -1
- package/lib/export-types.d.ts +0 -49
- package/lib/export-types.d.ts.map +0 -1
- package/lib/index.d.ts +0 -24
- package/lib/index.d.ts.map +0 -1
- package/lib/ui-components/SceneRunner.d.ts +0 -14
- package/lib/ui-components/SceneRunner.d.ts.map +0 -1
- package/lib/ui-components/SceneRunner.js +0 -43
- package/lib/ui-components/ScenesProcess.d.ts +0 -9
- package/lib/ui-components/ScenesProcess.d.ts.map +0 -1
- package/lib/ui-components/ScenesProcess.js +0 -46
- package/lib/ui-components/Sketch.d.ts +0 -12
- package/lib/ui-components/Sketch.d.ts.map +0 -1
- package/lib/ui-components/Sketch.js +0 -33
- package/lib/utilities.d.ts +0 -4
- package/lib/utilities.d.ts.map +0 -1
- package/lib/utils.d.ts +0 -8
- package/lib/utils.d.ts.map +0 -1
- package/lib/utils.js +0 -97
@@ -1,46 +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 { jsx as _jsx } from "react/jsx-runtime";
|
24
|
-
import { useEffect, useMemo, useState } from "react";
|
25
|
-
import { SceneManagement } from "../classes/scene-management";
|
26
|
-
import { SceneRunner } from "./SceneRunner";
|
27
|
-
export function ScenesProcess(_a) {
|
28
|
-
var list = _a.list, props = __rest(_a, ["list"]);
|
29
|
-
var sceneManagement = useMemo(function () {
|
30
|
-
return new SceneManagement(list);
|
31
|
-
}, [list]);
|
32
|
-
var _b = useState(sceneManagement.currentScene), currentScene = _b[0], setCurrentScene = _b[1];
|
33
|
-
var _c = useState(currentScene.loadedAssets), setLoadedAssets = _c[1];
|
34
|
-
useEffect(function () {
|
35
|
-
sceneManagement.onChangeScene(function (scene) {
|
36
|
-
setCurrentScene(scene);
|
37
|
-
setLoadedAssets(scene.loadedAssets);
|
38
|
-
});
|
39
|
-
}, [sceneManagement]);
|
40
|
-
useEffect(function () {
|
41
|
-
currentScene.onLoadAssetNotify(function (isLoaded) {
|
42
|
-
setLoadedAssets(isLoaded);
|
43
|
-
});
|
44
|
-
}, [currentScene]);
|
45
|
-
return (_jsx(SceneRunner, __assign({ current: currentScene }, props), currentScene.sessionId));
|
46
|
-
}
|
@@ -1,12 +0,0 @@
|
|
1
|
-
/// <reference types="react" />
|
2
|
-
import { Camera } from "../classes/camera";
|
3
|
-
declare type SketchProps = {
|
4
|
-
onSetup: (camera: Camera) => void;
|
5
|
-
onDraw: () => void;
|
6
|
-
onPreload?: () => void;
|
7
|
-
width: number;
|
8
|
-
height: number;
|
9
|
-
};
|
10
|
-
export declare function Sketch({ onSetup, onDraw, onPreload, width, height, }: SketchProps): JSX.Element;
|
11
|
-
export {};
|
12
|
-
//# sourceMappingURL=Sketch.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"Sketch.d.ts","sourceRoot":"","sources":["../../src/ui-components/Sketch.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,aAAK,WAAW,GAAG;IACjB,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAgB,MAAM,CAAC,EACrB,OAAO,EACP,MAAM,EACN,SAAS,EACT,KAAK,EACL,MAAM,GACP,EAAE,WAAW,eAgCb"}
|
@@ -1,33 +0,0 @@
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
-
import { useEffect, useRef } from "react";
|
3
|
-
import { Camera } from "../classes/camera";
|
4
|
-
import { P5 } from "../classes/p5";
|
5
|
-
export function Sketch(_a) {
|
6
|
-
var onSetup = _a.onSetup, onDraw = _a.onDraw, onPreload = _a.onPreload, width = _a.width, height = _a.height;
|
7
|
-
var refContainer = useRef(null);
|
8
|
-
useEffect(function () {
|
9
|
-
var sketch = function (s) {
|
10
|
-
var camera = new Camera(width, height);
|
11
|
-
s.preload = function () {
|
12
|
-
return onPreload === null || onPreload === void 0 ? void 0 : onPreload();
|
13
|
-
};
|
14
|
-
s.setup = function () {
|
15
|
-
s.createCanvas(width, height).parent(refContainer.current);
|
16
|
-
onSetup(camera);
|
17
|
-
};
|
18
|
-
s.draw = function () {
|
19
|
-
s.scale(camera.scaleX, camera.scaleY);
|
20
|
-
s.background(0);
|
21
|
-
s.imageMode(s.CENTER);
|
22
|
-
s.rectMode(s.CENTER);
|
23
|
-
onDraw();
|
24
|
-
};
|
25
|
-
};
|
26
|
-
var p5 = new P5(sketch);
|
27
|
-
return function () {
|
28
|
-
p5.remove();
|
29
|
-
};
|
30
|
-
// eslint-disable-next-line
|
31
|
-
}, []);
|
32
|
-
return _jsx("div", { style: { backgroundColor: "#000" }, ref: refContainer });
|
33
|
-
}
|
package/lib/utilities.d.ts
DELETED
package/lib/utilities.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC"}
|
package/lib/utils.d.ts
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
import { Sound } from "./classes/sound";
|
2
|
-
import { SoundType } from "./export-enums";
|
3
|
-
import { Avatar } from "./export-types";
|
4
|
-
export declare function createAssetImage(src: string): Promise<Avatar>;
|
5
|
-
export declare function createAssetSound(src: string, type?: SoundType): Promise<Sound>;
|
6
|
-
export declare function tick(delay?: number): Promise<unknown>;
|
7
|
-
export declare function copyProperties(source: Record<string, any>, target: Record<string, any>): void;
|
8
|
-
//# sourceMappingURL=utils.d.ts.map
|
package/lib/utils.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAiBxC,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAInE;AAED,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,SAAS,GACf,OAAO,CAAC,KAAK,CAAC,CAWhB;AAED,wBAAsB,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,oBAQxC;AAED,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAO5B"}
|
package/lib/utils.js
DELETED
@@ -1,97 +0,0 @@
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
-
});
|
9
|
-
};
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
14
|
-
function step(op) {
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
16
|
-
while (_) try {
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
19
|
-
switch (op[0]) {
|
20
|
-
case 0: case 1: t = op; break;
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
24
|
-
default:
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
29
|
-
if (t[2]) _.ops.pop();
|
30
|
-
_.trys.pop(); continue;
|
31
|
-
}
|
32
|
-
op = body.call(thisArg, _);
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
35
|
-
}
|
36
|
-
};
|
37
|
-
import OutofScopeP5 from "p5";
|
38
|
-
import { Sound } from "./classes/sound";
|
39
|
-
var outofScopeP5;
|
40
|
-
document.addEventListener("DOMContentLoaded", function () {
|
41
|
-
var noop = document.createElement("div");
|
42
|
-
noop.style.position = "absolute";
|
43
|
-
noop.style.zIndex = "-1";
|
44
|
-
noop.style.top = "-100%";
|
45
|
-
noop.style.left = "-100%";
|
46
|
-
document.body.appendChild(noop);
|
47
|
-
setTimeout(function () {
|
48
|
-
outofScopeP5 = new OutofScopeP5(function (skt) { }, noop);
|
49
|
-
}, 0);
|
50
|
-
});
|
51
|
-
export function createAssetImage(src) {
|
52
|
-
return __awaiter(this, void 0, void 0, function () {
|
53
|
-
return __generator(this, function (_a) {
|
54
|
-
return [2 /*return*/, new Promise(function (res, rej) {
|
55
|
-
outofScopeP5.loadImage(src, res, rej);
|
56
|
-
})];
|
57
|
-
});
|
58
|
-
});
|
59
|
-
}
|
60
|
-
export function createAssetSound(src, type) {
|
61
|
-
return __awaiter(this, void 0, void 0, function () {
|
62
|
-
var media;
|
63
|
-
return __generator(this, function (_a) {
|
64
|
-
media = new Sound(type);
|
65
|
-
return [2 /*return*/, new Promise(function (res, rej) {
|
66
|
-
media.native.onloadedmetadata = function () {
|
67
|
-
res(media);
|
68
|
-
};
|
69
|
-
media.native.onerror = function (error) {
|
70
|
-
rej(error);
|
71
|
-
};
|
72
|
-
media.native.src = src;
|
73
|
-
})];
|
74
|
-
});
|
75
|
-
});
|
76
|
-
}
|
77
|
-
export function tick(delay) {
|
78
|
-
return __awaiter(this, void 0, void 0, function () {
|
79
|
-
return __generator(this, function (_a) {
|
80
|
-
return [2 /*return*/, new Promise(function (res) {
|
81
|
-
if (delay != null) {
|
82
|
-
setTimeout(res, delay);
|
83
|
-
}
|
84
|
-
else {
|
85
|
-
// wait forever
|
86
|
-
}
|
87
|
-
})];
|
88
|
-
});
|
89
|
-
});
|
90
|
-
}
|
91
|
-
export function copyProperties(source, target) {
|
92
|
-
for (var key in target) {
|
93
|
-
if (target[key] !== undefined) {
|
94
|
-
source[key] = target[key];
|
95
|
-
}
|
96
|
-
}
|
97
|
-
}
|