cubeforge 0.2.1 → 0.2.2
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 +86 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# cubeforge
|
|
2
|
+
|
|
3
|
+
**Build browser games with React.**
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
<Game width={800} height={500} gravity={980}>
|
|
7
|
+
<World background="#1a1a2e">
|
|
8
|
+
<Camera2D followEntity="player" smoothing={0.85} />
|
|
9
|
+
<Entity id="player" tags={['player']}>
|
|
10
|
+
<Transform x={100} y={300} />
|
|
11
|
+
<Sprite width={32} height={48} color="#4fc3f7" />
|
|
12
|
+
<RigidBody />
|
|
13
|
+
<BoxCollider width={32} height={48} />
|
|
14
|
+
<Script update={playerUpdate} />
|
|
15
|
+
</Entity>
|
|
16
|
+
<Entity tags={['ground']}>
|
|
17
|
+
<Transform x={400} y={480} />
|
|
18
|
+
<Sprite width={800} height={32} color="#37474f" />
|
|
19
|
+
<RigidBody isStatic />
|
|
20
|
+
<BoxCollider width={800} height={32} />
|
|
21
|
+
</Entity>
|
|
22
|
+
</World>
|
|
23
|
+
</Game>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Install
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install cubeforge react react-dom
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## What's included
|
|
33
|
+
|
|
34
|
+
- **ECS** — archetype-based entity-component-system with query caching
|
|
35
|
+
- **Physics** — two-pass AABB, capsule colliders, kinematic bodies, one-way platforms, 60 Hz fixed timestep
|
|
36
|
+
- **Renderer** — Canvas2D sprites, animations, trails, parallax, camera with smoothing and bounds
|
|
37
|
+
- **Input** — keyboard, mouse, gamepad, per-player input maps, input contexts, recording/playback
|
|
38
|
+
- **Audio** — Web Audio API with volume groups, fade, crossfade, ducking (`useSound`)
|
|
39
|
+
- **Gameplay hooks** — `usePlatformerController`, `useTopDownMovement`, `useHealth`, `useSave`, `useGameStateMachine`, `useLevelTransition`, `usePathfinding`, `useAISteering`, and more
|
|
40
|
+
- **DevTools** — time-travel frame scrubber and entity inspector (`<Game devtools>`)
|
|
41
|
+
- **Deterministic mode** — seeded RNG for reproducible simulations (`<Game deterministic seed={n}>`)
|
|
42
|
+
|
|
43
|
+
## Quick example
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
import {
|
|
47
|
+
Game, World, Entity, Transform, Sprite,
|
|
48
|
+
RigidBody, BoxCollider, Script,
|
|
49
|
+
usePlatformerController, useHealth, useSound,
|
|
50
|
+
} from 'cubeforge'
|
|
51
|
+
|
|
52
|
+
function Player() {
|
|
53
|
+
const id = useEntity()
|
|
54
|
+
usePlatformerController(id, { speed: 220, jumpForce: -520, maxJumps: 2 })
|
|
55
|
+
const { hp, takeDamage } = useHealth(5, { onDeath: () => console.log('dead') })
|
|
56
|
+
const jump = useSound('/jump.wav', { group: 'sfx' })
|
|
57
|
+
return null
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export default function MyGame() {
|
|
61
|
+
return (
|
|
62
|
+
<Game width={800} height={500} gravity={980}>
|
|
63
|
+
<World background="#1a1a2e">
|
|
64
|
+
<Camera2D followEntity="player" smoothing={0.87} />
|
|
65
|
+
<Entity id="player" tags={['player']}>
|
|
66
|
+
<Transform x={100} y={300} />
|
|
67
|
+
<Sprite src="/player.png" width={32} height={48} />
|
|
68
|
+
<RigidBody />
|
|
69
|
+
<BoxCollider width={30} height={48} />
|
|
70
|
+
<Player />
|
|
71
|
+
</Entity>
|
|
72
|
+
</World>
|
|
73
|
+
</Game>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Links
|
|
79
|
+
|
|
80
|
+
- [Documentation](https://cubeforge.dev)
|
|
81
|
+
- [Examples](https://github.com/1homsi/cubeforge-examples) — 10 runnable games
|
|
82
|
+
- [GitHub](https://github.com/1homsi/cubeforge)
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
MIT
|