castle-web-cli 0.4.193 → 0.4.195
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/dist/agent-prompts.d.ts +1 -0
- package/dist/agent-prompts.js +14 -5
- package/dist/agent.js +101 -4
- package/dist/api.d.ts +1 -0
- package/dist/api.js +5 -0
- package/dist/bundle.js +2 -1
- package/dist/castleJson.d.ts +1 -2
- package/dist/castleJson.js +0 -39
- package/dist/check.js +14 -6
- package/dist/devSessionFrameBudget.d.ts +14 -0
- package/dist/devSessionFrameBudget.js +64 -0
- package/dist/devSessionServer.d.ts +6 -0
- package/dist/devSessionServer.js +38 -1
- package/dist/editorConfig.d.ts +1 -1
- package/dist/editorConfig.js +12 -4
- package/dist/filesChanged.js +7 -3
- package/dist/ide.js +28 -59
- package/dist/importUpdateHook.d.ts +31 -0
- package/dist/importUpdateHook.js +135 -0
- package/dist/importUpdateHookRunner.d.ts +2 -0
- package/dist/importUpdateHookRunner.js +24 -0
- package/dist/imports.js +58 -10
- package/dist/index.js +58 -7
- package/dist/init.d.ts +1 -0
- package/dist/init.js +15 -9
- package/dist/multiplayerDoc.d.ts +1 -0
- package/dist/multiplayerDoc.js +228 -0
- package/dist/native/loop.js +29 -9
- package/dist/platformDoc.d.ts +1 -0
- package/dist/platformDoc.js +25 -6
- package/dist/remix.js +4 -1
- package/dist/scriptErrors.d.ts +23 -0
- package/dist/scriptErrors.js +147 -0
- package/dist/serve.js +366 -36
- package/dist/serverBundle.js +1 -1
- package/dist/shell/assets/index-kMH1qj6D.js +449 -0
- package/dist/shell/index.html +1 -1
- package/dist/versions.d.ts +14 -0
- package/dist/versions.js +21 -0
- package/dist/viteClientStub.d.ts +18 -0
- package/dist/viteClientStub.js +193 -0
- package/dist/vitePlugins.d.ts +1 -0
- package/dist/vitePlugins.js +18 -0
- package/kits/base/CLAUDE.md +3 -3
- package/kits/base/castle.json +1 -3
- package/kits/base/sdk/README.md +17 -0
- package/kits/multiplayer-2d/CLAUDE.md +9 -2
- package/kits/multiplayer-2d/blueprints/crate.scene +32 -4
- package/kits/multiplayer-2d/blueprints/other-player.scene +31 -4
- package/kits/multiplayer-2d/blueprints/player.scene +38 -6
- package/kits/multiplayer-2d/blueprints/wall.scene +25 -3
- package/kits/multiplayer-2d/castle.json +3 -12
- package/kits/multiplayer-2d/test/two-client-test.mjs +4 -4
- package/kits/multiplayer-3d/CLAUDE.md +5 -2
- package/kits/multiplayer-3d/castle.json +3 -11
- package/kits/multiplayer-3d/scenes/main.scene +128 -0
- package/kits/physics-2d/CLAUDE.md +16 -11
- package/kits/physics-2d/behaviors/Camera.jsx +5 -6
- package/kits/physics-2d/behaviors/Goal.jsx +5 -2
- package/kits/physics-2d/behaviors/Joints.jsx +4 -3
- package/kits/physics-2d/behaviors/Layout.jsx +120 -3
- package/kits/physics-2d/behaviors/Sprite.jsx +9 -9
- package/kits/physics-2d/behaviors/Style.jsx +22 -15
- package/kits/physics-2d/behaviors/Text.jsx +7 -6
- package/kits/physics-2d/blueprints/ball.scene +27 -5
- package/kits/physics-2d/blueprints/block.scene +16 -3
- package/kits/physics-2d/blueprints/cauldron.scene +3 -1
- package/kits/physics-2d/blueprints/crate.scene +23 -4
- package/kits/physics-2d/blueprints/goal.scene +12 -2
- package/kits/physics-2d/blueprints/text.scene +13 -3
- package/kits/physics-2d/castle.json +2 -11
- package/kits/physics-2d/editors/SceneEditor.jsx +68 -5
- package/kits/physics-2d/editors/SelectionOverlay.jsx +27 -20
- package/kits/physics-2d/editors/behaviorRegistry.js +8 -2
- package/kits/physics-2d/engine/ErrorOverlay.jsx +69 -0
- package/kits/physics-2d/engine/ScenePlayer.jsx +2 -67
- package/kits/physics-2d/engine/blueprint.js +111 -54
- package/kits/physics-2d/engine/blueprintCore.js +59 -0
- package/kits/physics-2d/engine/collider.js +28 -17
- package/kits/physics-2d/engine/layout.js +61 -0
- package/kits/physics-2d/engine/layoutOriginMigration.js +223 -0
- package/kits/physics-2d/engine/liveReload.js +5 -4
- package/kits/physics-2d/engine/physics/PhysicsSystem.js +11 -7
- package/kits/physics-2d/engine/physics/controls.js +4 -8
- package/kits/physics-2d/engine/physics/matterBridge.js +13 -8
- package/kits/physics-2d/engine/scene.js +38 -34
- package/kits/physics-2d/engine/spriteGeometry.js +17 -9
- package/kits/physics-2d/engine/tap.js +4 -3
- package/kits/physics-2d/scenes/main.scene +59 -6
- package/kits/physics-2d/scenes/sandbox.scene +69 -7
- package/kits/physics-2d/scripts/onUpdate.mjs +199 -0
- package/kits/physics-3d/castle.json +0 -11
- package/kits/real-time/castle.json +2 -8
- package/kits/real-time/code/server/persist.js +14 -0
- package/kits/turn-based/CLAUDE.md +18 -10
- package/kits/turn-based/blueprints/board.scene +3 -1
- package/kits/turn-based/blueprints/square.scene +3 -1
- package/kits/turn-based/castle.json +3 -14
- package/kits/turn-based/code/behaviors/Board.jsx +33 -21
- package/package.json +1 -1
- package/dist/shell/assets/index-ColHKJYj.js +0 -449
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"title": "multiplayer-3d",
|
|
3
3
|
"editor": {
|
|
4
|
-
"hiddenPaths": [],
|
|
5
|
-
"visiblePaths": [
|
|
6
|
-
"code/**",
|
|
7
|
-
"theme.style",
|
|
8
|
-
"fonts.generated.js",
|
|
9
|
-
"scenes/**",
|
|
10
|
-
"blueprints/**"
|
|
11
|
-
],
|
|
12
4
|
"defaultPlayFile": "scenes/main.scene"
|
|
13
5
|
},
|
|
14
6
|
"imports": {
|
|
15
7
|
"castle.real-time": {
|
|
16
8
|
"deckId": "xFVr-afOLuUQ",
|
|
17
|
-
"version": "2026-09-
|
|
9
|
+
"version": "2026-09-16T21:18:06.448Z"
|
|
18
10
|
},
|
|
19
11
|
"castle.physics-3d": {
|
|
20
12
|
"deckId": "JH0SclbPVP0y",
|
|
@@ -22,7 +14,7 @@
|
|
|
22
14
|
},
|
|
23
15
|
"castle.physics-2d": {
|
|
24
16
|
"deckId": "ckRZGFW4iPrx",
|
|
25
|
-
"version": "2026-09-
|
|
17
|
+
"version": "2026-09-16T21:17:53.144Z",
|
|
26
18
|
"via": "castle.physics-3d"
|
|
27
19
|
},
|
|
28
20
|
"castle.base": {
|
|
@@ -33,7 +25,7 @@
|
|
|
33
25
|
"autoUpdateWhenImported": true,
|
|
34
26
|
"deckId": "ZwA_P_-VO-Qh",
|
|
35
27
|
"cardId": "bvRmCzyUpt_a",
|
|
36
|
-
"publishedVersion": "2026-09-
|
|
28
|
+
"publishedVersion": "2026-09-16T21:20:24.084Z",
|
|
37
29
|
"main": "main.jsx",
|
|
38
30
|
"server": {
|
|
39
31
|
"main": "code/server/index.js",
|
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
"x": -2.2,
|
|
14
14
|
"z": 2,
|
|
15
15
|
"y": 1
|
|
16
|
+
},
|
|
17
|
+
"Layout": {
|
|
18
|
+
"originX": 0,
|
|
19
|
+
"originY": 0
|
|
16
20
|
}
|
|
17
21
|
}
|
|
18
22
|
},
|
|
@@ -27,6 +31,10 @@
|
|
|
27
31
|
"Shape": {
|
|
28
32
|
"width": 1.6,
|
|
29
33
|
"depth": 1.6
|
|
34
|
+
},
|
|
35
|
+
"Layout": {
|
|
36
|
+
"originX": 0,
|
|
37
|
+
"originY": 0
|
|
30
38
|
}
|
|
31
39
|
}
|
|
32
40
|
},
|
|
@@ -38,6 +46,10 @@
|
|
|
38
46
|
"x": 4,
|
|
39
47
|
"y": 1.2,
|
|
40
48
|
"z": 3
|
|
49
|
+
},
|
|
50
|
+
"Layout": {
|
|
51
|
+
"originX": 0,
|
|
52
|
+
"originY": 0
|
|
41
53
|
}
|
|
42
54
|
}
|
|
43
55
|
},
|
|
@@ -48,6 +60,10 @@
|
|
|
48
60
|
"Transform": {
|
|
49
61
|
"x": -3,
|
|
50
62
|
"z": 3
|
|
63
|
+
},
|
|
64
|
+
"Layout": {
|
|
65
|
+
"originX": 0,
|
|
66
|
+
"originY": 0
|
|
51
67
|
}
|
|
52
68
|
}
|
|
53
69
|
},
|
|
@@ -58,6 +74,10 @@
|
|
|
58
74
|
"Transform": {
|
|
59
75
|
"x": -3.9,
|
|
60
76
|
"z": 4.1
|
|
77
|
+
},
|
|
78
|
+
"Layout": {
|
|
79
|
+
"originX": 0,
|
|
80
|
+
"originY": 0
|
|
61
81
|
}
|
|
62
82
|
}
|
|
63
83
|
},
|
|
@@ -69,6 +89,10 @@
|
|
|
69
89
|
"x": -3.2,
|
|
70
90
|
"y": 1.6,
|
|
71
91
|
"z": 3.6
|
|
92
|
+
},
|
|
93
|
+
"Layout": {
|
|
94
|
+
"originX": 0,
|
|
95
|
+
"originY": 0
|
|
72
96
|
}
|
|
73
97
|
}
|
|
74
98
|
},
|
|
@@ -79,6 +103,10 @@
|
|
|
79
103
|
"Transform": {
|
|
80
104
|
"x": 6.8,
|
|
81
105
|
"z": 6.6
|
|
106
|
+
},
|
|
107
|
+
"Layout": {
|
|
108
|
+
"originX": 0,
|
|
109
|
+
"originY": 0
|
|
82
110
|
}
|
|
83
111
|
}
|
|
84
112
|
},
|
|
@@ -90,6 +118,10 @@
|
|
|
90
118
|
"x": 6.1,
|
|
91
119
|
"y": 1.6,
|
|
92
120
|
"z": 7.2
|
|
121
|
+
},
|
|
122
|
+
"Layout": {
|
|
123
|
+
"originX": 0,
|
|
124
|
+
"originY": 0
|
|
93
125
|
}
|
|
94
126
|
}
|
|
95
127
|
},
|
|
@@ -100,6 +132,10 @@
|
|
|
100
132
|
"Transform": {
|
|
101
133
|
"x": 2,
|
|
102
134
|
"z": 6
|
|
135
|
+
},
|
|
136
|
+
"Layout": {
|
|
137
|
+
"originX": 0,
|
|
138
|
+
"originY": 0
|
|
103
139
|
}
|
|
104
140
|
}
|
|
105
141
|
},
|
|
@@ -110,6 +146,10 @@
|
|
|
110
146
|
"Transform": {
|
|
111
147
|
"x": -5,
|
|
112
148
|
"z": 0
|
|
149
|
+
},
|
|
150
|
+
"Layout": {
|
|
151
|
+
"originX": 0,
|
|
152
|
+
"originY": 0
|
|
113
153
|
}
|
|
114
154
|
}
|
|
115
155
|
},
|
|
@@ -120,6 +160,10 @@
|
|
|
120
160
|
"Transform": {
|
|
121
161
|
"x": 6,
|
|
122
162
|
"z": -2
|
|
163
|
+
},
|
|
164
|
+
"Layout": {
|
|
165
|
+
"originX": 0,
|
|
166
|
+
"originY": 0
|
|
123
167
|
}
|
|
124
168
|
}
|
|
125
169
|
},
|
|
@@ -130,6 +174,10 @@
|
|
|
130
174
|
"Transform": {
|
|
131
175
|
"x": 0,
|
|
132
176
|
"z": -8
|
|
177
|
+
},
|
|
178
|
+
"Layout": {
|
|
179
|
+
"originX": 0,
|
|
180
|
+
"originY": 0
|
|
133
181
|
}
|
|
134
182
|
}
|
|
135
183
|
},
|
|
@@ -141,6 +189,10 @@
|
|
|
141
189
|
"x": 8,
|
|
142
190
|
"y": 2.9,
|
|
143
191
|
"z": 1.2
|
|
192
|
+
},
|
|
193
|
+
"Layout": {
|
|
194
|
+
"originX": 0,
|
|
195
|
+
"originY": 0
|
|
144
196
|
}
|
|
145
197
|
}
|
|
146
198
|
},
|
|
@@ -151,6 +203,10 @@
|
|
|
151
203
|
"Transform": {
|
|
152
204
|
"x": -7,
|
|
153
205
|
"z": -6
|
|
206
|
+
},
|
|
207
|
+
"Layout": {
|
|
208
|
+
"originX": 0,
|
|
209
|
+
"originY": 0
|
|
154
210
|
}
|
|
155
211
|
}
|
|
156
212
|
},
|
|
@@ -161,6 +217,10 @@
|
|
|
161
217
|
"Transform": {
|
|
162
218
|
"x": 9,
|
|
163
219
|
"z": 7
|
|
220
|
+
},
|
|
221
|
+
"Layout": {
|
|
222
|
+
"originX": 0,
|
|
223
|
+
"originY": 0
|
|
164
224
|
}
|
|
165
225
|
}
|
|
166
226
|
},
|
|
@@ -171,6 +231,10 @@
|
|
|
171
231
|
"Transform": {
|
|
172
232
|
"x": 8,
|
|
173
233
|
"z": 4
|
|
234
|
+
},
|
|
235
|
+
"Layout": {
|
|
236
|
+
"originX": 0,
|
|
237
|
+
"originY": 0
|
|
174
238
|
}
|
|
175
239
|
}
|
|
176
240
|
},
|
|
@@ -182,6 +246,10 @@
|
|
|
182
246
|
"x": 9.4,
|
|
183
247
|
"y": 1.1,
|
|
184
248
|
"z": 2.6
|
|
249
|
+
},
|
|
250
|
+
"Layout": {
|
|
251
|
+
"originX": 0,
|
|
252
|
+
"originY": 0
|
|
185
253
|
}
|
|
186
254
|
}
|
|
187
255
|
},
|
|
@@ -193,6 +261,10 @@
|
|
|
193
261
|
"x": 8,
|
|
194
262
|
"y": 2,
|
|
195
263
|
"z": 1.2
|
|
264
|
+
},
|
|
265
|
+
"Layout": {
|
|
266
|
+
"originX": 0,
|
|
267
|
+
"originY": 0
|
|
196
268
|
}
|
|
197
269
|
}
|
|
198
270
|
},
|
|
@@ -210,6 +282,10 @@
|
|
|
210
282
|
4,
|
|
211
283
|
1
|
|
212
284
|
]
|
|
285
|
+
},
|
|
286
|
+
"Layout": {
|
|
287
|
+
"originX": 0,
|
|
288
|
+
"originY": 0
|
|
213
289
|
}
|
|
214
290
|
}
|
|
215
291
|
},
|
|
@@ -228,6 +304,10 @@
|
|
|
228
304
|
4,
|
|
229
305
|
1
|
|
230
306
|
]
|
|
307
|
+
},
|
|
308
|
+
"Layout": {
|
|
309
|
+
"originX": 0,
|
|
310
|
+
"originY": 0
|
|
231
311
|
}
|
|
232
312
|
}
|
|
233
313
|
},
|
|
@@ -246,6 +326,10 @@
|
|
|
246
326
|
4,
|
|
247
327
|
1
|
|
248
328
|
]
|
|
329
|
+
},
|
|
330
|
+
"Layout": {
|
|
331
|
+
"originX": 0,
|
|
332
|
+
"originY": 0
|
|
249
333
|
}
|
|
250
334
|
}
|
|
251
335
|
},
|
|
@@ -263,6 +347,10 @@
|
|
|
263
347
|
1.5,
|
|
264
348
|
1
|
|
265
349
|
]
|
|
350
|
+
},
|
|
351
|
+
"Layout": {
|
|
352
|
+
"originX": 0,
|
|
353
|
+
"originY": 0
|
|
266
354
|
}
|
|
267
355
|
}
|
|
268
356
|
},
|
|
@@ -280,6 +368,10 @@
|
|
|
280
368
|
1.5,
|
|
281
369
|
1
|
|
282
370
|
]
|
|
371
|
+
},
|
|
372
|
+
"Layout": {
|
|
373
|
+
"originX": 0,
|
|
374
|
+
"originY": 0
|
|
283
375
|
}
|
|
284
376
|
}
|
|
285
377
|
},
|
|
@@ -290,6 +382,10 @@
|
|
|
290
382
|
"Transform": {
|
|
291
383
|
"x": 0,
|
|
292
384
|
"z": -4
|
|
385
|
+
},
|
|
386
|
+
"Layout": {
|
|
387
|
+
"originX": 0,
|
|
388
|
+
"originY": 0
|
|
293
389
|
}
|
|
294
390
|
}
|
|
295
391
|
},
|
|
@@ -300,6 +396,10 @@
|
|
|
300
396
|
"Transform": {
|
|
301
397
|
"x": -1.5,
|
|
302
398
|
"z": -3.4
|
|
399
|
+
},
|
|
400
|
+
"Layout": {
|
|
401
|
+
"originX": 0,
|
|
402
|
+
"originY": 0
|
|
303
403
|
}
|
|
304
404
|
}
|
|
305
405
|
},
|
|
@@ -310,6 +410,10 @@
|
|
|
310
410
|
"Transform": {
|
|
311
411
|
"x": 1.5,
|
|
312
412
|
"z": -3.4
|
|
413
|
+
},
|
|
414
|
+
"Layout": {
|
|
415
|
+
"originX": 0,
|
|
416
|
+
"originY": 0
|
|
313
417
|
}
|
|
314
418
|
}
|
|
315
419
|
},
|
|
@@ -329,6 +433,10 @@
|
|
|
329
433
|
2.5,
|
|
330
434
|
0.4
|
|
331
435
|
]
|
|
436
|
+
},
|
|
437
|
+
"Layout": {
|
|
438
|
+
"originX": 0,
|
|
439
|
+
"originY": 0
|
|
332
440
|
}
|
|
333
441
|
}
|
|
334
442
|
},
|
|
@@ -349,6 +457,10 @@
|
|
|
349
457
|
2,
|
|
350
458
|
0.4
|
|
351
459
|
]
|
|
460
|
+
},
|
|
461
|
+
"Layout": {
|
|
462
|
+
"originX": 0,
|
|
463
|
+
"originY": 0
|
|
352
464
|
}
|
|
353
465
|
}
|
|
354
466
|
},
|
|
@@ -359,6 +471,10 @@
|
|
|
359
471
|
"Transform": {
|
|
360
472
|
"x": -2.7,
|
|
361
473
|
"z": -13.5
|
|
474
|
+
},
|
|
475
|
+
"Layout": {
|
|
476
|
+
"originX": 0,
|
|
477
|
+
"originY": 0
|
|
362
478
|
}
|
|
363
479
|
}
|
|
364
480
|
},
|
|
@@ -369,6 +485,10 @@
|
|
|
369
485
|
"Transform": {
|
|
370
486
|
"x": -1.3,
|
|
371
487
|
"z": -14.2
|
|
488
|
+
},
|
|
489
|
+
"Layout": {
|
|
490
|
+
"originX": 0,
|
|
491
|
+
"originY": 0
|
|
372
492
|
}
|
|
373
493
|
}
|
|
374
494
|
},
|
|
@@ -380,6 +500,10 @@
|
|
|
380
500
|
"x": -2.2,
|
|
381
501
|
"y": 1.6,
|
|
382
502
|
"z": 5.5
|
|
503
|
+
},
|
|
504
|
+
"Layout": {
|
|
505
|
+
"originX": 0,
|
|
506
|
+
"originY": 0
|
|
383
507
|
}
|
|
384
508
|
}
|
|
385
509
|
},
|
|
@@ -391,6 +515,10 @@
|
|
|
391
515
|
"x": -1.2,
|
|
392
516
|
"y": 1.6,
|
|
393
517
|
"z": 2.6
|
|
518
|
+
},
|
|
519
|
+
"Layout": {
|
|
520
|
+
"originX": 0,
|
|
521
|
+
"originY": 0
|
|
394
522
|
}
|
|
395
523
|
}
|
|
396
524
|
},
|
|
@@ -41,7 +41,7 @@ Reach for one when the deck accumulates content someone will keep iterating
|
|
|
41
41
|
on by hand — level layouts, dialogue, item or word catalogs, tuning values —
|
|
42
42
|
where editing raw JSON in the code editor is the bottleneck.
|
|
43
43
|
|
|
44
|
-
### The
|
|
44
|
+
### The two steps
|
|
45
45
|
|
|
46
46
|
1. **Declare the type** in the deck's own `castle.json` under
|
|
47
47
|
`editor.fileTypes`:
|
|
@@ -136,11 +136,8 @@ That hook is the single definition of the rule. Do not re-derive it from
|
|
|
136
136
|
`isImportedFile` or `window.__castleReadOnly` — a fork IS writable, and getting
|
|
137
137
|
that wrong locks an editor the deck is entitled to use.
|
|
138
138
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
or the files won't appear in the Files panel. A brand-new editor module
|
|
142
|
-
is not in the loader's glob until the panel reloads — the person's next
|
|
143
|
-
reload picks it up; do not force one.
|
|
139
|
+
A brand-new editor module is not in the loader's glob until the panel reloads —
|
|
140
|
+
the person's next reload picks it up; do not force one.
|
|
144
141
|
|
|
145
142
|
That's the whole integration: no entry-point changes, no registration call.
|
|
146
143
|
The kit's editor host dispatches any declared module, including ones the kit
|
|
@@ -378,7 +375,7 @@ A **blueprint** is a `.scene` file under `blueprints/` whose single actor (`acto
|
|
|
378
375
|
"actors": [
|
|
379
376
|
{
|
|
380
377
|
"components": {
|
|
381
|
-
"Layout": { "width": 50, "height": 25 },
|
|
378
|
+
"Layout": { "width": 50, "height": 25, "originX": 0.5, "originY": 0.5 },
|
|
382
379
|
"Sprite": { "file": "drawings/brick.sprite" },
|
|
383
380
|
"Collider": { "kind": "solid" },
|
|
384
381
|
"Brick": {}
|
|
@@ -390,6 +387,10 @@ A **blueprint** is a `.scene` file under `blueprints/` whose single actor (`acto
|
|
|
390
387
|
|
|
391
388
|
Template `components` keys are behavior names (the `static behaviorName`); add a behavior to a kind of actor by adding its key here, remove it by deleting the key. The template almost always has a `Layout` with `width`/`height` (instances supply `x`/`y`).
|
|
392
389
|
|
|
390
|
+
- **New blueprints default to center origin** (`originX`/`originY` `0.5` — written by the editor, and what omitting them means). Write `"originX": 0, "originY": 0` when you need top-left. See **Layout** under `## Built-in behaviors`.
|
|
391
|
+
- **A deck made before the origin existed had `"originX": 0, "originY": 0` written into it by the kit update**, so nothing moved and it still renders exactly as it did; convert a blueprint to center when you want to, from the Origin select in its inspector (which re-anchors its instances for you).
|
|
392
|
+
- **Never change the origin of a blueprint another deck imports.** Changing it in the editor re-anchors every instance in THIS deck's scenes so nothing moves; scenes in decks that import the blueprint are out of reach and their actors would jump. Same hazard as changing an imported blueprint's `width`, but positional.
|
|
393
|
+
|
|
393
394
|
- **Author one blueprint per kind of thing** — `blueprints/<meaningful>.scene` with a real `"name"` — and place instances that reference it. Do this even for a one-off actor: it costs one small file and keeps the deck's blueprint library intentional.
|
|
394
395
|
- Editing a blueprint file changes every instance that doesn't override that prop, across every scene — so one `blueprints/player.scene` referenced from every level stays in sync everywhere. Editing an instance's own `Layout.x`/`y`/`rotation` never touches the blueprint (position/rotation are always instance-local — see `Layout.jsx`'s `propertyMeta`).
|
|
395
396
|
- **Never write inline actors** (full `components`, no `blueprint` field). They aren't a lighter-weight alternative: the editor auto-migrates every such actor into its OWN new blueprint file the first time a human opens the scene — mechanically, one blueprint per actor, no dedup. That migration is a compatibility net for pre-blueprint decks, not an authoring workflow; leaning on it turns 10 inline enemies into 10 junk blueprints.
|
|
@@ -399,7 +400,7 @@ The kit also ships a few presets under `blueprints/` (e.g. `text.scene`, `ball.s
|
|
|
399
400
|
|
|
400
401
|
## Built-in behaviors
|
|
401
402
|
|
|
402
|
-
- **Layout** — `{ x, y, width, height, z?, rotation? }`. Every actor needs one. `z` orders draw (low first). `rotation` is degrees about the center.
|
|
403
|
+
- **Layout** — `{ x, y, width, height, z?, rotation?, originX?, originY? }`. Every actor needs one. `z` orders draw (low first). `rotation` is degrees about the box center. `originX`/`originY` say WHICH point of the box `x`/`y` names, as fractions of the box from its own top-left: `0.5, 0.5` (the default, and what omitting them means) is the center, `0, 0` the top-left corner, `1, 1` the bottom-right; values outside `0..1` are allowed. So `{ x: 250, y: 350, width: 40, height: 40 }` centers a 40x40 box on the middle of the card. The origin anchors position only — rotation still pivots on the center, and collider shape fractions are still measured from the box's top-left. Blueprints the editor creates, and the kit's own presets (`ball`, `block`, `crate`, `goal`, `cauldron`, `text`), use center. A deck authored before the origin existed meant the top-left everywhere, and the kit update wrote that down as explicit `0`s rather than moving anything — so an old deck reads as top-left because it says so, not because of a default. Read the box back with `scene.layoutRect(actor)` instead of doing `x + width / 2` by hand, which is only right at a top-left origin.
|
|
403
404
|
- **Sprite** — `{ file: "drawings/foo.sprite", tint?: "#rrggbbaa", playing?: true, tag?: "", mode?: 'cover'|'fit'|'stretch'|'tile', tileSize?: 50 }`. Renders the deck's 2D art into the Layout box. `file` is either a `.sprite` pixel-art sprite or an uploaded **image file** (`.png`, `.jpg`, `.jpeg`, `.gif`, `.webp`, `.svg`) — every prop below works the same on both, except that an image is a single still (no frames or tags) and is drawn smoothed rather than nearest-neighbour, which is what you want for a photo and not for pixel art. Draw modes: scaled up preserving the art's aspect ratio to fill the whole box, cropping whatever overflows a mismatched box (`mode: 'cover'`, the default -- CSS object-fit: cover), scaled preserving the art's aspect ratio and centered so the whole sprite stays visible, letterboxing a mismatched box instead of cropping (`mode: 'fit'` -- CSS object-fit: contain), scaled to fill the box exactly and distorting the art when the aspect ratios don't match (`mode: 'stretch'`), or repeated (`mode: 'tile'`). `tint` multiplies; use white (`#ffffffff`) or omit for the original colors. Animated sprites play automatically; set `playing: false` to hold the first frame, or `tag` to play a named animation tag. Tile mode repeats the art at a fixed cell size (`tileSize` card units tall, width scaled by the art's aspect) instead of stretching it across the Layout box.
|
|
404
405
|
- **Missing sprites fall back to a placeholder.** If `file` names a sprite that doesn't exist yet, it renders the fallback `drawings/cauldron.sprite` — so you can give an actor its REAL intended sprite name (`drawings/paddle.sprite`) right away and it shows the placeholder until that file is created. Reference real names from the start; don't wait for the art.
|
|
405
406
|
- **Fill the box, don't distort.** The default `mode: 'cover'` fills the Layout box with the art undistorted, cropping whatever overflows when the box aspect doesn't match the art's — so treat the Layout box like an image frame in a design tool: size it to frame what matters and keep the sprite's important content toward the center, since the edges may be cropped. Keeping an actor's Layout aspect ratio close to its sprite's native aspect ratio minimizes how much gets cropped. When the whole sprite must stay visible (nothing is safe to crop), use `mode: 'fit'`, which preserves the art and letterboxes the mismatched box instead. Avoid `mode: 'stretch'` for pixel art — filling a long/tall box by distorting wrecks the pixels (a brick sprite stretched into a wall ruins the bricks). For long surfaces (walls, floors, platforms), use `mode: 'tile'` on one actor to repeat the art at a fixed cell size instead of stretching or cropping a single sprite.
|
|
@@ -567,7 +568,8 @@ physics use `setVelocity`/`applyImpulse`/`applyForce`:
|
|
|
567
568
|
- `scene.physics.applyForce(actor, { x, y })` — add a matter-space force.
|
|
568
569
|
- `scene.physics.setRotation(actor, deg)` — same as writing `Layout.rotation`.
|
|
569
570
|
- `scene.physics.setPosition(actor, { x, y })` — same as writing Layout; x/y
|
|
570
|
-
are the Layout
|
|
571
|
+
are the Layout origin (the box center unless the actor sets
|
|
572
|
+
`originX`/`originY`), not the collider or body center.
|
|
571
573
|
- `scene.physics.setAngularVelocity(actor, degPerStep)` /
|
|
572
574
|
`getAngularVelocity(actor)` — set to 0 to stop a spin;
|
|
573
575
|
`setVelocity(actor, {x:0,y:0})` stops linear motion.
|
|
@@ -866,6 +868,7 @@ To generate path art, emit an svg of **shapes** rather than per-pixel rects and
|
|
|
866
868
|
- `scene.claimPointer(id, ownerId, priority?)` / `scene.ownsPointer(id, ownerId)` — take a finger for one gesture so two controls can't both act on it, and check you still hold it. A higher `priority` takes it from a lower one, which is how a control that was actually pressed (a `Draggable`'s collider) beats one that takes any press (an `AnalogStick`), regardless of actor order. Claims vanish with the pointer, so there's nothing to release. This is what lets a player work a stick with one thumb and drag with the other.
|
|
867
869
|
- `scene.getActor(id)` / `scene.getActors()` (sorted by Layout.z) / `scene.getComponent(actor, name)`.
|
|
868
870
|
- `scene.actorWith('GameController')` / `scene.actorsWith('Brick')` — find one / all actors carrying a given behavior. Prefer these to `getActors().find(a => a.components.X)`.
|
|
871
|
+
- `scene.layoutRect(actorOrId)` — the actor's Layout box as `{ x, y, width, height }` in world units, with `originX`/`originY` applied, or null. Use it for any edge or center test (`rect.x`, `rect.x + rect.width`, `rect.x + rect.width / 2`): `layout.x` is the origin point, so hand-rolled `x + width / 2` math is only right for a top-left-origin actor. Ignores `rotation`.
|
|
869
872
|
- `scene.colliderRect(actorOrId)` — rect from Layout + Collider, or null.
|
|
870
873
|
- `scene.overlaps(a, b)` — true when two actors/ids with Collider overlap.
|
|
871
874
|
- `scene.data` — the live scene data. Mutate `actor.components.X = {...}` to change props.
|
|
@@ -894,8 +897,8 @@ For HUD text prefer a `Text` actor with `space: 'screen'` (or `drawUi` for custo
|
|
|
894
897
|
|
|
895
898
|
## Common breakout-shaped recipe (sketch)
|
|
896
899
|
|
|
897
|
-
- `Paddle` behavior: read keys, clamp x
|
|
898
|
-
- `Ball` behavior: store `vx, vy` on `actor.runtime`; integrate; bounce off wall edges (`x<0`, `x+
|
|
900
|
+
- `Paddle` behavior: read keys, move `layout.x`, and keep the box on the card — `const box = scene.layoutRect(actor)` and clamp so `box.x >= 0` and `box.x + box.width <= 500`.
|
|
901
|
+
- `Ball` behavior: store `vx, vy` on `actor.runtime`; integrate; bounce off the wall edges read from `const box = scene.layoutRect(actor)` (`box.x < 0`, `box.x + box.width > 500`, `box.y < 0`); on `scene.overlaps(actor, paddle)`, flip `vy`; for each `brick` in `scene.actorsWith('Brick')` check `scene.overlaps(actor, brick)` → flip `vy` and `scene.despawnActor(brick.id)`; if `box.y > 700` lose a life.
|
|
899
902
|
- `Brick` behavior: typically just a marker — `kind: 'solid'` collider is enough. State (hit count) goes on `actor.runtime` or the brick's own props.
|
|
900
903
|
- `GameController` (no Layout needed if you don't draw it): tracks score / lives / status; expose HUD via `Text` with `space: 'screen'` or `drawUi()`.
|
|
901
904
|
|
|
@@ -903,6 +906,8 @@ For HUD text prefer a `Text` actor with `space: 'screen'` (or `drawUi` for custo
|
|
|
903
906
|
|
|
904
907
|
- Don't name a behavior prop with a leading `$` — the engine reserves that prefix (see `$enabled`).
|
|
905
908
|
|
|
909
|
+
- Don't revert, replace, or re-scaffold a deck's `scenes/*.scene`, `blueprints/*.scene` or `behaviors/*.jsx` back to this kit's starter content, and don't rewrite or delete a whole scene to diagnose a problem — those files are the creator's game. Fix forward with targeted edits.
|
|
910
|
+
- Don't answer "how do I …" by inserting a demo behavior or actor into the scene. Explain it, or give a standalone snippet; only build it into the game when that's what was asked, and then say which file and which actor or blueprint it landed on.
|
|
906
911
|
- Don't `console.log` in tight loops — flood the serve log.
|
|
907
912
|
- Don't keep per-actor state on the behavior class instance; it's recreated each frame. Use `actor.runtime` or component props.
|
|
908
913
|
- Don't skip `constructor(props) { this.props = props; }`. `this.props` exists because the constructor assigns it; `defaultProps` alone does not put it there.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { layoutCenter } from '../engine/layout';
|
|
1
2
|
import { cardSize } from '../engine/scene';
|
|
2
3
|
|
|
3
4
|
// Follow camera: keeps the target actor centered in the viewport, clamped to
|
|
@@ -19,13 +20,11 @@ export class Camera {
|
|
|
19
20
|
|
|
20
21
|
update(_actor, scene) {
|
|
21
22
|
const target = this.props.target ? scene.getActor(this.props.target) : undefined;
|
|
22
|
-
const
|
|
23
|
-
if (!
|
|
23
|
+
const center = layoutCenter(target?.components.Layout);
|
|
24
|
+
if (!center) return;
|
|
24
25
|
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const desiredX = centerX - cardSize.width / 2;
|
|
28
|
-
const desiredY = centerY - cardSize.height / 2;
|
|
26
|
+
const desiredX = center.x - cardSize.width / 2;
|
|
27
|
+
const desiredY = center.y - cardSize.height / 2;
|
|
29
28
|
|
|
30
29
|
scene.camera = {
|
|
31
30
|
x: this.props.followX
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { layoutRect } from '../engine/layout';
|
|
2
|
+
|
|
1
3
|
// Goal: a sensor zone that counts when a physics body enters it, and flashes
|
|
2
4
|
// green briefly. Demonstrates the physics collision callbacks + a Collider with
|
|
3
5
|
// `isTrigger: true`. Put it on an actor with a Layout and a trigger Collider.
|
|
@@ -19,13 +21,14 @@ export class Goal {
|
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
draw(actor, scene, ctx) {
|
|
22
|
-
const
|
|
24
|
+
const box = layoutRect(actor.components.Layout);
|
|
25
|
+
if (!box) return;
|
|
23
26
|
const lit = (actor.runtime.flashUntil ?? 0) > scene.time;
|
|
24
27
|
ctx.save();
|
|
25
28
|
ctx.strokeStyle = lit ? '#5ac54f' : 'rgba(255, 235, 87, 0.9)';
|
|
26
29
|
ctx.lineWidth = 4;
|
|
27
30
|
ctx.setLineDash([6, 4]);
|
|
28
|
-
ctx.strokeRect(
|
|
31
|
+
ctx.strokeRect(box.x + 2, box.y + 2, box.width - 4, box.height - 4);
|
|
29
32
|
ctx.restore();
|
|
30
33
|
}
|
|
31
34
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import { Panel, SelectField, NumberField, CheckboxField, Button } from '../engine/ui';
|
|
3
3
|
import { SpriteField } from '../engine/spriteField';
|
|
4
|
-
import {
|
|
4
|
+
import { layoutCenter } from '../engine/layout';
|
|
5
|
+
import { inActorWorldSpace } from '../engine/physics/controls';
|
|
5
6
|
import { JOINT_TYPES } from '../engine/physics/joints';
|
|
6
7
|
import { drawJointArt } from '../engine/physics/jointArt';
|
|
7
8
|
|
|
@@ -55,12 +56,12 @@ export class Joints {
|
|
|
55
56
|
const emphasized =
|
|
56
57
|
options.colliderOverlayIds?.includes(actor.id) ||
|
|
57
58
|
scene.usesBlueprint(actor, options.dimBlueprintPath);
|
|
58
|
-
const a =
|
|
59
|
+
const a = layoutCenter(actor.components.Layout);
|
|
59
60
|
inActorWorldSpace(ctx, actor.components.Layout, (g) => {
|
|
60
61
|
for (const joint of list) {
|
|
61
62
|
const target = joint?.target && scene.getActor(joint.target);
|
|
62
63
|
if (!target || target.id === actor.id) continue;
|
|
63
|
-
const b =
|
|
64
|
+
const b = layoutCenter(target.components.Layout);
|
|
64
65
|
// hidden shows as a faint line in the editor, nothing in play.
|
|
65
66
|
let render = joint.render ?? 'line';
|
|
66
67
|
if (editing && render === 'hidden') render = 'line';
|