castle-web-cli 0.4.193 → 0.4.194
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.js +87 -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 -0
- package/dist/check.js +14 -6
- package/dist/devSessionServer.d.ts +6 -0
- package/dist/devSessionServer.js +23 -1
- package/dist/filesChanged.js +7 -3
- 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 +56 -6
- package/dist/index.js +58 -7
- package/dist/init.d.ts +1 -0
- package/dist/init.js +6 -1
- package/dist/native/loop.js +29 -9
- package/dist/platformDoc.js +4 -4
- package/dist/remix.js +4 -1
- package/dist/serve.js +133 -32
- package/dist/serverBundle.js +1 -1
- package/dist/versions.d.ts +14 -0
- package/dist/versions.js +21 -0
- package/dist/vitePlugins.d.ts +1 -0
- package/dist/vitePlugins.js +18 -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 -3
- 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 -3
- package/kits/multiplayer-3d/scenes/main.scene +128 -0
- package/kits/physics-2d/CLAUDE.md +11 -5
- 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 -1
- package/kits/physics-2d/editors/SceneEditor.jsx +26 -2
- package/kits/physics-2d/editors/SelectionOverlay.jsx +27 -20
- 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/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/real-time/castle.json +2 -2
- package/kits/real-time/code/server/persist.js +14 -0
- package/kits/turn-based/CLAUDE.md +12 -7
- package/kits/turn-based/blueprints/board.scene +3 -1
- package/kits/turn-based/blueprints/square.scene +3 -1
- package/kits/turn-based/castle.json +5 -3
- package/kits/turn-based/code/behaviors/Board.jsx +33 -21
- package/package.json +1 -1
|
@@ -3,10 +3,38 @@
|
|
|
3
3
|
"actors": [
|
|
4
4
|
{
|
|
5
5
|
"components": {
|
|
6
|
-
"Layout": {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
"Layout": {
|
|
7
|
+
"width": 44,
|
|
8
|
+
"height": 44,
|
|
9
|
+
"z": 2,
|
|
10
|
+
"originX": 0,
|
|
11
|
+
"originY": 0
|
|
12
|
+
},
|
|
13
|
+
"Box": {
|
|
14
|
+
"color": "#bd9354",
|
|
15
|
+
"edge": "#7a5c31",
|
|
16
|
+
"radius": 3
|
|
17
|
+
},
|
|
18
|
+
"Collider": {
|
|
19
|
+
"shapes": [
|
|
20
|
+
{
|
|
21
|
+
"type": "box",
|
|
22
|
+
"x": 0.5,
|
|
23
|
+
"y": 0.5,
|
|
24
|
+
"w": 1,
|
|
25
|
+
"h": 1
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"friction": 0.3,
|
|
29
|
+
"frictionStatic": 0.4,
|
|
30
|
+
"bounciness": 0
|
|
31
|
+
},
|
|
32
|
+
"RigidBody": {
|
|
33
|
+
"bodyType": "dynamic",
|
|
34
|
+
"gravityScale": 0,
|
|
35
|
+
"drag": 0.09,
|
|
36
|
+
"angularDrag": 2
|
|
37
|
+
}
|
|
10
38
|
}
|
|
11
39
|
}
|
|
12
40
|
]
|
|
@@ -3,10 +3,37 @@
|
|
|
3
3
|
"actors": [
|
|
4
4
|
{
|
|
5
5
|
"components": {
|
|
6
|
-
"Layout": {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
"Layout": {
|
|
7
|
+
"width": 34,
|
|
8
|
+
"height": 34,
|
|
9
|
+
"z": 3,
|
|
10
|
+
"originX": 0,
|
|
11
|
+
"originY": 0
|
|
12
|
+
},
|
|
13
|
+
"Box": {
|
|
14
|
+
"color": "#ff79c6",
|
|
15
|
+
"edge": "#8c3f6b",
|
|
16
|
+
"radius": 17,
|
|
17
|
+
"showFacing": true
|
|
18
|
+
},
|
|
19
|
+
"Collider": {
|
|
20
|
+
"shapes": [
|
|
21
|
+
{
|
|
22
|
+
"type": "circle",
|
|
23
|
+
"x": 0.5,
|
|
24
|
+
"y": 0.5,
|
|
25
|
+
"r": 0.5
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"friction": 0.05,
|
|
29
|
+
"bounciness": 0
|
|
30
|
+
},
|
|
31
|
+
"RigidBody": {
|
|
32
|
+
"bodyType": "kinematic",
|
|
33
|
+
"gravityScale": 0,
|
|
34
|
+
"drag": 0,
|
|
35
|
+
"freezeRotation": true
|
|
36
|
+
}
|
|
10
37
|
}
|
|
11
38
|
}
|
|
12
39
|
]
|
|
@@ -3,12 +3,44 @@
|
|
|
3
3
|
"actors": [
|
|
4
4
|
{
|
|
5
5
|
"components": {
|
|
6
|
-
"Layout": {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
"Layout": {
|
|
7
|
+
"width": 34,
|
|
8
|
+
"height": 34,
|
|
9
|
+
"z": 3,
|
|
10
|
+
"originX": 0,
|
|
11
|
+
"originY": 0
|
|
12
|
+
},
|
|
13
|
+
"Box": {
|
|
14
|
+
"color": "#8be9fd",
|
|
15
|
+
"edge": "#3f7f8c",
|
|
16
|
+
"radius": 17,
|
|
17
|
+
"showFacing": true
|
|
18
|
+
},
|
|
19
|
+
"Collider": {
|
|
20
|
+
"shapes": [
|
|
21
|
+
{
|
|
22
|
+
"type": "circle",
|
|
23
|
+
"x": 0.5,
|
|
24
|
+
"y": 0.5,
|
|
25
|
+
"r": 0.5
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"friction": 0.05,
|
|
29
|
+
"bounciness": 0
|
|
30
|
+
},
|
|
31
|
+
"RigidBody": {
|
|
32
|
+
"bodyType": "dynamic",
|
|
33
|
+
"gravityScale": 0,
|
|
34
|
+
"drag": 0.3,
|
|
35
|
+
"freezeRotation": true
|
|
36
|
+
},
|
|
37
|
+
"Player": {
|
|
38
|
+
"speed": 4
|
|
39
|
+
},
|
|
40
|
+
"AnalogStick": {
|
|
41
|
+
"speed": 4,
|
|
42
|
+
"maxRadius": 70
|
|
43
|
+
}
|
|
12
44
|
}
|
|
13
45
|
}
|
|
14
46
|
]
|
|
@@ -3,9 +3,31 @@
|
|
|
3
3
|
"actors": [
|
|
4
4
|
{
|
|
5
5
|
"components": {
|
|
6
|
-
"Layout": {
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
"Layout": {
|
|
7
|
+
"width": 100,
|
|
8
|
+
"height": 24,
|
|
9
|
+
"z": 1,
|
|
10
|
+
"originX": 0,
|
|
11
|
+
"originY": 0
|
|
12
|
+
},
|
|
13
|
+
"Box": {
|
|
14
|
+
"color": "#2b2d3d",
|
|
15
|
+
"edge": "#3d4159",
|
|
16
|
+
"radius": 2
|
|
17
|
+
},
|
|
18
|
+
"Collider": {
|
|
19
|
+
"shapes": [
|
|
20
|
+
{
|
|
21
|
+
"type": "box",
|
|
22
|
+
"x": 0.5,
|
|
23
|
+
"y": 0.5,
|
|
24
|
+
"w": 1,
|
|
25
|
+
"h": 1
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"friction": 0.1,
|
|
29
|
+
"bounciness": 0
|
|
30
|
+
}
|
|
9
31
|
}
|
|
10
32
|
}
|
|
11
33
|
]
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"imports": {
|
|
16
16
|
"castle.real-time": {
|
|
17
17
|
"deckId": "xFVr-afOLuUQ",
|
|
18
|
-
"version": "2026-09-
|
|
18
|
+
"version": "2026-09-16T21:18:06.448Z"
|
|
19
19
|
},
|
|
20
20
|
"castle.physics-2d": {
|
|
21
21
|
"deckId": "ckRZGFW4iPrx",
|
|
22
|
-
"version": "2026-09-
|
|
22
|
+
"version": "2026-09-16T21:17:53.144Z"
|
|
23
23
|
},
|
|
24
24
|
"castle.base": {
|
|
25
25
|
"deckId": "yRcmH4_aYllE",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
},
|
|
36
36
|
"deckId": "oiFu96LkwZ09",
|
|
37
37
|
"cardId": "nkJgrvrCby3H",
|
|
38
|
-
"publishedVersion": "2026-09-
|
|
38
|
+
"publishedVersion": "2026-09-16T21:20:14.363Z"
|
|
39
39
|
}
|
|
@@ -7,10 +7,10 @@ import path from 'path';
|
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
8
|
import { createRequire } from 'module';
|
|
9
9
|
|
|
10
|
-
const require = createRequire('/
|
|
11
|
-
// Playwright
|
|
12
|
-
//
|
|
13
|
-
const { chromium } = require('playwright');
|
|
10
|
+
const require = createRequire(new URL('../../../cli/package.json', import.meta.url));
|
|
11
|
+
// Playwright is a CLI dependency. Workspace browser automation is restricted to
|
|
12
|
+
// Castle decks, and both pages opened here are this served deck.
|
|
13
|
+
const { chromium } = require('playwright-core');
|
|
14
14
|
|
|
15
15
|
const deckDir = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
|
|
16
16
|
|
|
@@ -99,8 +99,11 @@ File names stay lowercase.
|
|
|
99
99
|
Identity comes from `player.playerId` / `player.userId`, never from a body.
|
|
100
100
|
- The kit ships `code/systems/multiplayer.js`, the frame loop. A deck that writes
|
|
101
101
|
its own file of that path gets its own instead; most decks should not.
|
|
102
|
-
- Two players is the test that matters: `castle-web serve`,
|
|
103
|
-
two tabs
|
|
102
|
+
- Two players is the test that matters: run `castle-web serve`, open the shell
|
|
103
|
+
URL it prints in two tabs, and open the Play panel in each. If you use
|
|
104
|
+
`.castle/serve.json`'s `contentPlayUrl` directly, open `/index.html?edit=0`;
|
|
105
|
+
its bare origin is the edit surface, where multiplayer does not join. The room
|
|
106
|
+
persists in deck storage across serve restarts; a fresh one
|
|
104
107
|
means removing its `world:<room>`, `game:<room>` and `player:<room>:*` rows
|
|
105
108
|
(the local serve's room is `dev`).
|
|
106
109
|
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"imports": {
|
|
15
15
|
"castle.real-time": {
|
|
16
16
|
"deckId": "xFVr-afOLuUQ",
|
|
17
|
-
"version": "2026-09-
|
|
17
|
+
"version": "2026-09-16T21:18:06.448Z"
|
|
18
18
|
},
|
|
19
19
|
"castle.physics-3d": {
|
|
20
20
|
"deckId": "JH0SclbPVP0y",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"castle.physics-2d": {
|
|
24
24
|
"deckId": "ckRZGFW4iPrx",
|
|
25
|
-
"version": "2026-09-
|
|
25
|
+
"version": "2026-09-16T21:17:53.144Z",
|
|
26
26
|
"via": "castle.physics-3d"
|
|
27
27
|
},
|
|
28
28
|
"castle.base": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"autoUpdateWhenImported": true,
|
|
34
34
|
"deckId": "ZwA_P_-VO-Qh",
|
|
35
35
|
"cardId": "bvRmCzyUpt_a",
|
|
36
|
-
"publishedVersion": "2026-09-
|
|
36
|
+
"publishedVersion": "2026-09-16T21:20:24.084Z",
|
|
37
37
|
"main": "main.jsx",
|
|
38
38
|
"server": {
|
|
39
39
|
"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
|
},
|
|
@@ -378,7 +378,7 @@ A **blueprint** is a `.scene` file under `blueprints/` whose single actor (`acto
|
|
|
378
378
|
"actors": [
|
|
379
379
|
{
|
|
380
380
|
"components": {
|
|
381
|
-
"Layout": { "width": 50, "height": 25 },
|
|
381
|
+
"Layout": { "width": 50, "height": 25, "originX": 0.5, "originY": 0.5 },
|
|
382
382
|
"Sprite": { "file": "drawings/brick.sprite" },
|
|
383
383
|
"Collider": { "kind": "solid" },
|
|
384
384
|
"Brick": {}
|
|
@@ -390,6 +390,10 @@ A **blueprint** is a `.scene` file under `blueprints/` whose single actor (`acto
|
|
|
390
390
|
|
|
391
391
|
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
392
|
|
|
393
|
+
- **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`.
|
|
394
|
+
- **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).
|
|
395
|
+
- **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.
|
|
396
|
+
|
|
393
397
|
- **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
398
|
- 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
399
|
- **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 +403,7 @@ The kit also ships a few presets under `blueprints/` (e.g. `text.scene`, `ball.s
|
|
|
399
403
|
|
|
400
404
|
## Built-in behaviors
|
|
401
405
|
|
|
402
|
-
- **Layout** — `{ x, y, width, height, z?, rotation? }`. Every actor needs one. `z` orders draw (low first). `rotation` is degrees about the center.
|
|
406
|
+
- **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
407
|
- **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
408
|
- **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
409
|
- **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 +571,8 @@ physics use `setVelocity`/`applyImpulse`/`applyForce`:
|
|
|
567
571
|
- `scene.physics.applyForce(actor, { x, y })` — add a matter-space force.
|
|
568
572
|
- `scene.physics.setRotation(actor, deg)` — same as writing `Layout.rotation`.
|
|
569
573
|
- `scene.physics.setPosition(actor, { x, y })` — same as writing Layout; x/y
|
|
570
|
-
are the Layout
|
|
574
|
+
are the Layout origin (the box center unless the actor sets
|
|
575
|
+
`originX`/`originY`), not the collider or body center.
|
|
571
576
|
- `scene.physics.setAngularVelocity(actor, degPerStep)` /
|
|
572
577
|
`getAngularVelocity(actor)` — set to 0 to stop a spin;
|
|
573
578
|
`setVelocity(actor, {x:0,y:0})` stops linear motion.
|
|
@@ -866,6 +871,7 @@ To generate path art, emit an svg of **shapes** rather than per-pixel rects and
|
|
|
866
871
|
- `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
872
|
- `scene.getActor(id)` / `scene.getActors()` (sorted by Layout.z) / `scene.getComponent(actor, name)`.
|
|
868
873
|
- `scene.actorWith('GameController')` / `scene.actorsWith('Brick')` — find one / all actors carrying a given behavior. Prefer these to `getActors().find(a => a.components.X)`.
|
|
874
|
+
- `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
875
|
- `scene.colliderRect(actorOrId)` — rect from Layout + Collider, or null.
|
|
870
876
|
- `scene.overlaps(a, b)` — true when two actors/ids with Collider overlap.
|
|
871
877
|
- `scene.data` — the live scene data. Mutate `actor.components.X = {...}` to change props.
|
|
@@ -894,8 +900,8 @@ For HUD text prefer a `Text` actor with `space: 'screen'` (or `drawUi` for custo
|
|
|
894
900
|
|
|
895
901
|
## Common breakout-shaped recipe (sketch)
|
|
896
902
|
|
|
897
|
-
- `Paddle` behavior: read keys, clamp x
|
|
898
|
-
- `Ball` behavior: store `vx, vy` on `actor.runtime`; integrate; bounce off wall edges (`x<0`, `x+
|
|
903
|
+
- `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`.
|
|
904
|
+
- `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
905
|
- `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
906
|
- `GameController` (no Layout needed if you don't draw it): tracks score / lives / status; expose HUD via `Text` with `space: 'screen'` or `drawUi()`.
|
|
901
907
|
|
|
@@ -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
|