@inglorious/engine 4.0.0 → 7.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 CHANGED
@@ -100,6 +100,16 @@ 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 License - Free and open source**
106
+
107
+ Created by [Matteo Antony Mistretta](https://github.com/IngloriousCoderz)
108
+
109
+ You're free to use, modify, and distribute this software. See [LICENSE](./LICENSE) for details.
110
+
111
+ ---
112
+
103
113
  ## Contributing
104
114
 
105
115
  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": "4.0.0",
3
+ "version": "7.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/utils": "3.6.0",
34
- "@inglorious/store": "5.1.0"
33
+ "@inglorious/store": "5.4.0",
34
+ "@inglorious/utils": "3.6.2"
35
35
  },
36
36
  "peerDependencies": {
37
- "@inglorious/utils": "3.6.0",
38
- "@inglorious/store": "5.1.0"
37
+ "@inglorious/utils": "3.6.2",
38
+ "@inglorious/store": "5.4.0"
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
- entities: {
33
- entity1: {
34
- id: "entity1",
35
- type: "kitty",
36
- state: "meowing",
37
- treats: 1,
38
- },
32
+ entity1: {
33
+ id: "entity1",
34
+ type: "kitty",
35
+ state: "meowing",
36
+ treats: 1,
39
37
  },
40
38
  }
41
39
 
@@ -68,7 +68,7 @@ export class Engine {
68
68
  )
69
69
  }
70
70
 
71
- this._store = createStore({ ...this._config, middlewares })
71
+ this._store = createStore({ ...this._config, middlewares, mode: "batched" })
72
72
  this._api = this._store.getApi()
73
73
  this._loop = new Loop[this._config.loop.type]()
74
74
 
@@ -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 state = this._store.getState()
114
+ const entities = this._store.getState()
115
115
 
116
116
  // Check for devMode changes and connect/disconnect dev tools accordingly.
117
- const newDevMode = state.entities.game?.devMode
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, state)
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>} state.entities - A map of entity IDs to entity objects.
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(state, dt, api) {
16
- for (const id in state.entities) {
17
- const entity = state.entities[id]
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