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.
- package/README.md +16 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +283 -0
- package/dist/threenative.d.ts +6 -0
- package/dist/threenative.js +757 -0
- package/package.json +44 -0
- package/templates/action-rpg/.mcp.json +16 -0
- package/templates/action-rpg/AGENTS.md +40 -0
- package/templates/action-rpg/CLAUDE.md +42 -0
- package/templates/action-rpg/index.html +13 -0
- package/templates/action-rpg/kit.json +7 -0
- package/templates/action-rpg/package.json +47 -0
- package/templates/action-rpg/playtests/combat.playtest.json +61 -0
- package/templates/action-rpg/playtests/fail.playtest.json +21 -0
- package/templates/action-rpg/playtests/inventory.playtest.json +111 -0
- package/templates/action-rpg/playtests/progress.playtest.json +99 -0
- package/templates/action-rpg/playtests/survives.playtest.json +32 -0
- package/templates/action-rpg/playtests/win.playtest.json +30 -0
- package/templates/action-rpg/public/favicon.svg +5 -0
- package/templates/action-rpg/src/abilities/Ability.ts +45 -0
- package/templates/action-rpg/src/entities/Enemy.ts +143 -0
- package/templates/action-rpg/src/entities/Player.ts +83 -0
- package/templates/action-rpg/src/game.ts +40 -0
- package/templates/action-rpg/src/items/Inventory.ts +163 -0
- package/templates/action-rpg/src/loot/drops.ts +40 -0
- package/templates/action-rpg/src/main.ts +15 -0
- package/templates/action-rpg/src/physics.ts +40 -0
- package/templates/action-rpg/src/playtest-events.ts +15 -0
- package/templates/action-rpg/src/progress.ts +35 -0
- package/templates/action-rpg/src/render/camera.ts +26 -0
- package/templates/action-rpg/src/render/lighting.ts +30 -0
- package/templates/action-rpg/src/render/loading.ts +90 -0
- package/templates/action-rpg/src/render/materials.ts +40 -0
- package/templates/action-rpg/src/render/palette.ts +9 -0
- package/templates/action-rpg/src/render/postprocessing.ts +18 -0
- package/templates/action-rpg/src/render/shapes.ts +110 -0
- package/templates/action-rpg/src/render/sky.ts +18 -0
- package/templates/action-rpg/src/render/types.ts +3 -0
- package/templates/action-rpg/src/scenes/Boot.ts +12 -0
- package/templates/action-rpg/src/scenes/Play.ts +449 -0
- package/templates/action-rpg/src/state.ts +40 -0
- package/templates/action-rpg/src/stats/StatBlock.ts +57 -0
- package/templates/action-rpg/src/style.css +32 -0
- package/templates/action-rpg/src/ui/AbilityBar.tsx +28 -0
- package/templates/action-rpg/src/ui/App.tsx +21 -0
- package/templates/action-rpg/src/ui/CharacterPanel.tsx +31 -0
- package/templates/action-rpg/src/ui/Hud.tsx +29 -0
- package/templates/action-rpg/src/ui/InventoryPanel.tsx +37 -0
- package/templates/action-rpg/tailwind.config.ts +7 -0
- package/templates/action-rpg/threenative.config.ts +29 -0
- package/templates/action-rpg/tsconfig.json +17 -0
- package/templates/action-rpg/vite.config.ts +8 -0
- package/templates/defense/.mcp.json +16 -0
- package/templates/defense/AGENTS.md +53 -0
- package/templates/defense/CLAUDE.md +55 -0
- package/templates/defense/README.md +9 -0
- package/templates/defense/index.html +13 -0
- package/templates/defense/kit.json +7 -0
- package/templates/defense/package.json +46 -0
- package/templates/defense/playtests/leak.playtest.json +18 -0
- package/templates/defense/playtests/placement.playtest.json +40 -0
- package/templates/defense/playtests/scan.playtest.json +20 -0
- package/templates/defense/playtests/survive.playtest.json +26 -0
- package/templates/defense/playtests/survives.playtest.json +36 -0
- package/templates/defense/public/favicon.svg +5 -0
- package/templates/defense/src/attackers/Attacker.ts +104 -0
- package/templates/defense/src/board/Route.ts +80 -0
- package/templates/defense/src/economy.ts +36 -0
- package/templates/defense/src/entities/Player.ts +44 -0
- package/templates/defense/src/game.ts +30 -0
- package/templates/defense/src/main.ts +15 -0
- package/templates/defense/src/physics.ts +43 -0
- package/templates/defense/src/placement/Buildable.ts +49 -0
- package/templates/defense/src/playtest-events.ts +15 -0
- package/templates/defense/src/render/camera.ts +10 -0
- package/templates/defense/src/render/lighting.ts +32 -0
- package/templates/defense/src/render/loading.ts +89 -0
- package/templates/defense/src/render/materials.ts +13 -0
- package/templates/defense/src/render/palette.ts +21 -0
- package/templates/defense/src/render/postprocessing.ts +14 -0
- package/templates/defense/src/render/shapes.ts +89 -0
- package/templates/defense/src/render/sky.ts +45 -0
- package/templates/defense/src/scenes/Boot.ts +12 -0
- package/templates/defense/src/scenes/Defense.ts +165 -0
- package/templates/defense/src/state.ts +50 -0
- package/templates/defense/src/style.css +32 -0
- package/templates/defense/src/towers/Tower.ts +96 -0
- package/templates/defense/src/towers/targeting.ts +53 -0
- package/templates/defense/src/ui/App.tsx +17 -0
- package/templates/defense/src/ui/Hud.tsx +61 -0
- package/templates/defense/src/ui/Menu.tsx +7 -0
- package/templates/defense/src/waves.ts +40 -0
- package/templates/defense/tailwind.config.ts +1 -0
- package/templates/defense/threenative.config.ts +29 -0
- package/templates/defense/tsconfig.json +17 -0
- package/templates/defense/vite.config.ts +5 -0
- package/templates/minimal/.mcp.json +16 -0
- package/templates/minimal/AGENTS.md +400 -0
- package/templates/minimal/CLAUDE.md +402 -0
- package/templates/minimal/assets/.gitkeep +0 -0
- package/templates/minimal/index.html +14 -0
- package/templates/minimal/kit.json +7 -0
- package/templates/minimal/package.json +40 -0
- package/templates/minimal/playtests/play.playtest.json +32 -0
- package/templates/minimal/playtests/survives.playtest.json +32 -0
- package/templates/minimal/public/.gitkeep +0 -0
- package/templates/minimal/public/favicon.svg +4 -0
- package/templates/minimal/public/icon.png +0 -0
- package/templates/minimal/src/entities/Player.ts +66 -0
- package/templates/minimal/src/game.ts +28 -0
- package/templates/minimal/src/main.ts +17 -0
- package/templates/minimal/src/render/camera.ts +11 -0
- package/templates/minimal/src/render/hud.ts +53 -0
- package/templates/minimal/src/render/lighting.ts +46 -0
- package/templates/minimal/src/render/loading.ts +113 -0
- package/templates/minimal/src/render/materials.ts +16 -0
- package/templates/minimal/src/render/palette.ts +9 -0
- package/templates/minimal/src/render/postprocessing.ts +20 -0
- package/templates/minimal/src/render/sky.ts +41 -0
- package/templates/minimal/src/scenes/Boot.ts +5 -0
- package/templates/minimal/src/scenes/Play.ts +65 -0
- package/templates/minimal/src/state.ts +1 -0
- package/templates/minimal/src/style.css +41 -0
- package/templates/minimal/threenative.config.ts +32 -0
- package/templates/minimal/tsconfig.json +16 -0
- package/templates/minimal/vite.config.ts +3 -0
- package/templates/platformer/.mcp.json +16 -0
- package/templates/platformer/AGENTS.md +199 -0
- package/templates/platformer/CLAUDE.md +201 -0
- package/templates/platformer/assets/.gitkeep +0 -0
- package/templates/platformer/index.html +13 -0
- package/templates/platformer/kit.json +7 -0
- package/templates/platformer/package.json +50 -0
- package/templates/platformer/playtests/avoidance.playtest.json +23 -0
- package/templates/platformer/playtests/buffer.playtest.json +17 -0
- package/templates/platformer/playtests/chase.playtest.json +21 -0
- package/templates/platformer/playtests/collect.playtest.json +56 -0
- package/templates/platformer/playtests/collision-layers.playtest.json +36 -0
- package/templates/platformer/playtests/coyote.playtest.json +21 -0
- package/templates/platformer/playtests/damage.playtest.json +31 -0
- package/templates/platformer/playtests/dash.playtest.json +21 -0
- package/templates/platformer/playtests/jump.playtest.json +21 -0
- package/templates/platformer/playtests/oneway.playtest.json +17 -0
- package/templates/platformer/playtests/patrol.playtest.json +13 -0
- package/templates/platformer/playtests/performance.playtest.json +21 -0
- package/templates/platformer/playtests/physics.playtest.json +14 -0
- package/templates/platformer/playtests/respawn.playtest.json +31 -0
- package/templates/platformer/playtests/stomp-rise.playtest.json +41 -0
- package/templates/platformer/playtests/stomp.playtest.json +34 -0
- package/templates/platformer/playtests/survives.playtest.json +32 -0
- package/templates/platformer/playtests/terminal-loop-fail.playtest.json +29 -0
- package/templates/platformer/playtests/terminal-loop-win.playtest.json +52 -0
- package/templates/platformer/public/.gitkeep +0 -0
- package/templates/platformer/public/favicon.svg +4 -0
- package/templates/platformer/public/icon.png +0 -0
- package/templates/platformer/src/entities/Character.ts +218 -0
- package/templates/platformer/src/entities/Chaser.ts +118 -0
- package/templates/platformer/src/entities/Patrol.ts +88 -0
- package/templates/platformer/src/entities/Pickup.ts +72 -0
- package/templates/platformer/src/game.ts +27 -0
- package/templates/platformer/src/level/Checkpoints.ts +66 -0
- package/templates/platformer/src/level/Platform.ts +34 -0
- package/templates/platformer/src/main.ts +14 -0
- package/templates/platformer/src/playtest-events.ts +15 -0
- package/templates/platformer/src/render/camera.ts +8 -0
- package/templates/platformer/src/render/lighting.ts +38 -0
- package/templates/platformer/src/render/loading.ts +113 -0
- package/templates/platformer/src/render/materials.ts +11 -0
- package/templates/platformer/src/render/palette.ts +54 -0
- package/templates/platformer/src/render/postprocessing.ts +18 -0
- package/templates/platformer/src/render/rig.ts +60 -0
- package/templates/platformer/src/render/sky.ts +47 -0
- package/templates/platformer/src/render/terrain.ts +31 -0
- package/templates/platformer/src/render/touch-controls.ts +157 -0
- package/templates/platformer/src/render/touch-layout.ts +63 -0
- package/templates/platformer/src/scenes/Boot.ts +12 -0
- package/templates/platformer/src/scenes/Level.ts +176 -0
- package/templates/platformer/src/state.ts +23 -0
- package/templates/platformer/src/style.css +31 -0
- package/templates/platformer/src/ui/App.tsx +17 -0
- package/templates/platformer/src/ui/Hud.tsx +41 -0
- package/templates/platformer/src/ui/Menu.tsx +7 -0
- package/templates/platformer/tailwind.config.ts +2 -0
- package/templates/platformer/threenative.config.ts +32 -0
- package/templates/platformer/tsconfig.json +17 -0
- package/templates/platformer/vite.config.ts +5 -0
- package/templates/racing/.mcp.json +16 -0
- package/templates/racing/AGENTS.md +48 -0
- package/templates/racing/CLAUDE.md +50 -0
- package/templates/racing/index.html +13 -0
- package/templates/racing/kit.json +7 -0
- package/templates/racing/package.json +46 -0
- package/templates/racing/playtests/boost.playtest.json +45 -0
- package/templates/racing/playtests/outcome.playtest.json +78 -0
- package/templates/racing/playtests/ranking.playtest.json +37 -0
- package/templates/racing/playtests/rescue.playtest.json +28 -0
- package/templates/racing/playtests/reverse.playtest.json +37 -0
- package/templates/racing/playtests/shortcut.playtest.json +44 -0
- package/templates/racing/playtests/survives.playtest.json +32 -0
- package/templates/racing/public/favicon.svg +6 -0
- package/templates/racing/src/entities/RacingCar.ts +114 -0
- package/templates/racing/src/entities/Rival.ts +46 -0
- package/templates/racing/src/game.ts +29 -0
- package/templates/racing/src/kart/boost.ts +38 -0
- package/templates/racing/src/main.ts +15 -0
- package/templates/racing/src/playtest-events.ts +15 -0
- package/templates/racing/src/render/camera.ts +28 -0
- package/templates/racing/src/render/lighting.ts +32 -0
- package/templates/racing/src/render/loading.ts +58 -0
- package/templates/racing/src/render/materials.ts +15 -0
- package/templates/racing/src/render/palette.ts +30 -0
- package/templates/racing/src/render/postprocessing.ts +14 -0
- package/templates/racing/src/render/shapes.ts +37 -0
- package/templates/racing/src/render/sky.ts +45 -0
- package/templates/racing/src/scenes/Boot.ts +12 -0
- package/templates/racing/src/scenes/Race.ts +180 -0
- package/templates/racing/src/state.ts +35 -0
- package/templates/racing/src/style.css +32 -0
- package/templates/racing/src/track/Checkline.ts +19 -0
- package/templates/racing/src/track/Lap.ts +104 -0
- package/templates/racing/src/track/Ranking.ts +35 -0
- package/templates/racing/src/track/Track.ts +229 -0
- package/templates/racing/src/track/TrackSector.ts +77 -0
- package/templates/racing/src/track/rescue.ts +21 -0
- package/templates/racing/src/ui/App.tsx +17 -0
- package/templates/racing/src/ui/Hud.tsx +71 -0
- package/templates/racing/src/ui/Menu.tsx +7 -0
- package/templates/racing/tailwind.config.ts +2 -0
- package/templates/racing/threenative.config.ts +29 -0
- package/templates/racing/tsconfig.json +17 -0
- package/templates/racing/vite.config.ts +5 -0
- package/templates/shooter/.mcp.json +16 -0
- package/templates/shooter/AGENTS.md +69 -0
- package/templates/shooter/CLAUDE.md +71 -0
- package/templates/shooter/index.html +13 -0
- package/templates/shooter/kit.json +7 -0
- package/templates/shooter/package.json +46 -0
- package/templates/shooter/playtests/fail.playtest.json +30 -0
- package/templates/shooter/playtests/shooter.playtest.json +89 -0
- package/templates/shooter/playtests/survives.playtest.json +32 -0
- package/templates/shooter/public/favicon.svg +4 -0
- package/templates/shooter/src/combat/damage.ts +41 -0
- package/templates/shooter/src/entities/Pickup.ts +70 -0
- package/templates/shooter/src/entities/Player.ts +93 -0
- package/templates/shooter/src/entities/Target.ts +103 -0
- package/templates/shooter/src/game.ts +36 -0
- package/templates/shooter/src/level/SpawnPoints.ts +28 -0
- package/templates/shooter/src/main.ts +26 -0
- package/templates/shooter/src/physics.ts +49 -0
- package/templates/shooter/src/playtest-events.ts +15 -0
- package/templates/shooter/src/render/camera.ts +29 -0
- package/templates/shooter/src/render/lighting.ts +38 -0
- package/templates/shooter/src/render/loading.ts +86 -0
- package/templates/shooter/src/render/materials.ts +38 -0
- package/templates/shooter/src/render/palette.ts +9 -0
- package/templates/shooter/src/render/postprocessing.ts +19 -0
- package/templates/shooter/src/render/shapes.ts +194 -0
- package/templates/shooter/src/render/sky.ts +37 -0
- package/templates/shooter/src/render/types.ts +3 -0
- package/templates/shooter/src/render/ui.css +212 -0
- package/templates/shooter/src/render/ui.ts +59 -0
- package/templates/shooter/src/scenes/Boot.ts +12 -0
- package/templates/shooter/src/scenes/Play.ts +428 -0
- package/templates/shooter/src/state.ts +29 -0
- package/templates/shooter/src/ui/App.tsx +25 -0
- package/templates/shooter/src/ui/Hud.tsx +49 -0
- package/templates/shooter/src/ui/Menu.tsx +26 -0
- package/templates/shooter/src/waves.ts +50 -0
- package/templates/shooter/src/weapons/Hitscan.ts +43 -0
- package/templates/shooter/src/weapons/Projectile.ts +76 -0
- package/templates/shooter/tailwind.config.ts +5 -0
- package/templates/shooter/threenative.config.ts +29 -0
- package/templates/shooter/tsconfig.json +17 -0
- package/templates/shooter/vite.config.ts +8 -0
- package/templates/starter/.mcp.json +16 -0
- package/templates/starter/AGENTS.md +450 -0
- package/templates/starter/CLAUDE.md +452 -0
- package/templates/starter/assets/.gitkeep +0 -0
- package/templates/starter/index.html +13 -0
- package/templates/starter/kit.json +7 -0
- package/templates/starter/package.json +49 -0
- package/templates/starter/playtests/buffer.playtest.json +29 -0
- package/templates/starter/playtests/coyote.playtest.json +35 -0
- package/templates/starter/playtests/forward.playtest.json +15 -0
- package/templates/starter/playtests/hot-reload.playtest.json +28 -0
- package/templates/starter/playtests/look.playtest.json +43 -0
- package/templates/starter/playtests/monitoring.playtest.json +41 -0
- package/templates/starter/playtests/pause.playtest.json +33 -0
- package/templates/starter/playtests/play.playtest.json +16 -0
- package/templates/starter/playtests/respawn.playtest.json +28 -0
- package/templates/starter/playtests/restart.playtest.json +36 -0
- package/templates/starter/playtests/seed.playtest.json +18 -0
- package/templates/starter/playtests/survives.playtest.json +32 -0
- package/templates/starter/public/.gitkeep +0 -0
- package/templates/starter/public/favicon.svg +4 -0
- package/templates/starter/public/icon.png +0 -0
- package/templates/starter/public/native-proof.glb +0 -0
- package/templates/starter/public/native-proof.png +0 -0
- package/templates/starter/public/pickup.ogg +0 -0
- package/templates/starter/src/entities/Crate.ts +34 -0
- package/templates/starter/src/entities/Player.ts +80 -0
- package/templates/starter/src/game.ts +30 -0
- package/templates/starter/src/main.ts +15 -0
- package/templates/starter/src/render/camera.ts +57 -0
- package/templates/starter/src/render/lighting.ts +55 -0
- package/templates/starter/src/render/materials.ts +12 -0
- package/templates/starter/src/render/palette.ts +9 -0
- package/templates/starter/src/render/postprocessing.ts +18 -0
- package/templates/starter/src/render/shapes.ts +147 -0
- package/templates/starter/src/render/sky.ts +56 -0
- package/templates/starter/src/scenes/Play.ts +161 -0
- package/templates/starter/src/state.ts +10 -0
- package/templates/starter/src/style.css +45 -0
- package/templates/starter/src/ui/App.tsx +19 -0
- package/templates/starter/src/ui/Hud.tsx +37 -0
- package/templates/starter/src/ui/Menu.tsx +43 -0
- package/templates/starter/tailwind.config.ts +2 -0
- package/templates/starter/threenative.config.ts +31 -0
- package/templates/starter/tsconfig.json +17 -0
- package/templates/starter/vite.config.ts +8 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "platformer-coyote",
|
|
3
|
+
"schemaVersion": 1,
|
|
4
|
+
"target": "web",
|
|
5
|
+
"viewport": { "width": 1280, "height": 720 },
|
|
6
|
+
"warmupFrames": 10,
|
|
7
|
+
"subject": "player",
|
|
8
|
+
"steps": [
|
|
9
|
+
{ "kind": "input", "press": "ArrowRight", "holdTicks": 92, "release": true },
|
|
10
|
+
{ "kind": "wait", "waitTicks": 8, "release": true },
|
|
11
|
+
{ "kind": "input", "press": "Space", "holdTicks": 2, "release": true },
|
|
12
|
+
{ "kind": "wait", "waitTicks": 20, "release": true }
|
|
13
|
+
],
|
|
14
|
+
"assert": {
|
|
15
|
+
"diagnostics": { "noConsoleErrors": true, "runtimeReady": true },
|
|
16
|
+
"resources": [
|
|
17
|
+
{ "id": "GameState", "path": "jumps", "gte": 1, "changed": true },
|
|
18
|
+
{ "id": "GameState", "path": "coyoteJumps", "gte": 1, "changed": true }
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "platformer-damage",
|
|
3
|
+
"schemaVersion": 1,
|
|
4
|
+
"target": "web",
|
|
5
|
+
"viewport": { "width": 1280, "height": 720 },
|
|
6
|
+
"warmupFrames": 10,
|
|
7
|
+
"subject": "player",
|
|
8
|
+
"steps": [
|
|
9
|
+
{ "kind": "input", "press": "ArrowRight", "holdTicks": 16, "release": true },
|
|
10
|
+
{
|
|
11
|
+
"kind": "input",
|
|
12
|
+
"press": ["ArrowRight", "Space"],
|
|
13
|
+
"holdTicks": 30,
|
|
14
|
+
"release": true
|
|
15
|
+
},
|
|
16
|
+
{ "kind": "wait", "waitTicks": 16, "release": true },
|
|
17
|
+
{
|
|
18
|
+
"kind": "input",
|
|
19
|
+
"label": "enemy-contact",
|
|
20
|
+
"press": "ArrowRight",
|
|
21
|
+
"holdTicks": 20,
|
|
22
|
+
"release": true
|
|
23
|
+
},
|
|
24
|
+
{ "kind": "wait", "label": "damage-settled", "waitTicks": 10, "release": true }
|
|
25
|
+
],
|
|
26
|
+
"assert": {
|
|
27
|
+
"diagnostics": { "noConsoleErrors": true, "runtimeReady": true },
|
|
28
|
+
"resources": [{ "id": "GameState", "path": "topSpeed", "gte": 1, "changed": true }],
|
|
29
|
+
"components": [{ "entity": "player", "component": "health", "equals": 2, "changed": true }]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "platformer-dash",
|
|
3
|
+
"schemaVersion": 1,
|
|
4
|
+
"target": "web",
|
|
5
|
+
"viewport": { "width": 1280, "height": 720 },
|
|
6
|
+
"warmupFrames": 10,
|
|
7
|
+
"subject": "player",
|
|
8
|
+
"steps": [
|
|
9
|
+
{ "kind": "input", "press": "ArrowRight", "holdTicks": 18, "release": false },
|
|
10
|
+
{ "kind": "input", "press": "ShiftLeft", "holdTicks": 6, "release": true },
|
|
11
|
+
{ "kind": "wait", "waitTicks": 20, "release": true }
|
|
12
|
+
],
|
|
13
|
+
"assert": {
|
|
14
|
+
"diagnostics": { "noConsoleErrors": true, "runtimeReady": true },
|
|
15
|
+
"movement": { "entity": "player", "minAxisDelta": { "axis": "+x", "min": 2.5 } },
|
|
16
|
+
"resources": [
|
|
17
|
+
{ "id": "GameState", "path": "dashes", "gte": 1, "changed": true },
|
|
18
|
+
{ "id": "GameState", "path": "topSpeed", "gte": 12, "changed": true }
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "platformer-jump",
|
|
3
|
+
"schemaVersion": 1,
|
|
4
|
+
"target": "web",
|
|
5
|
+
"viewport": { "width": 1280, "height": 720 },
|
|
6
|
+
"warmupFrames": 10,
|
|
7
|
+
"subject": "player",
|
|
8
|
+
"steps": [
|
|
9
|
+
{ "kind": "input", "press": "Space", "holdTicks": 4, "release": true },
|
|
10
|
+
{ "kind": "wait", "waitTicks": 14, "release": true }
|
|
11
|
+
],
|
|
12
|
+
"assert": {
|
|
13
|
+
"diagnostics": { "noConsoleErrors": true, "runtimeReady": true },
|
|
14
|
+
"performance": {},
|
|
15
|
+
"movement": { "entity": "player", "minAxisDelta": { "axis": "+y", "min": 1.5 } },
|
|
16
|
+
"resources": [
|
|
17
|
+
{ "id": "GameState", "path": "jumps", "gte": 1, "changed": true },
|
|
18
|
+
{ "id": "GameState", "path": "peakRise", "gte": 1.5, "changed": true }
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "platformer-one-way",
|
|
3
|
+
"schemaVersion": 1,
|
|
4
|
+
"target": "web",
|
|
5
|
+
"viewport": { "width": 1280, "height": 720 },
|
|
6
|
+
"warmupFrames": 10,
|
|
7
|
+
"subject": "player",
|
|
8
|
+
"steps": [
|
|
9
|
+
{ "kind": "input", "press": "Space", "holdTicks": 4, "release": true },
|
|
10
|
+
{ "kind": "wait", "waitTicks": 100, "release": true }
|
|
11
|
+
],
|
|
12
|
+
"assert": {
|
|
13
|
+
"diagnostics": { "noConsoleErrors": true, "runtimeReady": true },
|
|
14
|
+
"movement": { "entity": "player", "minAxisDelta": { "axis": "+y", "min": 1.5 } },
|
|
15
|
+
"resources": [{ "id": "GameState", "path": "peakRise", "gte": 1.5, "changed": true }]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "platformer-patrol",
|
|
3
|
+
"schemaVersion": 1,
|
|
4
|
+
"target": "web",
|
|
5
|
+
"viewport": { "width": 1280, "height": 720 },
|
|
6
|
+
"warmupFrames": 10,
|
|
7
|
+
"subject": "patrol",
|
|
8
|
+
"steps": [{ "kind": "wait", "waitTicks": 100, "release": true }],
|
|
9
|
+
"assert": {
|
|
10
|
+
"diagnostics": { "noConsoleErrors": true, "runtimeReady": true },
|
|
11
|
+
"movement": { "entity": "patrol", "pathLength": 2.2 }
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"acceptanceId": "prd-064-performance",
|
|
3
|
+
"artifacts": { "screenshots": "after" },
|
|
4
|
+
"assert": {
|
|
5
|
+
"performance": {
|
|
6
|
+
"maxDrawCalls": 180,
|
|
7
|
+
"maxFrameMsP95": 33,
|
|
8
|
+
"maxTriangles": 100000
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"name": "production-performance",
|
|
12
|
+
"schemaVersion": 1,
|
|
13
|
+
"steps": [
|
|
14
|
+
{ "kind": "input", "press": "ArrowRight", "holdFrames": 60, "release": true },
|
|
15
|
+
{ "kind": "wait", "waitFrames": 600, "release": true }
|
|
16
|
+
],
|
|
17
|
+
"subject": "player",
|
|
18
|
+
"target": "web",
|
|
19
|
+
"viewport": { "height": 1080, "width": 1920 },
|
|
20
|
+
"warmupFrames": 60
|
|
21
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "platformer-physics-settled",
|
|
3
|
+
"schemaVersion": 1,
|
|
4
|
+
"target": "web",
|
|
5
|
+
"viewport": { "width": 1280, "height": 720 },
|
|
6
|
+
"warmupFrames": 10,
|
|
7
|
+
"subject": "crate",
|
|
8
|
+
"artifacts": { "screenshots": false },
|
|
9
|
+
"steps": [{ "kind": "wait", "label": "settled", "waitTicks": 240, "release": true }],
|
|
10
|
+
"assert": {
|
|
11
|
+
"diagnostics": { "noConsoleErrors": true, "runtimeReady": true },
|
|
12
|
+
"settled": [{ "atStep": "settled", "entity": "crate", "minBodies": 1 }]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "platformer-respawn",
|
|
3
|
+
"schemaVersion": 1,
|
|
4
|
+
"target": "web",
|
|
5
|
+
"viewport": { "width": 1280, "height": 720 },
|
|
6
|
+
"warmupFrames": 10,
|
|
7
|
+
"subject": "player",
|
|
8
|
+
"steps": [
|
|
9
|
+
{ "kind": "input", "press": "ArrowRight", "holdTicks": 16, "release": true },
|
|
10
|
+
{
|
|
11
|
+
"kind": "input",
|
|
12
|
+
"press": ["ArrowRight", "Space"],
|
|
13
|
+
"holdTicks": 30,
|
|
14
|
+
"release": true
|
|
15
|
+
},
|
|
16
|
+
{ "kind": "wait", "waitTicks": 16, "release": true },
|
|
17
|
+
{ "kind": "input", "press": "ArrowRight", "holdTicks": 170, "release": true },
|
|
18
|
+
{ "kind": "wait", "waitTicks": 100, "release": true }
|
|
19
|
+
],
|
|
20
|
+
"assert": {
|
|
21
|
+
"diagnostics": { "noConsoleErrors": true, "runtimeReady": true },
|
|
22
|
+
"movement": {
|
|
23
|
+
"entity": "player",
|
|
24
|
+
"reachesPositionWithin": { "position": [14, 0.75, 0], "maxDistance": 2 }
|
|
25
|
+
},
|
|
26
|
+
"resources": [
|
|
27
|
+
{ "id": "GameState", "path": "checkpoint", "equals": 1, "changed": true },
|
|
28
|
+
{ "id": "GameState", "path": "respawns", "gte": 1, "changed": true }
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "platformer-stomp-rise",
|
|
3
|
+
"schemaVersion": 1,
|
|
4
|
+
"target": "web",
|
|
5
|
+
"viewport": { "width": 1280, "height": 720 },
|
|
6
|
+
"warmupFrames": 10,
|
|
7
|
+
"subject": "player",
|
|
8
|
+
"steps": [
|
|
9
|
+
{ "kind": "input", "press": "ArrowRight", "holdTicks": 16, "release": true },
|
|
10
|
+
{
|
|
11
|
+
"kind": "input",
|
|
12
|
+
"press": ["ArrowRight", "Space"],
|
|
13
|
+
"holdTicks": 30,
|
|
14
|
+
"release": true
|
|
15
|
+
},
|
|
16
|
+
{ "kind": "wait", "waitTicks": 16, "release": true },
|
|
17
|
+
{
|
|
18
|
+
"kind": "input",
|
|
19
|
+
"label": "enemy-contact",
|
|
20
|
+
"press": "ArrowRight",
|
|
21
|
+
"holdTicks": 20,
|
|
22
|
+
"release": true
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"kind": "input",
|
|
26
|
+
"label": "rise-after-contact",
|
|
27
|
+
"press": "Space",
|
|
28
|
+
"holdTicks": 4,
|
|
29
|
+
"release": true
|
|
30
|
+
},
|
|
31
|
+
{ "kind": "wait", "label": "damage-settled", "waitTicks": 10, "release": true }
|
|
32
|
+
],
|
|
33
|
+
"assert": {
|
|
34
|
+
"diagnostics": { "noConsoleErrors": true, "runtimeReady": true },
|
|
35
|
+
"resources": [
|
|
36
|
+
{ "id": "GameState", "path": "hearts", "equals": 2, "changed": true },
|
|
37
|
+
{ "id": "GameState", "path": "defeated", "equals": 0, "allowTrivial": true }
|
|
38
|
+
],
|
|
39
|
+
"tags": [{ "tag": "patrol", "count": 1 }]
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "platformer-stomp",
|
|
3
|
+
"schemaVersion": 1,
|
|
4
|
+
"target": "web",
|
|
5
|
+
"viewport": { "width": 1280, "height": 720 },
|
|
6
|
+
"warmupFrames": 10,
|
|
7
|
+
"subject": "player",
|
|
8
|
+
"steps": [
|
|
9
|
+
{
|
|
10
|
+
"kind": "input",
|
|
11
|
+
"label": "near-patrol",
|
|
12
|
+
"press": "ArrowRight",
|
|
13
|
+
"holdTicks": 28,
|
|
14
|
+
"release": true
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"kind": "input",
|
|
18
|
+
"label": "jump",
|
|
19
|
+
"press": ["ArrowRight", "Space"],
|
|
20
|
+
"holdTicks": 42,
|
|
21
|
+
"release": true
|
|
22
|
+
},
|
|
23
|
+
{ "kind": "wait", "label": "stomp-settled", "waitTicks": 45, "release": true }
|
|
24
|
+
],
|
|
25
|
+
"assert": {
|
|
26
|
+
"diagnostics": { "noConsoleErrors": true, "runtimeReady": true },
|
|
27
|
+
"resources": [
|
|
28
|
+
{ "id": "GameState", "path": "defeated", "gte": 1, "changed": true },
|
|
29
|
+
{ "id": "GameState", "path": "jumps", "gte": 1, "changed": true },
|
|
30
|
+
{ "id": "GameState", "path": "hearts", "equals": 3, "allowTrivial": true }
|
|
31
|
+
],
|
|
32
|
+
"tags": [{ "tag": "patrol", "count": 0 }]
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "survives",
|
|
3
|
+
"target": "web",
|
|
4
|
+
"schemaVersion": 1,
|
|
5
|
+
"viewport": { "width": 1280, "height": 720 },
|
|
6
|
+
"warmupFrames": 10,
|
|
7
|
+
"subject": "player",
|
|
8
|
+
"steps": [
|
|
9
|
+
{ "kind": "input", "label": "move", "press": "ArrowUp", "holdTicks": 60, "release": true },
|
|
10
|
+
{ "kind": "wait", "label": "settle", "waitTicks": 10, "release": true }
|
|
11
|
+
],
|
|
12
|
+
"assert": {
|
|
13
|
+
"diagnostics": {
|
|
14
|
+
"noConsoleErrors": true,
|
|
15
|
+
"noNetworkErrors": true,
|
|
16
|
+
"noRuntimeDiagnostics": true,
|
|
17
|
+
"runtimeReady": true
|
|
18
|
+
},
|
|
19
|
+
"movement": { "entity": "player", "minDistance": 0.5 },
|
|
20
|
+
"visual": [
|
|
21
|
+
{
|
|
22
|
+
"region": {
|
|
23
|
+
"x": 0,
|
|
24
|
+
"y": 0,
|
|
25
|
+
"width": 1280,
|
|
26
|
+
"height": 720,
|
|
27
|
+
"minNonblankPixelRatio": 0.01
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "platformer-terminal-loop-fail",
|
|
3
|
+
"schemaVersion": 1,
|
|
4
|
+
"target": "web",
|
|
5
|
+
"viewport": { "width": 1280, "height": 720 },
|
|
6
|
+
"warmupFrames": 10,
|
|
7
|
+
"subject": "player",
|
|
8
|
+
"steps": [
|
|
9
|
+
{ "kind": "input", "press": "ArrowRight", "holdTicks": 45, "release": true },
|
|
10
|
+
{ "kind": "wait", "waitTicks": 80, "release": true },
|
|
11
|
+
{ "kind": "input", "press": "ArrowLeft", "holdTicks": 50, "release": true },
|
|
12
|
+
{ "kind": "wait", "waitTicks": 80, "release": true },
|
|
13
|
+
{ "kind": "input", "press": "ArrowRight", "holdTicks": 80, "release": true },
|
|
14
|
+
{ "kind": "wait", "waitTicks": 80, "release": true },
|
|
15
|
+
{ "kind": "input", "press": "ArrowLeft", "holdTicks": 80, "release": true },
|
|
16
|
+
{ "kind": "wait", "waitTicks": 80, "release": true },
|
|
17
|
+
{ "kind": "input", "press": "ArrowRight", "holdTicks": 80, "release": true },
|
|
18
|
+
{ "kind": "wait", "label": "fail-settled", "waitTicks": 80, "release": true }
|
|
19
|
+
],
|
|
20
|
+
"assert": {
|
|
21
|
+
"diagnostics": { "noConsoleErrors": true, "runtimeReady": true },
|
|
22
|
+
"resources": [
|
|
23
|
+
{ "id": "GameState", "path": "terminal", "equals": 2, "changed": true },
|
|
24
|
+
{ "id": "GameState", "path": "hearts", "equals": 0, "changed": true },
|
|
25
|
+
{ "id": "GameState", "path": "respawns", "equals": 0, "allowTrivial": true }
|
|
26
|
+
],
|
|
27
|
+
"signals": [{ "entity": "game", "name": "lost", "minCount": 1 }]
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "platformer-terminal-loop-win",
|
|
3
|
+
"schemaVersion": 1,
|
|
4
|
+
"target": "web",
|
|
5
|
+
"viewport": { "width": 1280, "height": 720 },
|
|
6
|
+
"warmupFrames": 10,
|
|
7
|
+
"subject": "player",
|
|
8
|
+
"steps": [
|
|
9
|
+
{ "kind": "input", "press": "ArrowRight", "holdTicks": 16, "release": true },
|
|
10
|
+
{
|
|
11
|
+
"kind": "input",
|
|
12
|
+
"press": ["ArrowRight", "Space"],
|
|
13
|
+
"holdTicks": 30,
|
|
14
|
+
"release": true
|
|
15
|
+
},
|
|
16
|
+
{ "kind": "wait", "waitTicks": 16, "release": true },
|
|
17
|
+
{
|
|
18
|
+
"kind": "input",
|
|
19
|
+
"press": "ArrowRight",
|
|
20
|
+
"holdTicks": 170,
|
|
21
|
+
"release": true
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"kind": "input",
|
|
25
|
+
"label": "jump-final",
|
|
26
|
+
"press": ["ArrowRight", "Space"],
|
|
27
|
+
"holdTicks": 30,
|
|
28
|
+
"release": true
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"kind": "input",
|
|
32
|
+
"label": "reach-goal",
|
|
33
|
+
"press": "ArrowRight",
|
|
34
|
+
"holdTicks": 80,
|
|
35
|
+
"release": true
|
|
36
|
+
},
|
|
37
|
+
{ "kind": "wait", "label": "win-settled", "waitTicks": 20, "release": true }
|
|
38
|
+
],
|
|
39
|
+
"assert": {
|
|
40
|
+
"diagnostics": { "noConsoleErrors": true, "runtimeReady": true },
|
|
41
|
+
"resources": [
|
|
42
|
+
{ "id": "GameState", "path": "terminal", "equals": 1, "changed": true },
|
|
43
|
+
{
|
|
44
|
+
"id": "GameState",
|
|
45
|
+
"path": "grounded",
|
|
46
|
+
"atSteps": [{ "label": "reach-goal", "equals": true }]
|
|
47
|
+
},
|
|
48
|
+
{ "id": "GameState", "path": "playerX", "gte": 21.5, "changed": true }
|
|
49
|
+
],
|
|
50
|
+
"signals": [{ "entity": "game", "name": "won", "minCount": 1 }]
|
|
51
|
+
}
|
|
52
|
+
}
|
|
File without changes
|
|
Binary file
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import type { ICtx } from "@threenative/core";
|
|
2
|
+
import { CharacterBody3D, CollisionShape3D, type IPhysicsContext } from "@threenative/physics";
|
|
3
|
+
import { Group, Vector3 } from "three";
|
|
4
|
+
import { ONE_WAY_LAYER } from "../level/Platform.js";
|
|
5
|
+
import { animateCharacter, createCharacterRig } from "../render/rig.js";
|
|
6
|
+
import type { ITouchInput } from "../render/touch-layout.js";
|
|
7
|
+
import type { GameState } from "../state.js";
|
|
8
|
+
type GameCtx = ICtx<GameState, IPhysicsContext>;
|
|
9
|
+
export const PLAYER_LAYER = 1;
|
|
10
|
+
export const PLATFORMER_FEEL = {
|
|
11
|
+
airAcceleration: 24,
|
|
12
|
+
blinkRate: 18,
|
|
13
|
+
coyoteTime: 0.12,
|
|
14
|
+
dashCooldown: 0.55,
|
|
15
|
+
dashSpeed: 17,
|
|
16
|
+
dashTime: 0.18,
|
|
17
|
+
gravity: -28,
|
|
18
|
+
groundAcceleration: 58,
|
|
19
|
+
hurtHorizontalSpeed: 4.5,
|
|
20
|
+
hurtVerticalSpeed: 5.5,
|
|
21
|
+
invulnerabilityTime: 1.2,
|
|
22
|
+
jumpBuffer: 0.14,
|
|
23
|
+
jumpSpeed: 11,
|
|
24
|
+
maxFallSpeed: 32,
|
|
25
|
+
patrolSpeed: 1.6,
|
|
26
|
+
runSpeed: 6.2,
|
|
27
|
+
stompBounce: 9,
|
|
28
|
+
stompFallSpeed: -0.5,
|
|
29
|
+
stompHeight: 0.3,
|
|
30
|
+
} as const;
|
|
31
|
+
|
|
32
|
+
export type CharacterState = "dash" | "fall" | "hurt" | "idle" | "jump" | "run";
|
|
33
|
+
|
|
34
|
+
export class Character {
|
|
35
|
+
readonly mesh: Group;
|
|
36
|
+
readonly body: CharacterBody3D;
|
|
37
|
+
readonly visual: Group;
|
|
38
|
+
readonly tags = ["player"];
|
|
39
|
+
state: CharacterState = "idle";
|
|
40
|
+
coyoteJumps = 0;
|
|
41
|
+
health = 3;
|
|
42
|
+
jumps = 0;
|
|
43
|
+
dashes = 0;
|
|
44
|
+
#rig: ReturnType<typeof createCharacterRig>;
|
|
45
|
+
#facing = Math.PI / 2;
|
|
46
|
+
#coyote = 0;
|
|
47
|
+
#buffered = 0;
|
|
48
|
+
#dashTimer = 0;
|
|
49
|
+
#dashCooldown = 0;
|
|
50
|
+
#airJumpUsed = false;
|
|
51
|
+
#time = 0;
|
|
52
|
+
#dashDirection = new Vector3(1, 0, 0);
|
|
53
|
+
|
|
54
|
+
constructor(ctx: GameCtx, spawn: Vector3) {
|
|
55
|
+
this.mesh = new Group();
|
|
56
|
+
this.mesh.position.copy(spawn);
|
|
57
|
+
ctx.add(this.mesh);
|
|
58
|
+
this.#rig = createCharacterRig();
|
|
59
|
+
this.visual = this.#rig.root;
|
|
60
|
+
this.visual.position.y = -0.72;
|
|
61
|
+
this.mesh.add(this.visual);
|
|
62
|
+
this.body = new CharacterBody3D({
|
|
63
|
+
autostep: { maxHeight: 0.35, minWidth: 0.2 },
|
|
64
|
+
collisionLayer: PLAYER_LAYER,
|
|
65
|
+
collisionMask: 0xfffb,
|
|
66
|
+
entity: "player",
|
|
67
|
+
gravity: PLATFORMER_FEEL.gravity,
|
|
68
|
+
maxFallSpeed: PLATFORMER_FEEL.maxFallSpeed,
|
|
69
|
+
object: this.mesh,
|
|
70
|
+
oneWayLayers: ONE_WAY_LAYER,
|
|
71
|
+
physics: ctx.physics,
|
|
72
|
+
shape: CollisionShape3D.capsule(0.35, 0.3),
|
|
73
|
+
snapToGround: 0.25,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
update(ctx: GameCtx, dt: number, touch?: ITouchInput): void {
|
|
78
|
+
this.#time += dt;
|
|
79
|
+
this.#dashTimer = Math.max(0, this.#dashTimer - dt);
|
|
80
|
+
this.#dashCooldown = Math.max(0, this.#dashCooldown - dt);
|
|
81
|
+
this.#coyote = Math.max(0, this.#coyote - dt);
|
|
82
|
+
this.#buffered = Math.max(0, this.#buffered - dt);
|
|
83
|
+
const move = ctx.input.vector("move");
|
|
84
|
+
if (touch !== undefined) move.add(touch.move).clampLength(0, 1);
|
|
85
|
+
const wants = new Vector3(move.x, 0, -move.y);
|
|
86
|
+
if (wants.lengthSq() > 1) wants.normalize();
|
|
87
|
+
if (this.body.grounded) {
|
|
88
|
+
this.#coyote = PLATFORMER_FEEL.coyoteTime;
|
|
89
|
+
this.#airJumpUsed = false;
|
|
90
|
+
}
|
|
91
|
+
if (ctx.input.justPressed("jump") || touch?.jumpPressed === true)
|
|
92
|
+
this.#buffered = PLATFORMER_FEEL.jumpBuffer;
|
|
93
|
+
if (
|
|
94
|
+
(ctx.input.justPressed("dash") || touch?.dashPressed === true) &&
|
|
95
|
+
this.#dashCooldown <= 0 &&
|
|
96
|
+
this.#dashTimer <= 0
|
|
97
|
+
)
|
|
98
|
+
this.#startDash(wants);
|
|
99
|
+
|
|
100
|
+
if (this.#dashTimer > 0) this.#driveDash();
|
|
101
|
+
else this.#driveWalk(wants, dt);
|
|
102
|
+
this.#tryJump();
|
|
103
|
+
this.body.moveAndSlide(dt);
|
|
104
|
+
this.#face(dt);
|
|
105
|
+
this.#applyState();
|
|
106
|
+
animateCharacter(this.#rig, this.state, this.#time, this.body.velocity.x);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
bounce(): void {
|
|
110
|
+
this.body.velocity.y = PLATFORMER_FEEL.stompBounce;
|
|
111
|
+
this.#coyote = 0;
|
|
112
|
+
this.#buffered = 0;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
respawn(position: Vector3): void {
|
|
116
|
+
this.body.teleport(position);
|
|
117
|
+
this.#dashTimer = 0;
|
|
118
|
+
this.#dashCooldown = 0;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
debug(): Record<string, unknown> {
|
|
122
|
+
return {
|
|
123
|
+
dashes: this.dashes,
|
|
124
|
+
grounded: this.body.grounded,
|
|
125
|
+
health: this.health,
|
|
126
|
+
jumps: this.jumps,
|
|
127
|
+
position: this.mesh.position.toArray(),
|
|
128
|
+
state: this.state,
|
|
129
|
+
velocity: this.body.velocity.toArray(),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
dispose(): void {
|
|
134
|
+
this.body.dispose();
|
|
135
|
+
this.mesh.removeFromParent();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
#tryJump(): void {
|
|
139
|
+
if (this.#buffered <= 0) return;
|
|
140
|
+
if (this.#coyote > 0) {
|
|
141
|
+
this.body.velocity.y = PLATFORMER_FEEL.jumpSpeed;
|
|
142
|
+
this.#buffered = 0;
|
|
143
|
+
this.#coyote = 0;
|
|
144
|
+
this.coyoteJumps += 1;
|
|
145
|
+
this.jumps += 1;
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (!this.#airJumpUsed) {
|
|
149
|
+
this.body.velocity.y = PLATFORMER_FEEL.jumpSpeed;
|
|
150
|
+
this.#buffered = 0;
|
|
151
|
+
this.#airJumpUsed = true;
|
|
152
|
+
this.jumps += 1;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
#startDash(wants: Vector3): void {
|
|
157
|
+
this.#dashDirection.copy(
|
|
158
|
+
wants.lengthSq() > 0.01
|
|
159
|
+
? wants
|
|
160
|
+
: new Vector3(Math.sin(this.#facing), 0, Math.cos(this.#facing)),
|
|
161
|
+
);
|
|
162
|
+
this.#dashTimer = PLATFORMER_FEEL.dashTime;
|
|
163
|
+
this.#dashCooldown = PLATFORMER_FEEL.dashCooldown;
|
|
164
|
+
this.dashes += 1;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
#driveDash(): void {
|
|
168
|
+
this.body.velocity.set(
|
|
169
|
+
this.#dashDirection.x * PLATFORMER_FEEL.dashSpeed,
|
|
170
|
+
0,
|
|
171
|
+
this.#dashDirection.z * PLATFORMER_FEEL.dashSpeed,
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
#driveWalk(wants: Vector3, dt: number): void {
|
|
176
|
+
const acceleration = this.body.grounded
|
|
177
|
+
? PLATFORMER_FEEL.groundAcceleration
|
|
178
|
+
: PLATFORMER_FEEL.airAcceleration;
|
|
179
|
+
this.body.velocity.x = approach(
|
|
180
|
+
this.body.velocity.x,
|
|
181
|
+
wants.x * PLATFORMER_FEEL.runSpeed,
|
|
182
|
+
acceleration * dt,
|
|
183
|
+
);
|
|
184
|
+
this.body.velocity.z = approach(
|
|
185
|
+
this.body.velocity.z,
|
|
186
|
+
wants.z * PLATFORMER_FEEL.runSpeed,
|
|
187
|
+
acceleration * dt,
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
#face(dt: number): void {
|
|
192
|
+
const horizontal = Math.hypot(this.body.velocity.x, this.body.velocity.z);
|
|
193
|
+
if (horizontal < 0.1) return;
|
|
194
|
+
const target = Math.atan2(this.body.velocity.x, this.body.velocity.z);
|
|
195
|
+
this.#facing +=
|
|
196
|
+
(((target - this.#facing + Math.PI) % (Math.PI * 2)) - Math.PI) * (1 - Math.exp(-14 * dt));
|
|
197
|
+
this.visual.rotation.y = this.#facing;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
#applyState(): void {
|
|
201
|
+
const speed = Math.hypot(this.body.velocity.x, this.body.velocity.z);
|
|
202
|
+
this.state =
|
|
203
|
+
this.#dashTimer > 0
|
|
204
|
+
? "dash"
|
|
205
|
+
: !this.body.grounded
|
|
206
|
+
? this.body.velocity.y > 0.2
|
|
207
|
+
? "jump"
|
|
208
|
+
: "fall"
|
|
209
|
+
: speed > 0.6
|
|
210
|
+
? "run"
|
|
211
|
+
: "idle";
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function approach(current: number, target: number, maxDelta: number): number {
|
|
216
|
+
const delta = target - current;
|
|
217
|
+
return Math.abs(delta) <= maxDelta ? target : current + Math.sign(delta) * maxDelta;
|
|
218
|
+
}
|