create-dreamer-app 1.0.9 → 1.0.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-dreamer-app",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "The scaffolding application for using Disco Dreamer.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -1,6 +1,6 @@
1
1
  # Disco Dreamer reference
2
2
 
3
- A practical guide to building browser games with `discodreamer`. Examples use the public API in version 1.0.6 and TypeScript with JSX.
3
+ A practical guide to building browser games with `discodreamer`. Examples use the public API in version 1.0.8 and TypeScript with JSX.
4
4
 
5
5
  ## How a game runs
6
6
 
@@ -88,9 +88,21 @@ setScore((previous) => previous + 1);
88
88
 
89
89
  Keys identify persistent data across frames. Give each stateful hook and each body instance a stable, descriptive key. For repeated entities, include an entity ID, such as `` `enemy.${id}.health` ``.
90
90
 
91
- Internally, consecutive stateful calls using the same key receive numbered slots. Their order must stay consistent. Reusing a key after a different key starts its numbering again, which can alias an earlier slot. The simplest application pattern is to use a distinct key for each hook and avoid sharing keys with component internals. Keep stateful hook calls in a consistent order each frame.
91
+ Internally, ordinary keys receive numbered slots for consecutive stateful calls using the same key. Their order must stay consistent. Reusing a key after a different ordinary key starts its numbering again, which can alias an earlier slot. The simplest application pattern is to use a distinct key for each hook and avoid sharing keys with component internals. Keep stateful hook calls in a consistent order each frame.
92
92
 
93
- State that is no longer used is removed during frame cleanup. If an entity disappears for a frame and returns later, expect its state to initialize again.
93
+ Prefix a `gameState` key with `$` to use it literally, bypassing numbering. The `$` remains part of the stored key. Every call with the same literal key shares one state slot, regardless of call location or loop iteration:
94
+
95
+ ```ts
96
+ const [, setScore] = gameState("$score", 0);
97
+ setScore((previous) => previous + 1);
98
+
99
+ // Elsewhere in the same frame:
100
+ const [score] = gameState("$score", 0); // Reads the incremented score.
101
+ ```
102
+
103
+ The first call initializes the shared slot; later calls do not reset it. Literal keys do not advance or reset ordinary-key numbering. The `$` rule is implemented in `gameState`, so helpers that call it internally also inherit it. Use ordinary keys for those helpers, especially `gameAnimation`, which needs multiple numbered slots for a single key. Hooks that resolve keys directly, such as `gameEffect`, retain normal numbering.
104
+
105
+ State that is no longer used is removed during frame cleanup. This also applies to `$` keys: sharing a slot does not make it permanent. If an entity disappears for a frame and returns later, expect its state to initialize again.
94
106
 
95
107
  ### `createDynamicId()`
96
108
 
@@ -147,12 +159,13 @@ The sprite's position is its unrotated top-left corner. Images are cached by URL
147
159
 
148
160
  ### `Text`
149
161
 
150
- Draws white, left-aligned, top-aligned text. Uses `sans-serif` unless a font family is supplied.
162
+ Draws left-aligned, top-aligned text in the supplied `color`, or white by default. Uses `sans-serif` unless a font family is supplied.
151
163
 
152
164
  | Prop | Default | Purpose |
153
165
  | --- | --- | --- |
154
166
  | `value` | Required | Text string to draw |
155
167
  | `x`, `y`, `z` | `0` | Position and sibling draw order |
168
+ | `color` | `"white"` | Text fill color as a canvas color string, such as `"red"` or `"#ff00ff"` |
156
169
  | `fontSize` | `25` | Font size in pixels |
157
170
  | `font` | `""` (renders as `sans-serif`) | Font family name, such as a name registered with `addCustomFont` |
158
171
  | `width` | `Infinity` | Maximum canvas text draw width |
@@ -161,7 +174,7 @@ A finite `width` limits the canvas text draw width; it does not create wrapping
161
174
 
162
175
  ```tsx
163
176
  <Text x={16} y={16} value="Score: 10" fontSize={24} />
164
- <Text x={16} y={48} value="Custom font" font="PixelFont" fontSize={32} />
177
+ <Text x={16} y={48} value="Custom font" font="PixelFont" fontSize={32} color="#ff00ff" />
165
178
  ```
166
179
 
167
180
  ## Custom fonts
@@ -22,6 +22,6 @@
22
22
  "vite": "^8.3.2"
23
23
  },
24
24
  "dependencies": {
25
- "discodreamer": "^1.0.6"
25
+ "discodreamer": "^1.0.8"
26
26
  }
27
27
  }