@antha/engine 0.1.0 → 0.1.1
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/README.md +30 -3
- package/dist/antha-engine.d.ts +4 -4
- package/dist/antha-engine.js +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,11 +1,38 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @antha/engine
|
|
2
2
|
|
|
3
|
-
The Antha game engine (for the web), where everything is a mod!
|
|
3
|
+
The Antha game engine (for the web), where everything is a mod! This engine core package only includes a lightweight framework for flexibly defining, inserting, and running the engine mods.
|
|
4
4
|
|
|
5
5
|
- Demo: https://electrovir.github.io/antha/demo
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
|
-
npm i antha
|
|
10
|
+
npm i @antha/engine
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
<!-- example-link: src/readme-examples/creating-engine.example.ts -->
|
|
16
|
+
|
|
17
|
+
```TypeScript
|
|
18
|
+
import {AnthaEngine, defineAnthaMod} from '@antha/engine';
|
|
19
|
+
|
|
20
|
+
const engine = new AnthaEngine<{
|
|
21
|
+
count: number;
|
|
22
|
+
}>({
|
|
23
|
+
mods: [
|
|
24
|
+
defineAnthaMod<{
|
|
25
|
+
count: number;
|
|
26
|
+
}>({
|
|
27
|
+
modName: 'counter',
|
|
28
|
+
execute({state}) {
|
|
29
|
+
state.count = (state.count ?? 0) + 1;
|
|
30
|
+
|
|
31
|
+
return `Count: ${state.count}`;
|
|
32
|
+
},
|
|
33
|
+
}),
|
|
34
|
+
],
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
engine.startLoop();
|
|
11
38
|
```
|
package/dist/antha-engine.d.ts
CHANGED
|
@@ -36,10 +36,10 @@ export type ModCleanupParams<State extends AnyObject> = {
|
|
|
36
36
|
modInstanceId: ModInstanceId;
|
|
37
37
|
} & ModOptions;
|
|
38
38
|
/**
|
|
39
|
-
* Return this from a mod's
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
39
|
+
* Return this from a mod's `execute` callback to instruct {@link AnthaEngine} that the mod's current
|
|
40
|
+
* execution should not count toward the mod's frequency schedule. This is useful when a mod needs a
|
|
41
|
+
* dependency (such as a canvas or external resource) that isn't ready yet so that the engine will
|
|
42
|
+
* keep retrying on subsequent ticks, even if the mod has a low execution frequency.
|
|
43
43
|
*
|
|
44
44
|
* @category Mod
|
|
45
45
|
*/
|
package/dist/antha-engine.js
CHANGED
|
@@ -6,10 +6,10 @@ import { Observable } from 'observavir';
|
|
|
6
6
|
import { AnthaUi } from './antha-ui.element.js';
|
|
7
7
|
import { browserAnthaLogger } from './logger/browser-antha-logger.js';
|
|
8
8
|
/**
|
|
9
|
-
* Return this from a mod's
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* Return this from a mod's `execute` callback to instruct {@link AnthaEngine} that the mod's current
|
|
10
|
+
* execution should not count toward the mod's frequency schedule. This is useful when a mod needs a
|
|
11
|
+
* dependency (such as a canvas or external resource) that isn't ready yet so that the engine will
|
|
12
|
+
* keep retrying on subsequent ticks, even if the mod has a low execution frequency.
|
|
13
13
|
*
|
|
14
14
|
* @category Mod
|
|
15
15
|
*/
|