@inglorious/engine 4.0.0 → 5.0.0
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 +8 -0
- package/package.json +5 -5
- package/src/behaviors/fsm.test.js +5 -7
- package/src/core/engine.js +3 -3
- package/src/systems/sprite-animation.js +4 -4
package/README.md
CHANGED
|
@@ -100,6 +100,14 @@ Here is a complete example showing how to set up and run a game using the engine
|
|
|
100
100
|
|
|
101
101
|
---
|
|
102
102
|
|
|
103
|
+
## License
|
|
104
|
+
|
|
105
|
+
MIT © [Matteo Antony Mistretta](https://github.com/IngloriousCoderz)
|
|
106
|
+
|
|
107
|
+
This is free and open-source software. Use it however you want!
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
103
111
|
## Contributing
|
|
104
112
|
|
|
105
113
|
We welcome contributions from the community\! Whether you're fixing a bug, adding a feature, or improving the documentation, your help is appreciated. Please read our [Contributing Guidelines](https://github.com/IngloriousCoderz/inglorious-engine/blob/main/CONTRIBUTING.md) for details on how to get started.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inglorious/engine",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "A JavaScript game engine written with global state, immutability, and pure functions in mind. Have fun(ctional programming) with it!",
|
|
5
5
|
"author": "IceOnFire <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@inglorious/
|
|
34
|
-
"@inglorious/
|
|
33
|
+
"@inglorious/store": "5.2.0",
|
|
34
|
+
"@inglorious/utils": "3.6.1"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@inglorious/
|
|
38
|
-
"@inglorious/
|
|
37
|
+
"@inglorious/store": "5.2.0",
|
|
38
|
+
"@inglorious/utils": "3.6.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"prettier": "^3.5.3",
|
|
@@ -29,13 +29,11 @@ test("it should add a finite state machine", () => {
|
|
|
29
29
|
},
|
|
30
30
|
}
|
|
31
31
|
const afterState = {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
treats: 1,
|
|
38
|
-
},
|
|
32
|
+
entity1: {
|
|
33
|
+
id: "entity1",
|
|
34
|
+
type: "kitty",
|
|
35
|
+
state: "meowing",
|
|
36
|
+
treats: 1,
|
|
39
37
|
},
|
|
40
38
|
}
|
|
41
39
|
|
package/src/core/engine.js
CHANGED
|
@@ -111,10 +111,10 @@ export class Engine {
|
|
|
111
111
|
update(dt) {
|
|
112
112
|
this._api.notify("update", dt)
|
|
113
113
|
const processedEvents = this._store.update()
|
|
114
|
-
const
|
|
114
|
+
const entities = this._store.getState()
|
|
115
115
|
|
|
116
116
|
// Check for devMode changes and connect/disconnect dev tools accordingly.
|
|
117
|
-
const newDevMode =
|
|
117
|
+
const newDevMode = entities.game?.devMode
|
|
118
118
|
if (newDevMode !== this._devMode) {
|
|
119
119
|
if (newDevMode) {
|
|
120
120
|
connectDevTools(this._store, { skippedEvents: coreEvents })
|
|
@@ -133,7 +133,7 @@ export class Engine {
|
|
|
133
133
|
type: eventsToLog.map(({ type }) => type).join("|"),
|
|
134
134
|
payload: eventsToLog,
|
|
135
135
|
}
|
|
136
|
-
sendAction(action,
|
|
136
|
+
sendAction(action, entities)
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
}
|
|
@@ -5,16 +5,16 @@ import { Sprite } from "@inglorious/engine/animation/sprite.js"
|
|
|
5
5
|
* with an active animation state.
|
|
6
6
|
*
|
|
7
7
|
* @param {Object} state - The game state, containing all entities.
|
|
8
|
-
* @param {Object<string, Object>}
|
|
8
|
+
* @param {Object<string, Object>} entities - A map of entity IDs to entity objects.
|
|
9
9
|
* @param {number} dt - The delta time since the last update.
|
|
10
10
|
* @param {Object} api - The game API.
|
|
11
11
|
* @param {Function} api.notify - A function to notify about events.
|
|
12
12
|
*/
|
|
13
13
|
export function spriteAnimationSystem() {
|
|
14
14
|
return {
|
|
15
|
-
update(
|
|
16
|
-
for (const id in
|
|
17
|
-
const entity =
|
|
15
|
+
update(entities, dt, api) {
|
|
16
|
+
for (const id in entities) {
|
|
17
|
+
const entity = entities[id]
|
|
18
18
|
|
|
19
19
|
if (!entity.sprite || !entity.sprite.state) {
|
|
20
20
|
continue
|