create-threenative 0.2.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.
Files changed (320) hide show
  1. package/README.md +16 -0
  2. package/dist/index.d.ts +30 -0
  3. package/dist/index.js +283 -0
  4. package/dist/threenative.d.ts +6 -0
  5. package/dist/threenative.js +757 -0
  6. package/package.json +44 -0
  7. package/templates/action-rpg/.mcp.json +16 -0
  8. package/templates/action-rpg/AGENTS.md +40 -0
  9. package/templates/action-rpg/CLAUDE.md +42 -0
  10. package/templates/action-rpg/index.html +13 -0
  11. package/templates/action-rpg/kit.json +7 -0
  12. package/templates/action-rpg/package.json +47 -0
  13. package/templates/action-rpg/playtests/combat.playtest.json +61 -0
  14. package/templates/action-rpg/playtests/fail.playtest.json +21 -0
  15. package/templates/action-rpg/playtests/inventory.playtest.json +111 -0
  16. package/templates/action-rpg/playtests/progress.playtest.json +99 -0
  17. package/templates/action-rpg/playtests/survives.playtest.json +32 -0
  18. package/templates/action-rpg/playtests/win.playtest.json +30 -0
  19. package/templates/action-rpg/public/favicon.svg +5 -0
  20. package/templates/action-rpg/src/abilities/Ability.ts +45 -0
  21. package/templates/action-rpg/src/entities/Enemy.ts +143 -0
  22. package/templates/action-rpg/src/entities/Player.ts +83 -0
  23. package/templates/action-rpg/src/game.ts +40 -0
  24. package/templates/action-rpg/src/items/Inventory.ts +163 -0
  25. package/templates/action-rpg/src/loot/drops.ts +40 -0
  26. package/templates/action-rpg/src/main.ts +15 -0
  27. package/templates/action-rpg/src/physics.ts +40 -0
  28. package/templates/action-rpg/src/playtest-events.ts +15 -0
  29. package/templates/action-rpg/src/progress.ts +35 -0
  30. package/templates/action-rpg/src/render/camera.ts +26 -0
  31. package/templates/action-rpg/src/render/lighting.ts +30 -0
  32. package/templates/action-rpg/src/render/loading.ts +90 -0
  33. package/templates/action-rpg/src/render/materials.ts +40 -0
  34. package/templates/action-rpg/src/render/palette.ts +9 -0
  35. package/templates/action-rpg/src/render/postprocessing.ts +18 -0
  36. package/templates/action-rpg/src/render/shapes.ts +110 -0
  37. package/templates/action-rpg/src/render/sky.ts +18 -0
  38. package/templates/action-rpg/src/render/types.ts +3 -0
  39. package/templates/action-rpg/src/scenes/Boot.ts +12 -0
  40. package/templates/action-rpg/src/scenes/Play.ts +449 -0
  41. package/templates/action-rpg/src/state.ts +40 -0
  42. package/templates/action-rpg/src/stats/StatBlock.ts +57 -0
  43. package/templates/action-rpg/src/style.css +32 -0
  44. package/templates/action-rpg/src/ui/AbilityBar.tsx +28 -0
  45. package/templates/action-rpg/src/ui/App.tsx +21 -0
  46. package/templates/action-rpg/src/ui/CharacterPanel.tsx +31 -0
  47. package/templates/action-rpg/src/ui/Hud.tsx +29 -0
  48. package/templates/action-rpg/src/ui/InventoryPanel.tsx +37 -0
  49. package/templates/action-rpg/tailwind.config.ts +7 -0
  50. package/templates/action-rpg/threenative.config.ts +29 -0
  51. package/templates/action-rpg/tsconfig.json +17 -0
  52. package/templates/action-rpg/vite.config.ts +8 -0
  53. package/templates/defense/.mcp.json +16 -0
  54. package/templates/defense/AGENTS.md +53 -0
  55. package/templates/defense/CLAUDE.md +55 -0
  56. package/templates/defense/README.md +9 -0
  57. package/templates/defense/index.html +13 -0
  58. package/templates/defense/kit.json +7 -0
  59. package/templates/defense/package.json +46 -0
  60. package/templates/defense/playtests/leak.playtest.json +18 -0
  61. package/templates/defense/playtests/placement.playtest.json +40 -0
  62. package/templates/defense/playtests/scan.playtest.json +20 -0
  63. package/templates/defense/playtests/survive.playtest.json +26 -0
  64. package/templates/defense/playtests/survives.playtest.json +36 -0
  65. package/templates/defense/public/favicon.svg +5 -0
  66. package/templates/defense/src/attackers/Attacker.ts +104 -0
  67. package/templates/defense/src/board/Route.ts +80 -0
  68. package/templates/defense/src/economy.ts +36 -0
  69. package/templates/defense/src/entities/Player.ts +44 -0
  70. package/templates/defense/src/game.ts +30 -0
  71. package/templates/defense/src/main.ts +15 -0
  72. package/templates/defense/src/physics.ts +43 -0
  73. package/templates/defense/src/placement/Buildable.ts +49 -0
  74. package/templates/defense/src/playtest-events.ts +15 -0
  75. package/templates/defense/src/render/camera.ts +10 -0
  76. package/templates/defense/src/render/lighting.ts +32 -0
  77. package/templates/defense/src/render/loading.ts +89 -0
  78. package/templates/defense/src/render/materials.ts +13 -0
  79. package/templates/defense/src/render/palette.ts +21 -0
  80. package/templates/defense/src/render/postprocessing.ts +14 -0
  81. package/templates/defense/src/render/shapes.ts +89 -0
  82. package/templates/defense/src/render/sky.ts +45 -0
  83. package/templates/defense/src/scenes/Boot.ts +12 -0
  84. package/templates/defense/src/scenes/Defense.ts +165 -0
  85. package/templates/defense/src/state.ts +50 -0
  86. package/templates/defense/src/style.css +32 -0
  87. package/templates/defense/src/towers/Tower.ts +96 -0
  88. package/templates/defense/src/towers/targeting.ts +53 -0
  89. package/templates/defense/src/ui/App.tsx +17 -0
  90. package/templates/defense/src/ui/Hud.tsx +61 -0
  91. package/templates/defense/src/ui/Menu.tsx +7 -0
  92. package/templates/defense/src/waves.ts +40 -0
  93. package/templates/defense/tailwind.config.ts +1 -0
  94. package/templates/defense/threenative.config.ts +29 -0
  95. package/templates/defense/tsconfig.json +17 -0
  96. package/templates/defense/vite.config.ts +5 -0
  97. package/templates/minimal/.mcp.json +16 -0
  98. package/templates/minimal/AGENTS.md +400 -0
  99. package/templates/minimal/CLAUDE.md +402 -0
  100. package/templates/minimal/assets/.gitkeep +0 -0
  101. package/templates/minimal/index.html +14 -0
  102. package/templates/minimal/kit.json +7 -0
  103. package/templates/minimal/package.json +40 -0
  104. package/templates/minimal/playtests/play.playtest.json +32 -0
  105. package/templates/minimal/playtests/survives.playtest.json +32 -0
  106. package/templates/minimal/public/.gitkeep +0 -0
  107. package/templates/minimal/public/favicon.svg +4 -0
  108. package/templates/minimal/public/icon.png +0 -0
  109. package/templates/minimal/src/entities/Player.ts +66 -0
  110. package/templates/minimal/src/game.ts +28 -0
  111. package/templates/minimal/src/main.ts +17 -0
  112. package/templates/minimal/src/render/camera.ts +11 -0
  113. package/templates/minimal/src/render/hud.ts +53 -0
  114. package/templates/minimal/src/render/lighting.ts +46 -0
  115. package/templates/minimal/src/render/loading.ts +113 -0
  116. package/templates/minimal/src/render/materials.ts +16 -0
  117. package/templates/minimal/src/render/palette.ts +9 -0
  118. package/templates/minimal/src/render/postprocessing.ts +20 -0
  119. package/templates/minimal/src/render/sky.ts +41 -0
  120. package/templates/minimal/src/scenes/Boot.ts +5 -0
  121. package/templates/minimal/src/scenes/Play.ts +65 -0
  122. package/templates/minimal/src/state.ts +1 -0
  123. package/templates/minimal/src/style.css +41 -0
  124. package/templates/minimal/threenative.config.ts +32 -0
  125. package/templates/minimal/tsconfig.json +16 -0
  126. package/templates/minimal/vite.config.ts +3 -0
  127. package/templates/platformer/.mcp.json +16 -0
  128. package/templates/platformer/AGENTS.md +199 -0
  129. package/templates/platformer/CLAUDE.md +201 -0
  130. package/templates/platformer/assets/.gitkeep +0 -0
  131. package/templates/platformer/index.html +13 -0
  132. package/templates/platformer/kit.json +7 -0
  133. package/templates/platformer/package.json +50 -0
  134. package/templates/platformer/playtests/avoidance.playtest.json +23 -0
  135. package/templates/platformer/playtests/buffer.playtest.json +17 -0
  136. package/templates/platformer/playtests/chase.playtest.json +21 -0
  137. package/templates/platformer/playtests/collect.playtest.json +56 -0
  138. package/templates/platformer/playtests/collision-layers.playtest.json +36 -0
  139. package/templates/platformer/playtests/coyote.playtest.json +21 -0
  140. package/templates/platformer/playtests/damage.playtest.json +31 -0
  141. package/templates/platformer/playtests/dash.playtest.json +21 -0
  142. package/templates/platformer/playtests/jump.playtest.json +21 -0
  143. package/templates/platformer/playtests/oneway.playtest.json +17 -0
  144. package/templates/platformer/playtests/patrol.playtest.json +13 -0
  145. package/templates/platformer/playtests/performance.playtest.json +21 -0
  146. package/templates/platformer/playtests/physics.playtest.json +14 -0
  147. package/templates/platformer/playtests/respawn.playtest.json +31 -0
  148. package/templates/platformer/playtests/stomp-rise.playtest.json +41 -0
  149. package/templates/platformer/playtests/stomp.playtest.json +34 -0
  150. package/templates/platformer/playtests/survives.playtest.json +32 -0
  151. package/templates/platformer/playtests/terminal-loop-fail.playtest.json +29 -0
  152. package/templates/platformer/playtests/terminal-loop-win.playtest.json +52 -0
  153. package/templates/platformer/public/.gitkeep +0 -0
  154. package/templates/platformer/public/favicon.svg +4 -0
  155. package/templates/platformer/public/icon.png +0 -0
  156. package/templates/platformer/src/entities/Character.ts +218 -0
  157. package/templates/platformer/src/entities/Chaser.ts +118 -0
  158. package/templates/platformer/src/entities/Patrol.ts +88 -0
  159. package/templates/platformer/src/entities/Pickup.ts +72 -0
  160. package/templates/platformer/src/game.ts +27 -0
  161. package/templates/platformer/src/level/Checkpoints.ts +66 -0
  162. package/templates/platformer/src/level/Platform.ts +34 -0
  163. package/templates/platformer/src/main.ts +14 -0
  164. package/templates/platformer/src/playtest-events.ts +15 -0
  165. package/templates/platformer/src/render/camera.ts +8 -0
  166. package/templates/platformer/src/render/lighting.ts +38 -0
  167. package/templates/platformer/src/render/loading.ts +113 -0
  168. package/templates/platformer/src/render/materials.ts +11 -0
  169. package/templates/platformer/src/render/palette.ts +54 -0
  170. package/templates/platformer/src/render/postprocessing.ts +18 -0
  171. package/templates/platformer/src/render/rig.ts +60 -0
  172. package/templates/platformer/src/render/sky.ts +47 -0
  173. package/templates/platformer/src/render/terrain.ts +31 -0
  174. package/templates/platformer/src/render/touch-controls.ts +157 -0
  175. package/templates/platformer/src/render/touch-layout.ts +63 -0
  176. package/templates/platformer/src/scenes/Boot.ts +12 -0
  177. package/templates/platformer/src/scenes/Level.ts +176 -0
  178. package/templates/platformer/src/state.ts +23 -0
  179. package/templates/platformer/src/style.css +31 -0
  180. package/templates/platformer/src/ui/App.tsx +17 -0
  181. package/templates/platformer/src/ui/Hud.tsx +41 -0
  182. package/templates/platformer/src/ui/Menu.tsx +7 -0
  183. package/templates/platformer/tailwind.config.ts +2 -0
  184. package/templates/platformer/threenative.config.ts +32 -0
  185. package/templates/platformer/tsconfig.json +17 -0
  186. package/templates/platformer/vite.config.ts +5 -0
  187. package/templates/racing/.mcp.json +16 -0
  188. package/templates/racing/AGENTS.md +48 -0
  189. package/templates/racing/CLAUDE.md +50 -0
  190. package/templates/racing/index.html +13 -0
  191. package/templates/racing/kit.json +7 -0
  192. package/templates/racing/package.json +46 -0
  193. package/templates/racing/playtests/boost.playtest.json +45 -0
  194. package/templates/racing/playtests/outcome.playtest.json +78 -0
  195. package/templates/racing/playtests/ranking.playtest.json +37 -0
  196. package/templates/racing/playtests/rescue.playtest.json +28 -0
  197. package/templates/racing/playtests/reverse.playtest.json +37 -0
  198. package/templates/racing/playtests/shortcut.playtest.json +44 -0
  199. package/templates/racing/playtests/survives.playtest.json +32 -0
  200. package/templates/racing/public/favicon.svg +6 -0
  201. package/templates/racing/src/entities/RacingCar.ts +114 -0
  202. package/templates/racing/src/entities/Rival.ts +46 -0
  203. package/templates/racing/src/game.ts +29 -0
  204. package/templates/racing/src/kart/boost.ts +38 -0
  205. package/templates/racing/src/main.ts +15 -0
  206. package/templates/racing/src/playtest-events.ts +15 -0
  207. package/templates/racing/src/render/camera.ts +28 -0
  208. package/templates/racing/src/render/lighting.ts +32 -0
  209. package/templates/racing/src/render/loading.ts +58 -0
  210. package/templates/racing/src/render/materials.ts +15 -0
  211. package/templates/racing/src/render/palette.ts +30 -0
  212. package/templates/racing/src/render/postprocessing.ts +14 -0
  213. package/templates/racing/src/render/shapes.ts +37 -0
  214. package/templates/racing/src/render/sky.ts +45 -0
  215. package/templates/racing/src/scenes/Boot.ts +12 -0
  216. package/templates/racing/src/scenes/Race.ts +180 -0
  217. package/templates/racing/src/state.ts +35 -0
  218. package/templates/racing/src/style.css +32 -0
  219. package/templates/racing/src/track/Checkline.ts +19 -0
  220. package/templates/racing/src/track/Lap.ts +104 -0
  221. package/templates/racing/src/track/Ranking.ts +35 -0
  222. package/templates/racing/src/track/Track.ts +229 -0
  223. package/templates/racing/src/track/TrackSector.ts +77 -0
  224. package/templates/racing/src/track/rescue.ts +21 -0
  225. package/templates/racing/src/ui/App.tsx +17 -0
  226. package/templates/racing/src/ui/Hud.tsx +71 -0
  227. package/templates/racing/src/ui/Menu.tsx +7 -0
  228. package/templates/racing/tailwind.config.ts +2 -0
  229. package/templates/racing/threenative.config.ts +29 -0
  230. package/templates/racing/tsconfig.json +17 -0
  231. package/templates/racing/vite.config.ts +5 -0
  232. package/templates/shooter/.mcp.json +16 -0
  233. package/templates/shooter/AGENTS.md +69 -0
  234. package/templates/shooter/CLAUDE.md +71 -0
  235. package/templates/shooter/index.html +13 -0
  236. package/templates/shooter/kit.json +7 -0
  237. package/templates/shooter/package.json +46 -0
  238. package/templates/shooter/playtests/fail.playtest.json +30 -0
  239. package/templates/shooter/playtests/shooter.playtest.json +89 -0
  240. package/templates/shooter/playtests/survives.playtest.json +32 -0
  241. package/templates/shooter/public/favicon.svg +4 -0
  242. package/templates/shooter/src/combat/damage.ts +41 -0
  243. package/templates/shooter/src/entities/Pickup.ts +70 -0
  244. package/templates/shooter/src/entities/Player.ts +93 -0
  245. package/templates/shooter/src/entities/Target.ts +103 -0
  246. package/templates/shooter/src/game.ts +36 -0
  247. package/templates/shooter/src/level/SpawnPoints.ts +28 -0
  248. package/templates/shooter/src/main.ts +26 -0
  249. package/templates/shooter/src/physics.ts +49 -0
  250. package/templates/shooter/src/playtest-events.ts +15 -0
  251. package/templates/shooter/src/render/camera.ts +29 -0
  252. package/templates/shooter/src/render/lighting.ts +38 -0
  253. package/templates/shooter/src/render/loading.ts +86 -0
  254. package/templates/shooter/src/render/materials.ts +38 -0
  255. package/templates/shooter/src/render/palette.ts +9 -0
  256. package/templates/shooter/src/render/postprocessing.ts +19 -0
  257. package/templates/shooter/src/render/shapes.ts +194 -0
  258. package/templates/shooter/src/render/sky.ts +37 -0
  259. package/templates/shooter/src/render/types.ts +3 -0
  260. package/templates/shooter/src/render/ui.css +212 -0
  261. package/templates/shooter/src/render/ui.ts +59 -0
  262. package/templates/shooter/src/scenes/Boot.ts +12 -0
  263. package/templates/shooter/src/scenes/Play.ts +428 -0
  264. package/templates/shooter/src/state.ts +29 -0
  265. package/templates/shooter/src/ui/App.tsx +25 -0
  266. package/templates/shooter/src/ui/Hud.tsx +49 -0
  267. package/templates/shooter/src/ui/Menu.tsx +26 -0
  268. package/templates/shooter/src/waves.ts +50 -0
  269. package/templates/shooter/src/weapons/Hitscan.ts +43 -0
  270. package/templates/shooter/src/weapons/Projectile.ts +76 -0
  271. package/templates/shooter/tailwind.config.ts +5 -0
  272. package/templates/shooter/threenative.config.ts +29 -0
  273. package/templates/shooter/tsconfig.json +17 -0
  274. package/templates/shooter/vite.config.ts +8 -0
  275. package/templates/starter/.mcp.json +16 -0
  276. package/templates/starter/AGENTS.md +450 -0
  277. package/templates/starter/CLAUDE.md +452 -0
  278. package/templates/starter/assets/.gitkeep +0 -0
  279. package/templates/starter/index.html +13 -0
  280. package/templates/starter/kit.json +7 -0
  281. package/templates/starter/package.json +49 -0
  282. package/templates/starter/playtests/buffer.playtest.json +29 -0
  283. package/templates/starter/playtests/coyote.playtest.json +35 -0
  284. package/templates/starter/playtests/forward.playtest.json +15 -0
  285. package/templates/starter/playtests/hot-reload.playtest.json +28 -0
  286. package/templates/starter/playtests/look.playtest.json +43 -0
  287. package/templates/starter/playtests/monitoring.playtest.json +41 -0
  288. package/templates/starter/playtests/pause.playtest.json +33 -0
  289. package/templates/starter/playtests/play.playtest.json +16 -0
  290. package/templates/starter/playtests/respawn.playtest.json +28 -0
  291. package/templates/starter/playtests/restart.playtest.json +36 -0
  292. package/templates/starter/playtests/seed.playtest.json +18 -0
  293. package/templates/starter/playtests/survives.playtest.json +32 -0
  294. package/templates/starter/public/.gitkeep +0 -0
  295. package/templates/starter/public/favicon.svg +4 -0
  296. package/templates/starter/public/icon.png +0 -0
  297. package/templates/starter/public/native-proof.glb +0 -0
  298. package/templates/starter/public/native-proof.png +0 -0
  299. package/templates/starter/public/pickup.ogg +0 -0
  300. package/templates/starter/src/entities/Crate.ts +34 -0
  301. package/templates/starter/src/entities/Player.ts +80 -0
  302. package/templates/starter/src/game.ts +30 -0
  303. package/templates/starter/src/main.ts +15 -0
  304. package/templates/starter/src/render/camera.ts +57 -0
  305. package/templates/starter/src/render/lighting.ts +55 -0
  306. package/templates/starter/src/render/materials.ts +12 -0
  307. package/templates/starter/src/render/palette.ts +9 -0
  308. package/templates/starter/src/render/postprocessing.ts +18 -0
  309. package/templates/starter/src/render/shapes.ts +147 -0
  310. package/templates/starter/src/render/sky.ts +56 -0
  311. package/templates/starter/src/scenes/Play.ts +161 -0
  312. package/templates/starter/src/state.ts +10 -0
  313. package/templates/starter/src/style.css +45 -0
  314. package/templates/starter/src/ui/App.tsx +19 -0
  315. package/templates/starter/src/ui/Hud.tsx +37 -0
  316. package/templates/starter/src/ui/Menu.tsx +43 -0
  317. package/templates/starter/tailwind.config.ts +2 -0
  318. package/templates/starter/threenative.config.ts +31 -0
  319. package/templates/starter/tsconfig.json +17 -0
  320. package/templates/starter/vite.config.ts +8 -0
@@ -0,0 +1,60 @@
1
+ import { BoxGeometry, Group, Mesh, SphereGeometry } from "three";
2
+ import { createMaterials } from "./materials.js";
3
+
4
+ function limb(
5
+ side: number,
6
+ y: number,
7
+ material: ReturnType<typeof createMaterials>["character"],
8
+ ): Group {
9
+ const joint = new Group();
10
+ joint.position.set(side * 0.18, y, 0);
11
+ const mesh = new Mesh(new BoxGeometry(0.2, 0.42, 0.2), material);
12
+ mesh.position.y = -0.21;
13
+ mesh.castShadow = true;
14
+ joint.add(mesh);
15
+ return joint;
16
+ }
17
+
18
+ export function createCharacterRig() {
19
+ const materials = createMaterials();
20
+ const root = new Group();
21
+ const torso = new Group();
22
+ torso.position.y = 0.72;
23
+ root.add(torso);
24
+ const jacket = new Mesh(new BoxGeometry(0.62, 0.62, 0.46), materials.accent);
25
+ jacket.castShadow = true;
26
+ torso.add(jacket);
27
+ const head = new Mesh(new SphereGeometry(0.32, 12, 8), materials.character);
28
+ head.position.y = 0.55;
29
+ head.castShadow = true;
30
+ torso.add(head);
31
+ const nose = new Mesh(new SphereGeometry(0.07, 8, 6), materials.shadow);
32
+ nose.position.set(0, 0.5, 0.3);
33
+ torso.add(nose);
34
+ const arms: [Group, Group] = [
35
+ limb(-1, 0.2, materials.character),
36
+ limb(1, 0.2, materials.character),
37
+ ];
38
+ const legs: [Group, Group] = [
39
+ limb(-1, 0.48, materials.character),
40
+ limb(1, 0.48, materials.character),
41
+ ];
42
+ torso.add(...arms);
43
+ root.add(...legs);
44
+ return { arms, legs, root, torso };
45
+ }
46
+
47
+ export function animateCharacter(
48
+ rig: ReturnType<typeof createCharacterRig>,
49
+ state: string,
50
+ time: number,
51
+ speed: number,
52
+ ): void {
53
+ const swing = state === "run" ? Math.sin(time * 15) * 0.8 : 0;
54
+ rig.legs[0].rotation.z = swing;
55
+ rig.legs[1].rotation.z = -swing;
56
+ rig.arms[0].rotation.z = -swing * 0.7;
57
+ rig.arms[1].rotation.z = swing * 0.7;
58
+ rig.torso.position.y = 0.72 + (state === "idle" ? Math.sin(time * 3) * 0.025 : 0);
59
+ rig.root.rotation.y += (speed > 0.1 ? 0.04 : 0) * Math.sign(speed);
60
+ }
@@ -0,0 +1,47 @@
1
+ import {
2
+ BackSide,
3
+ BufferAttribute,
4
+ Color,
5
+ Fog,
6
+ Mesh,
7
+ MeshBasicMaterial,
8
+ type Scene,
9
+ SphereGeometry,
10
+ } from "three";
11
+ import { palette } from "./palette.js";
12
+
13
+ function skyDome(): Mesh {
14
+ const geometry = new SphereGeometry(180, 24, 12);
15
+ const positions = geometry.getAttribute("position");
16
+ const colors = new Float32Array(positions.count * 3);
17
+ const high = new Color(palette.skyHigh);
18
+ const low = new Color(palette.skyLow);
19
+ const color = new Color();
20
+ for (let index = 0; index < positions.count; index += 1) {
21
+ const height = Math.max(0, Math.min(1, (positions.getY(index) / 180 + 0.18) / 0.58));
22
+ color.copy(low).lerp(high, height);
23
+ colors.set([color.r, color.g, color.b], index * 3);
24
+ }
25
+ geometry.setAttribute("color", new BufferAttribute(colors, 3));
26
+ const mesh = new Mesh(
27
+ geometry,
28
+ new MeshBasicMaterial({ fog: false, side: BackSide, toneMapped: false, vertexColors: true }),
29
+ );
30
+ // The dome is authored at the origin and never moves; freeze only this
31
+ // known-static render object, leaving gameplay transforms under user control.
32
+ mesh.updateMatrix();
33
+ mesh.matrixAutoUpdate = false;
34
+ mesh.frustumCulled = false;
35
+ return mesh;
36
+ }
37
+
38
+ export function setupSky(scene: Scene): void {
39
+ scene.background = new Color(palette.skyHigh);
40
+ // Fog starting 28 units out reached the playable middle distance and pulled ground, platforms
41
+ // and props toward the same pale sky colour: a blind score of the first frame measured mean
42
+ // luminance 0.77, the highest of the seven templates, with the palette collapsed to one value
43
+ // band. Start it past where the next jump is and let the horizon fade instead. Tune both numbers
44
+ // to your level — this is your file.
45
+ scene.fog = new Fog(palette.skyLow, 90, 240);
46
+ scene.add(skyDome());
47
+ }
@@ -0,0 +1,31 @@
1
+ import { Group, type Object3D } from "three";
2
+ import { rockBox } from "./palette.js";
3
+
4
+ export function platform(
5
+ width: number,
6
+ height: number,
7
+ options: { readonly depth?: number; readonly seed?: number; readonly oneWay?: boolean } = {},
8
+ ): Object3D {
9
+ const depth = options.depth ?? 6;
10
+ if (options.oneWay === true) {
11
+ const group = new Group();
12
+ const slab = rockBox(width, height, depth, options.seed ?? 1);
13
+ group.add(slab);
14
+ return group;
15
+ }
16
+ return rockBox(width, height, depth, options.seed ?? 1);
17
+ }
18
+
19
+ export function bridge(length: number, depth = 2.6): Object3D {
20
+ const group = new Group();
21
+ for (let index = 0; index < Math.ceil(length); index += 1) {
22
+ const board = rockBox(0.86, 0.32, depth, index + 3);
23
+ board.position.x = index * 0.92;
24
+ group.add(board);
25
+ }
26
+ return group;
27
+ }
28
+
29
+ export function crate(): Object3D {
30
+ return rockBox(0.8, 0.8, 0.8, 23);
31
+ }
@@ -0,0 +1,157 @@
1
+ import {
2
+ CircleGeometry,
3
+ type ColorRepresentation,
4
+ Group,
5
+ MathUtils,
6
+ Mesh,
7
+ MeshBasicMaterial,
8
+ type PerspectiveCamera,
9
+ RingGeometry,
10
+ Vector2,
11
+ } from "three";
12
+ import { palette } from "./palette.js";
13
+ import {
14
+ BUTTON_RADIUS,
15
+ type ITouchInput,
16
+ type ITouchPointer,
17
+ type ITouchViewport,
18
+ MOVE_RADIUS,
19
+ stickDeflection,
20
+ touchControlPoint,
21
+ } from "./touch-layout.js";
22
+
23
+ /** Flat overlay material: drawn over the scene, never occluded by it. */
24
+ function overlayMaterial(color: ColorRepresentation, opacity: number): MeshBasicMaterial {
25
+ return new MeshBasicMaterial({
26
+ color,
27
+ depthTest: false,
28
+ depthWrite: false,
29
+ opacity,
30
+ transparent: true,
31
+ });
32
+ }
33
+
34
+ /** Controls live on a flat plane, so z is always 0. */
35
+ function place(mesh: Mesh, x: number, y: number): void {
36
+ mesh.position.set(x, y, 0);
37
+ }
38
+
39
+ /** The 5px-thick outline every control shares. */
40
+ function ringMesh(radius: number, material: MeshBasicMaterial): Mesh {
41
+ return new Mesh(new RingGeometry(radius - 5, radius, 32), material);
42
+ }
43
+
44
+ export class TouchControls {
45
+ readonly root = new Group();
46
+ #camera: PerspectiveCamera;
47
+ #input: ITouchInput = { dashPressed: false, jumpPressed: false, move: new Vector2() };
48
+ #wasDash = false;
49
+ #wasJump = false;
50
+ /** Where the current thumb landed. Undefined between touches. */
51
+ #moveAnchor: Vector2 | undefined;
52
+ #moveBase: Mesh;
53
+ #moveKnob: Mesh;
54
+ #dash: Mesh;
55
+ #jump: Mesh;
56
+ #idleMaterial: MeshBasicMaterial;
57
+ #activeMaterial: MeshBasicMaterial;
58
+
59
+ constructor(camera: PerspectiveCamera) {
60
+ this.#camera = camera;
61
+ this.#idleMaterial = overlayMaterial(palette.shadow, 0.28);
62
+ this.#activeMaterial = overlayMaterial(palette.accent, 0.58);
63
+ this.#moveBase = ringMesh(MOVE_RADIUS, this.#idleMaterial);
64
+ this.#moveKnob = new Mesh(new CircleGeometry(28, 24), this.#activeMaterial);
65
+ this.#dash = ringMesh(BUTTON_RADIUS, this.#idleMaterial);
66
+ this.#jump = ringMesh(BUTTON_RADIUS, this.#idleMaterial);
67
+ this.root.add(this.#moveBase, this.#moveKnob, this.#dash, this.#jump);
68
+ this.root.renderOrder = 10_001;
69
+ camera.add(this.root);
70
+ }
71
+
72
+ update(pointers: ReadonlyMap<number, ITouchPointer>, size: ITouchViewport): ITouchInput {
73
+ const jumpCenter = touchControlPoint(size, "jump");
74
+ const dashCenter = touchControlPoint(size, "dash");
75
+ const jump = this.#at(pointers, jumpCenter, BUTTON_RADIUS);
76
+ const dash = this.#at(pointers, dashCenter, BUTTON_RADIUS);
77
+ const left = [...pointers.values()].find((pointer) =>
78
+ this.#isMovementPointer(pointer, size, dashCenter, jumpCenter),
79
+ );
80
+ const resting = touchControlPoint(size, "move");
81
+ const move = this.#input.move;
82
+ if (left === undefined) {
83
+ // Thumb lifted: forget where it was, so the next touch anchors fresh.
84
+ this.#moveAnchor = undefined;
85
+ move.set(0, 0);
86
+ } else {
87
+ this.#moveAnchor ??= left.position.clone();
88
+ move.copy(stickDeflection(this.#moveAnchor, left.position, MOVE_RADIUS));
89
+ }
90
+ // The ring follows the thumb to its anchor, so the player can see where the stick went
91
+ // instead of watching a knob move against a circle their thumb is nowhere near.
92
+ const center = this.#moveAnchor ?? resting;
93
+ place(this.#moveKnob, center.x + move.x * MOVE_RADIUS, center.y - move.y * MOVE_RADIUS);
94
+ this.#jump.material = jump ? this.#activeMaterial : this.#idleMaterial;
95
+ this.#dash.material = dash ? this.#activeMaterial : this.#idleMaterial;
96
+ this.#input = {
97
+ dashPressed: dash && !this.#wasDash,
98
+ jumpPressed: jump && !this.#wasJump,
99
+ move,
100
+ };
101
+ this.#wasDash = dash;
102
+ this.#wasJump = jump;
103
+ this.#layout(size);
104
+ return this.#input;
105
+ }
106
+
107
+ debug(): Record<string, unknown> {
108
+ return { dash: this.#wasDash, jump: this.#wasJump, move: this.#input.move.toArray() };
109
+ }
110
+
111
+ dispose(): void {
112
+ this.root.removeFromParent();
113
+ for (const child of this.root.children) {
114
+ if (child instanceof Mesh) child.geometry.dispose();
115
+ }
116
+ this.#idleMaterial.dispose();
117
+ this.#activeMaterial.dispose();
118
+ }
119
+
120
+ #layout(size: ITouchViewport): void {
121
+ const worldHeight = 2 * Math.tan(MathUtils.degToRad(this.#camera.fov / 2));
122
+ const pixels = worldHeight / Math.max(1, size.height);
123
+ const worldWidth = size.width * pixels;
124
+ this.root.position.set(-worldWidth / 2, worldHeight / 2, -1);
125
+ this.root.scale.set(pixels, -pixels, 1);
126
+ // The anchor wins while a thumb is down; this only re-homes the ring once it lifts.
127
+ const move = this.#moveAnchor ?? touchControlPoint(size, "move");
128
+ const dash = touchControlPoint(size, "dash");
129
+ const jump = touchControlPoint(size, "jump");
130
+ place(this.#moveBase, move.x, move.y);
131
+ place(this.#dash, dash.x, dash.y);
132
+ place(this.#jump, jump.x, jump.y);
133
+ }
134
+
135
+ #isMovementPointer(
136
+ pointer: ITouchPointer,
137
+ size: ITouchViewport,
138
+ dashCenter: Vector2,
139
+ jumpCenter: Vector2,
140
+ ): boolean {
141
+ if (pointer.position.x >= size.width * 0.5 || pointer.position.y <= size.height * 0.5)
142
+ return false;
143
+ if (size.height <= size.width) return true;
144
+ const radiusSquared = BUTTON_RADIUS * BUTTON_RADIUS;
145
+ return (
146
+ pointer.position.distanceToSquared(dashCenter) > radiusSquared &&
147
+ pointer.position.distanceToSquared(jumpCenter) > radiusSquared
148
+ );
149
+ }
150
+
151
+ #at(pointers: ReadonlyMap<number, ITouchPointer>, center: Vector2, radius: number): boolean {
152
+ const radiusSquared = radius * radius;
153
+ return [...pointers.values()].some(
154
+ (pointer) => pointer.position.distanceToSquared(center) <= radiusSquared,
155
+ );
156
+ }
157
+ }
@@ -0,0 +1,63 @@
1
+ import { MathUtils, Vector2 } from "three";
2
+
3
+ /**
4
+ * Where the on-screen controls sit and how far the stick has been pushed. Pure geometry: no
5
+ * Three.js objects, no scene, so a test can check the maths without a renderer.
6
+ */
7
+
8
+ export const MOVE_RADIUS = 72;
9
+ export const BUTTON_RADIUS = 64;
10
+ const EDGE = 36;
11
+
12
+ export interface ITouchPointer {
13
+ readonly position: Vector2;
14
+ }
15
+
16
+ export interface ITouchViewport {
17
+ readonly height: number;
18
+ readonly width: number;
19
+ }
20
+
21
+ type TouchControlName = "dash" | "jump" | "move";
22
+
23
+ export function touchControlPoint(size: ITouchViewport, name: TouchControlName): Vector2 {
24
+ if (name === "move") return new Vector2(MOVE_RADIUS + EDGE, size.height - MOVE_RADIUS - EDGE);
25
+
26
+ if (size.height > size.width) {
27
+ const yOffset = name === "jump" ? BUTTON_RADIUS * 2 + EDGE : 0;
28
+ return new Vector2(
29
+ size.width - BUTTON_RADIUS - EDGE,
30
+ size.height - BUTTON_RADIUS - EDGE - yOffset,
31
+ );
32
+ }
33
+
34
+ const x =
35
+ name === "jump" ? size.width - BUTTON_RADIUS - EDGE : size.width - BUTTON_RADIUS * 3 - EDGE;
36
+ return new Vector2(x, size.height - BUTTON_RADIUS - EDGE);
37
+ }
38
+
39
+ export interface ITouchInput {
40
+ readonly dashPressed: boolean;
41
+ readonly jumpPressed: boolean;
42
+ readonly move: Vector2;
43
+ }
44
+
45
+ /**
46
+ * Deflection of a thumb from where that thumb landed, not from where the ring is drawn.
47
+ *
48
+ * A thumb does not arrive on the circle. It lands wherever the player's hand already was, and
49
+ * measuring from a fixed centre turns that landing spot into an instant full-strength direction
50
+ * the player never asked for — press the middle of the pad and the character bolts diagonally
51
+ * before you have moved at all. Anchoring on touch is what every thumbstick that feels right
52
+ * does, and it is the difference between a control that works and one that fights you.
53
+ *
54
+ * Exported so it can be tested without a renderer: it is pure arithmetic on two points.
55
+ */
56
+ export function stickDeflection(anchor: Vector2, current: Vector2, radius: number): Vector2 {
57
+ return new Vector2(
58
+ MathUtils.clamp((current.x - anchor.x) / radius, -1, 1),
59
+ // Screen y grows downward and the game's move.y is +up, so this axis inverts here rather
60
+ // than in the character, which reads `move` from keyboard and touch alike.
61
+ MathUtils.clamp((anchor.y - current.y) / radius, -1, 1),
62
+ );
63
+ }
@@ -0,0 +1,12 @@
1
+ import { Scene } from "@threenative/core";
2
+ import type { GameState } from "../state.js";
3
+ import { Level } from "./Level.js";
4
+ import type { GameCtx } from "./Level.js";
5
+
6
+ export class Boot extends Scene<GameState, GameCtx["physics"]> {
7
+ static override readonly initialState = Level.initialState;
8
+
9
+ override enter(ctx: GameCtx): void {
10
+ void ctx.goto("level");
11
+ }
12
+ }
@@ -0,0 +1,176 @@
1
+ import { type ICtx, Scene, type SceneFrame } from "@threenative/core";
2
+ import { CollisionShape3D, RigidBody3D } from "@threenative/physics";
3
+ import type { IPhysicsContext } from "@threenative/physics";
4
+ import { BoxGeometry, Mesh, type PerspectiveCamera, Vector3 } from "three";
5
+ import { Character, PLATFORMER_FEEL } from "../entities/Character.js";
6
+ import { Chaser } from "../entities/Chaser.js";
7
+ import { Patrol } from "../entities/Patrol.js";
8
+ import { Pickup, coinArc } from "../entities/Pickup.js";
9
+ import { Checkpoints } from "../level/Checkpoints.js";
10
+ import { createPlatform } from "../level/Platform.js";
11
+ import { emitPlaytestEvent } from "../playtest-events.js";
12
+ import { setupCamera } from "../render/camera.js";
13
+ import { setupLighting } from "../render/lighting.js";
14
+ import { createLoadingScreen } from "../render/loading.js";
15
+ import { createMaterials } from "../render/materials.js";
16
+ import { setupPost } from "../render/postprocessing.js";
17
+ import { setupSky } from "../render/sky.js";
18
+ import { crate as crateMesh } from "../render/terrain.js";
19
+ import { TouchControls } from "../render/touch-controls.js";
20
+ import { type GameState, TERMINAL, type TerminalState } from "../state.js";
21
+ export type GameCtx = ICtx<GameState, IPhysicsContext>;
22
+ const SPAWN = new Vector3(0, 0.75, 0);
23
+ const KILL_PLANE = -8;
24
+ const GOAL_X = 21.5;
25
+ export class Level extends Scene<GameState, IPhysicsContext> {
26
+ static override readonly initialState = {
27
+ checkpoint: 0,
28
+ coins: 0,
29
+ coyoteJumps: 0,
30
+ defeated: 0,
31
+ dashes: 0,
32
+ hearts: 3,
33
+ jumps: 0,
34
+ peakRise: 0,
35
+ playerX: SPAWN.x,
36
+ grounded: false,
37
+ respawns: 0,
38
+ terminal: TERMINAL.playing,
39
+ topSpeed: 0,
40
+ };
41
+ override enter(ctx: GameCtx): SceneFrame<GameState, IPhysicsContext> {
42
+ setupSky(ctx.scene);
43
+ setupLighting(ctx.scene, ctx.renderer.raw as Parameters<typeof setupLighting>[1]);
44
+ setupPost(ctx.renderer, ctx.scene, ctx.camera);
45
+ const camera = ctx.camera as PerspectiveCamera;
46
+ setupCamera(camera);
47
+ const loading = createLoadingScreen(ctx);
48
+ ctx.add(camera);
49
+ const touchControls = ctx.entities.add("touch-controls", new TouchControls(camera));
50
+ ctx.viewport.resize();
51
+ createPlatform(ctx, new Vector3(0, 0, 0), 18, { depth: 7, seed: 3 });
52
+ createPlatform(ctx, new Vector3(14, 0, 0), 10, { depth: 7, seed: 7 });
53
+ createPlatform(ctx, new Vector3(25, 0, 0), 8, { depth: 7, seed: 11 });
54
+ createPlatform(ctx, new Vector3(0, 2.6, 0), 6, { depth: 5, oneWay: true, seed: 17 });
55
+ const crate = crateMesh();
56
+ crate.position.set(-3, 1, 0);
57
+ crate.castShadow = crate.receiveShadow = true;
58
+ ctx.add(crate);
59
+ const crateBody = new RigidBody3D({
60
+ object: crate,
61
+ physics: ctx.physics,
62
+ shape: CollisionShape3D.box(0.8, 0.8, 0.8),
63
+ });
64
+ ctx.entities.add("crate", { body: crateBody, object: crate });
65
+ const blocker = new Mesh(new BoxGeometry(0.6, 1.6, 5.2), createMaterials().shadow);
66
+ blocker.position.set(3.4, 0.8, 0);
67
+ blocker.castShadow = blocker.receiveShadow = true;
68
+ ctx.add(blocker);
69
+ new RigidBody3D({
70
+ collisionLayer: 4,
71
+ object: blocker,
72
+ physics: ctx.physics,
73
+ shape: CollisionShape3D.box(0.6, 1.6, 5.2),
74
+ type: "fixed",
75
+ });
76
+ const { playerX } = ctx.state.getState() as { playerX?: number };
77
+ const spawn = SPAWN.clone();
78
+ if (Number.isFinite(playerX)) spawn.x = playerX ?? SPAWN.x;
79
+ const character = new Character(ctx, spawn);
80
+ ctx.entities.add("player", character);
81
+ const p = (x: number) => new Vector3(x, 0.75, 0);
82
+ const checkpoints = new Checkpoints([SPAWN, p(14), p(25)], 3, PLATFORMER_FEEL);
83
+ let coins = 0;
84
+ let defeated = 0;
85
+ let nextCoin = 0;
86
+ const cameraAnchor = new Vector3();
87
+ const addPickup = (at: Vector3): void => {
88
+ const id = `coin.${nextCoin}`;
89
+ nextCoin += 1;
90
+ const pickup = new Pickup(ctx, at, () => {
91
+ coins += 1;
92
+ emitPlaytestEvent({ entity: "player", name: "collected" });
93
+ });
94
+ ctx.entities.add(id, pickup);
95
+ };
96
+ const followCamera = (target: Vector3, dt: number): void => {
97
+ const desired = cameraAnchor.set(target.x, target.y + 4.4, target.z + 8.5);
98
+ if (dt >= 1) camera.position.copy(desired);
99
+ else camera.position.lerp(desired, 1 - Math.exp(-dt / 0.18));
100
+ camera.lookAt(target.x, target.y + 0.9, target.z);
101
+ };
102
+ addPickup(new Vector3(2, 1.05, 0));
103
+ addPickup(new Vector3(3.2, 1.05, 0));
104
+ addPickup(new Vector3(4.4, 1.05, 0));
105
+ for (const point of coinArc(new Vector3(11, 1.05, 0), 4, 3.6, 1.4)) addPickup(point);
106
+ const patrol = new Patrol(
107
+ ctx,
108
+ character,
109
+ new Vector3(5.2, 0.66, 0),
110
+ new Vector3(7.4, 0.66, 0),
111
+ () => {
112
+ defeated += 1;
113
+ },
114
+ (fromX) => checkpoints.hurt(character, fromX),
115
+ PLATFORMER_FEEL,
116
+ );
117
+ ctx.entities.add("patrol", patrol);
118
+ const chaser = new Chaser(ctx, new Vector3(7.5, 0.66, 0));
119
+ const avoidanceChaser = new Chaser(ctx, new Vector3(8.2, 0.66, 0.7));
120
+ chaser.mesh.userData.peer = avoidanceChaser.mesh;
121
+ avoidanceChaser.mesh.userData.peer = chaser.mesh;
122
+ ctx.entities.add("chaser", chaser);
123
+ ctx.entities.add("chaser.avoidance", avoidanceChaser);
124
+ followCamera(spawn, 1);
125
+ let elapsed = 0;
126
+ let terminal: TerminalState = TERMINAL.playing;
127
+ const finish = (next: TerminalState): void => {
128
+ if (terminal !== TERMINAL.playing) return;
129
+ terminal = next;
130
+ emitPlaytestEvent({ entity: "game", name: next === TERMINAL.won ? "won" : "lost" });
131
+ };
132
+ const updatePlaying = (frameCtx: GameCtx, dt: number): void => {
133
+ elapsed += dt;
134
+ character.update(
135
+ frameCtx,
136
+ dt,
137
+ touchControls.update(frameCtx.input.raw.pointers, frameCtx.viewport.size),
138
+ );
139
+ chaser.update(dt);
140
+ avoidanceChaser.update(dt);
141
+ patrol.update(dt);
142
+ checkpoints.pass(character.mesh.position);
143
+ checkpoints.update(dt, character);
144
+ character.health = checkpoints.hearts;
145
+ if (character.mesh.position.y < KILL_PLANE) checkpoints.respawn(character);
146
+ };
147
+ return (frameCtx, dt) => {
148
+ loading.update();
149
+ if (terminal === TERMINAL.playing) {
150
+ updatePlaying(frameCtx, dt);
151
+ if (checkpoints.hearts <= 0) finish(TERMINAL.lost);
152
+ else if (character.mesh.position.x >= GOAL_X && character.body.grounded)
153
+ finish(TERMINAL.won);
154
+ }
155
+ const rise = Math.max(0, character.mesh.position.y - SPAWN.y);
156
+ const speed = Math.hypot(character.body.velocity.x, character.body.velocity.z);
157
+ const previous = frameCtx.state.getState();
158
+ frameCtx.state.set({
159
+ checkpoint: checkpoints.currentIndex,
160
+ coins,
161
+ coyoteJumps: character.coyoteJumps,
162
+ defeated,
163
+ dashes: character.dashes,
164
+ hearts: checkpoints.hearts,
165
+ jumps: character.jumps,
166
+ peakRise: Math.max(previous.peakRise, rise),
167
+ playerX: character.mesh.position.x,
168
+ grounded: character.body.grounded,
169
+ respawns: checkpoints.respawns,
170
+ terminal,
171
+ topSpeed: Math.max(previous.topSpeed, speed),
172
+ } as Partial<GameState>);
173
+ followCamera(character.mesh.position, dt);
174
+ };
175
+ }
176
+ }
@@ -0,0 +1,23 @@
1
+ export const TERMINAL = {
2
+ playing: 0,
3
+ won: 1,
4
+ lost: 2,
5
+ } as const;
6
+
7
+ export type TerminalState = (typeof TERMINAL)[keyof typeof TERMINAL];
8
+
9
+ export type GameState = {
10
+ checkpoint: number;
11
+ coins: number;
12
+ coyoteJumps: number;
13
+ defeated: number;
14
+ dashes: number;
15
+ hearts: number;
16
+ jumps: number;
17
+ peakRise: number;
18
+ playerX: number;
19
+ grounded: boolean;
20
+ respawns: number;
21
+ terminal: TerminalState;
22
+ topSpeed: number;
23
+ };
@@ -0,0 +1,31 @@
1
+ @import "tailwindcss";
2
+
3
+ @source "../index.html";
4
+ @source "./";
5
+
6
+ @theme {
7
+ --color-ink: #04080d;
8
+ --color-panel: #0d1c26;
9
+ --color-line: #14313f;
10
+ --color-lume: #6fe8ff;
11
+ --color-warn: #ffd27a;
12
+ --color-text: #a8ccd8;
13
+ --color-dim: #4e7686;
14
+ --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
15
+ }
16
+
17
+ html,
18
+ body,
19
+ #root {
20
+ width: 100%;
21
+ height: 100%;
22
+ margin: 0;
23
+ overflow: hidden;
24
+ }
25
+
26
+ body {
27
+ background: var(--color-ink);
28
+ color: var(--color-text);
29
+ font-family: var(--font-mono);
30
+ -webkit-font-smoothing: antialiased;
31
+ }
@@ -0,0 +1,17 @@
1
+ import type { IGame } from "@threenative/core";
2
+ import type { IPhysicsContext } from "@threenative/physics";
3
+ import { DebugOverlay, GameCanvas } from "@threenative/ui";
4
+ import type { GameState } from "../state.js";
5
+ import { Hud } from "./Hud.js";
6
+ import { Menu } from "./Menu.js";
7
+
8
+ export function App({ game }: { game: IGame<GameState, IPhysicsContext> }) {
9
+ return (
10
+ <main className="relative h-screen w-screen overflow-hidden bg-ink">
11
+ <GameCanvas className="absolute inset-0" game={game} />
12
+ <Hud game={game} />
13
+ <Menu />
14
+ <DebugOverlay />
15
+ </main>
16
+ );
17
+ }
@@ -0,0 +1,41 @@
1
+ import type { IGame } from "@threenative/core";
2
+ import type { IPhysicsContext } from "@threenative/physics";
3
+ import { useGameState } from "@threenative/ui";
4
+ import type { GameState } from "../state.js";
5
+
6
+ export function Hud({ game }: { game: IGame<GameState, IPhysicsContext> }) {
7
+ const state = useGameState(game, (value) => value);
8
+ return (
9
+ <div className="pointer-events-none absolute inset-0 p-6 text-[11px] uppercase tracking-[0.14em] text-text">
10
+ <div className="flex gap-5">
11
+ <span>
12
+ coins{" "}
13
+ <b id="coins" className="text-lume">
14
+ {state.coins}
15
+ </b>
16
+ </span>
17
+ <span>
18
+ hearts{" "}
19
+ <b id="hearts" className="text-warn">
20
+ {state.hearts}
21
+ </b>
22
+ </span>
23
+ <span>
24
+ checkpoint{" "}
25
+ <b id="checkpoint" className="text-lume">
26
+ {state.checkpoint}
27
+ </b>
28
+ </span>
29
+ <span>
30
+ term{" "}
31
+ <b id="terminal" className="text-lume">
32
+ {state.terminal}
33
+ </b>
34
+ </span>
35
+ </div>
36
+ <div className="mt-2 text-dim">
37
+ jumps {state.jumps} · dashes {state.dashes} · defeated {state.defeated}
38
+ </div>
39
+ </div>
40
+ );
41
+ }
@@ -0,0 +1,7 @@
1
+ export function Menu() {
2
+ return (
3
+ <div className="pointer-events-none absolute bottom-6 left-6 border border-line bg-panel/75 px-4 py-3 text-[11px] uppercase tracking-[0.14em] text-dim">
4
+ arrows / WASD move · space jump · shift dash
5
+ </div>
6
+ );
7
+ }
@@ -0,0 +1,2 @@
1
+ // Tailwind 4 is CSS-first. Keep this file for familiar project discovery.
2
+ export default {};