@inglorious/engine 10.0.3 → 11.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 +115 -115
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,115 +1,115 @@
|
|
|
1
|
-
# Inglorious Engine
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/@inglorious/engine)
|
|
4
|
-
[](https://opensource.org/licenses/MIT)
|
|
5
|
-
|
|
6
|
-
The core orchestrator for the [Inglorious Engine](https://github.com/IngloriousCoderz/inglorious-engine). This package provides a complete game loop, state management, and rendering pipeline in a single, cohesive unit. It is designed to be highly configurable and extensible, allowing you to build games with a functional, data-oriented approach.
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
## Core Concepts
|
|
11
|
-
|
|
12
|
-
The `@inglorious/engine` package acts as the central hub that brings together all the engine's components. Its main responsibilities are:
|
|
13
|
-
|
|
14
|
-
1. **Orchestrating the Game Loop**: The `Engine` class manages the game loop, which is responsible for continuously updating the state and rendering the game. The loop can be configured to use different timing mechanisms, such as `animationFrame` or a fixed `fps`.
|
|
15
|
-
|
|
16
|
-
2. **State Management**: It leverages the `@inglorious/store` package to manage the game's state. It provides methods to start, stop, and update the state manager, processing a queue of events on each frame.
|
|
17
|
-
|
|
18
|
-
3. **Integrating the Renderer**: The engine is headless by design, but it can be configured with a renderer to display the game. The engine takes a renderer object in its configuration and integrates its systems and logic into the main game loop.
|
|
19
|
-
|
|
20
|
-
4. **Dev Tools Integration**: The engine automatically connects to a browser's dev tools for debugging and time-travel capabilities if `devMode` is enabled in the game's state.
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
## Installation
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
npm install @inglorious/engine
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
---
|
|
31
|
-
|
|
32
|
-
## API
|
|
33
|
-
|
|
34
|
-
### `new Engine(...gameConfigs)`
|
|
35
|
-
|
|
36
|
-
Creates a new `Engine` instance, given one or more configuration objects.
|
|
37
|
-
|
|
38
|
-
**Parameters:**
|
|
39
|
-
|
|
40
|
-
- `gameConfig` (object): The game-specific configuration. It is an object with the following properties:
|
|
41
|
-
- `loop` (object, optional): Configuration for the game loop.
|
|
42
|
-
- `type` (string, optional): The type of loop to use (`animationFrame` or `fixed`). Defaults to `animationFrame`.
|
|
43
|
-
- `fps` (number, optional): The target frames per second. Only used with the `fixed` loop type. Defaults to `60`.
|
|
44
|
-
- `types` (object, optional): A map of entity types.
|
|
45
|
-
- `entities` (object, optional): A map of initial entities.
|
|
46
|
-
- `systems` (array, optional): An array of system objects, which define behaviors for the whole state.
|
|
47
|
-
|
|
48
|
-
**Returns:**
|
|
49
|
-
|
|
50
|
-
- A new `Engine` instance.
|
|
51
|
-
|
|
52
|
-
### `await engine.init()`
|
|
53
|
-
|
|
54
|
-
An asynchronous function that initializes the resources required for the game to load.
|
|
55
|
-
|
|
56
|
-
### `engine.start()`
|
|
57
|
-
|
|
58
|
-
Starts the game loop, triggering the first `update` and `render` calls.
|
|
59
|
-
|
|
60
|
-
### `engine.stop()`
|
|
61
|
-
|
|
62
|
-
Halts the game loop and cleans up any resources. This method also processes a final `stop` event to ensure a clean shutdown.
|
|
63
|
-
|
|
64
|
-
---
|
|
65
|
-
|
|
66
|
-
## Basic Usage
|
|
67
|
-
|
|
68
|
-
Here is a complete example showing how to set up and run a game using the engine.
|
|
69
|
-
|
|
70
|
-
```html
|
|
71
|
-
<!DOCTYPE html>
|
|
72
|
-
<html lang="en">
|
|
73
|
-
<body>
|
|
74
|
-
<canvas id="canvas" width="800" height="600"></canvas>
|
|
75
|
-
|
|
76
|
-
<script type="text/javascript">
|
|
77
|
-
window.process = { env: "development" }
|
|
78
|
-
</script>
|
|
79
|
-
|
|
80
|
-
<script type="importmap">
|
|
81
|
-
{
|
|
82
|
-
"imports": {
|
|
83
|
-
"mutative": "https://unpkg.com/mutative@latest/dist/mutative.esm.mjs",
|
|
84
|
-
"@inglorious/utils/": "https://unpkg.com/@inglorious%2Futils@latest/src/",
|
|
85
|
-
"@inglorious/store/": "https://unpkg.com/@inglorious%2Fstore@latest/src/",
|
|
86
|
-
"@inglorious/engine/": "https://unpkg.com/@inglorious%2Fengine@latest/src/",
|
|
87
|
-
"@inglorious/renderer-2d/": "https://unpkg.com/@inglorious%2Frenderer-2d@latest/src/",
|
|
88
|
-
"game": "/game.js"
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
</script>
|
|
92
|
-
|
|
93
|
-
<script
|
|
94
|
-
type="module"
|
|
95
|
-
src="https://unpkg.com/@inglorious%2Fengine@latest/src/main.js"
|
|
96
|
-
></script>
|
|
97
|
-
</body>
|
|
98
|
-
</html>
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
---
|
|
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
|
-
|
|
113
|
-
## Contributing
|
|
114
|
-
|
|
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.
|
|
1
|
+
# Inglorious Engine
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@inglorious/engine)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
The core orchestrator for the [Inglorious Engine](https://github.com/IngloriousCoderz/inglorious-engine). This package provides a complete game loop, state management, and rendering pipeline in a single, cohesive unit. It is designed to be highly configurable and extensible, allowing you to build games with a functional, data-oriented approach.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Core Concepts
|
|
11
|
+
|
|
12
|
+
The `@inglorious/engine` package acts as the central hub that brings together all the engine's components. Its main responsibilities are:
|
|
13
|
+
|
|
14
|
+
1. **Orchestrating the Game Loop**: The `Engine` class manages the game loop, which is responsible for continuously updating the state and rendering the game. The loop can be configured to use different timing mechanisms, such as `animationFrame` or a fixed `fps`.
|
|
15
|
+
|
|
16
|
+
2. **State Management**: It leverages the `@inglorious/store` package to manage the game's state. It provides methods to start, stop, and update the state manager, processing a queue of events on each frame.
|
|
17
|
+
|
|
18
|
+
3. **Integrating the Renderer**: The engine is headless by design, but it can be configured with a renderer to display the game. The engine takes a renderer object in its configuration and integrates its systems and logic into the main game loop.
|
|
19
|
+
|
|
20
|
+
4. **Dev Tools Integration**: The engine automatically connects to a browser's dev tools for debugging and time-travel capabilities if `devMode` is enabled in the game's state.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install @inglorious/engine
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## API
|
|
33
|
+
|
|
34
|
+
### `new Engine(...gameConfigs)`
|
|
35
|
+
|
|
36
|
+
Creates a new `Engine` instance, given one or more configuration objects.
|
|
37
|
+
|
|
38
|
+
**Parameters:**
|
|
39
|
+
|
|
40
|
+
- `gameConfig` (object): The game-specific configuration. It is an object with the following properties:
|
|
41
|
+
- `loop` (object, optional): Configuration for the game loop.
|
|
42
|
+
- `type` (string, optional): The type of loop to use (`animationFrame` or `fixed`). Defaults to `animationFrame`.
|
|
43
|
+
- `fps` (number, optional): The target frames per second. Only used with the `fixed` loop type. Defaults to `60`.
|
|
44
|
+
- `types` (object, optional): A map of entity types.
|
|
45
|
+
- `entities` (object, optional): A map of initial entities.
|
|
46
|
+
- `systems` (array, optional): An array of system objects, which define behaviors for the whole state.
|
|
47
|
+
|
|
48
|
+
**Returns:**
|
|
49
|
+
|
|
50
|
+
- A new `Engine` instance.
|
|
51
|
+
|
|
52
|
+
### `await engine.init()`
|
|
53
|
+
|
|
54
|
+
An asynchronous function that initializes the resources required for the game to load.
|
|
55
|
+
|
|
56
|
+
### `engine.start()`
|
|
57
|
+
|
|
58
|
+
Starts the game loop, triggering the first `update` and `render` calls.
|
|
59
|
+
|
|
60
|
+
### `engine.stop()`
|
|
61
|
+
|
|
62
|
+
Halts the game loop and cleans up any resources. This method also processes a final `stop` event to ensure a clean shutdown.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Basic Usage
|
|
67
|
+
|
|
68
|
+
Here is a complete example showing how to set up and run a game using the engine.
|
|
69
|
+
|
|
70
|
+
```html
|
|
71
|
+
<!DOCTYPE html>
|
|
72
|
+
<html lang="en">
|
|
73
|
+
<body>
|
|
74
|
+
<canvas id="canvas" width="800" height="600"></canvas>
|
|
75
|
+
|
|
76
|
+
<script type="text/javascript">
|
|
77
|
+
window.process = { env: "development" }
|
|
78
|
+
</script>
|
|
79
|
+
|
|
80
|
+
<script type="importmap">
|
|
81
|
+
{
|
|
82
|
+
"imports": {
|
|
83
|
+
"mutative": "https://unpkg.com/mutative@latest/dist/mutative.esm.mjs",
|
|
84
|
+
"@inglorious/utils/": "https://unpkg.com/@inglorious%2Futils@latest/src/",
|
|
85
|
+
"@inglorious/store/": "https://unpkg.com/@inglorious%2Fstore@latest/src/",
|
|
86
|
+
"@inglorious/engine/": "https://unpkg.com/@inglorious%2Fengine@latest/src/",
|
|
87
|
+
"@inglorious/renderer-2d/": "https://unpkg.com/@inglorious%2Frenderer-2d@latest/src/",
|
|
88
|
+
"game": "/game.js"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
</script>
|
|
92
|
+
|
|
93
|
+
<script
|
|
94
|
+
type="module"
|
|
95
|
+
src="https://unpkg.com/@inglorious%2Fengine@latest/src/main.js"
|
|
96
|
+
></script>
|
|
97
|
+
</body>
|
|
98
|
+
</html>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
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
|
+
|
|
113
|
+
## Contributing
|
|
114
|
+
|
|
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": "
|
|
3
|
+
"version": "11.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/store": "6.
|
|
33
|
+
"@inglorious/store": "6.2.0",
|
|
34
34
|
"@inglorious/utils": "3.6.2"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@inglorious/
|
|
38
|
-
"@inglorious/
|
|
37
|
+
"@inglorious/store": "6.2.0",
|
|
38
|
+
"@inglorious/utils": "3.6.2"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"prettier": "^3.5.3",
|