@origingame/create-game 0.0.0-stage → 0.1.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 +57 -2
- package/archetypes/README.md +99 -0
- package/archetypes/idle/.origin/setup +14 -0
- package/archetypes/idle/LICENSES.md +12 -0
- package/archetypes/idle/README.md +234 -0
- package/archetypes/idle/assets/audio/buy.wav +0 -0
- package/archetypes/idle/assets/audio/milestone.wav +0 -0
- package/archetypes/idle/assets/audio/nova.wav +0 -0
- package/archetypes/idle/assets/audio/orbit.wav +0 -0
- package/archetypes/idle/assets/audio/tap.wav +0 -0
- package/archetypes/idle/assets/audio/ui-close.ogt +9 -0
- package/archetypes/idle/assets/audio/ui-error.ogt +9 -0
- package/archetypes/idle/assets/audio/ui-open.ogt +9 -0
- package/archetypes/idle/assets/audio/ui-press.ogt +9 -0
- package/archetypes/idle/assets/audio/ui-success.ogt +9 -0
- package/archetypes/idle/assets/fonts/NotoSansSC-subset.ttf +0 -0
- package/archetypes/idle/assets/fonts/NotoSansSC-subset.ttf.ogt +10 -0
- package/archetypes/idle/assets/fonts/OFL.txt +93 -0
- package/archetypes/idle/assets/fx/drift.ogt +21 -0
- package/archetypes/idle/assets/fx/milestone.ogt +21 -0
- package/archetypes/idle/assets/fx/nova.ogt +22 -0
- package/archetypes/idle/assets/fx/stars.ogt +20 -0
- package/archetypes/idle/assets/fx/tap.ogt +23 -0
- package/archetypes/idle/assets/looks/idle.ogt +17 -0
- package/archetypes/idle/assets/skins/sparkorb/ChakraPetch-BoldItalic.ttf +0 -0
- package/archetypes/idle/assets/skins/sparkorb/ChakraPetch-BoldItalic.ttf.ogt +9 -0
- package/archetypes/idle/assets/skins/sparkorb/LICENSES.md +19 -0
- package/archetypes/idle/assets/skins/sparkorb/OFL.txt +95 -0
- package/archetypes/idle/assets/skins/sparkorb/Orbitron-Medium.ttf +0 -0
- package/archetypes/idle/assets/skins/sparkorb/Orbitron-Medium.ttf.ogt +9 -0
- package/archetypes/idle/assets/skins/sparkorb/Rajdhani-Bold.ttf +0 -0
- package/archetypes/idle/assets/skins/sparkorb/Rajdhani-Bold.ttf.ogt +9 -0
- package/archetypes/idle/assets/skins/sparkorb/atlas.png +0 -0
- package/archetypes/idle/assets/skins/sparkorb/atlas.png.ogt +7 -0
- package/archetypes/idle/assets/skins/sparkorb/icons.png +0 -0
- package/archetypes/idle/assets/skins/sparkorb/icons.png.ogt +7 -0
- package/archetypes/idle/assets/skins/sparkorb/skin.ogt +113 -0
- package/archetypes/idle/assets/sprites/glow.png +0 -0
- package/archetypes/idle/assets/sprites/glow.png.ogt +8 -0
- package/archetypes/idle/assets/sprites/mote-crystal.png +0 -0
- package/archetypes/idle/assets/sprites/mote-crystal.png.ogt +7 -0
- package/archetypes/idle/assets/sprites/mote-ember.png +0 -0
- package/archetypes/idle/assets/sprites/mote-ember.png.ogt +7 -0
- package/archetypes/idle/assets/sprites/mote-star.png +0 -0
- package/archetypes/idle/assets/sprites/mote-star.png.ogt +7 -0
- package/archetypes/idle/assets/sprites/mote-storm.png +0 -0
- package/archetypes/idle/assets/sprites/mote-storm.png.ogt +7 -0
- package/archetypes/idle/assets/sprites/orb.png +0 -0
- package/archetypes/idle/assets/sprites/orb.png.ogt +7 -0
- package/archetypes/idle/assets/sprites/spark.png +0 -0
- package/archetypes/idle/assets/sprites/spark.png.ogt +7 -0
- package/archetypes/idle/assets/strings/en.ogt +62 -0
- package/archetypes/idle/assets/strings/zh-CN.ogt +62 -0
- package/archetypes/idle/gitattributes +22 -0
- package/archetypes/idle/host.d.ts +46 -0
- package/archetypes/idle/package.json +18 -0
- package/archetypes/idle/project.ogt +14 -0
- package/archetypes/idle/references/metal/card.png +0 -0
- package/archetypes/idle/references/metal/orbit.png +0 -0
- package/archetypes/idle/references/metal/title.png +0 -0
- package/archetypes/idle/src/components.ts +139 -0
- package/archetypes/idle/src/main.ts +247 -0
- package/archetypes/idle/src/numbers.ts +126 -0
- package/archetypes/idle/src/systems.ts +340 -0
- package/archetypes/idle/src/ui.ts +412 -0
- package/archetypes/idle/tests/away.og.ts +42 -0
- package/archetypes/idle/tests/flow.og.ts +57 -0
- package/archetypes/idle/tests/frames.og.ts +33 -0
- package/archetypes/idle/tests/frames.ts +134 -0
- package/archetypes/idle/tests/lib.ts +74 -0
- package/archetypes/idle/tests/milestone.og.ts +32 -0
- package/archetypes/idle/tests/nova.og.ts +52 -0
- package/archetypes/idle/tests/offline.og.ts +60 -0
- package/archetypes/idle/tests/pad.og.ts +55 -0
- package/archetypes/idle/tests/pause.og.ts +68 -0
- package/archetypes/idle/tests/phone.og.ts +50 -0
- package/archetypes/idle/tests/replay.og.ts +28 -0
- package/archetypes/idle/tools/make-assets.py +448 -0
- package/archetypes/idle/tools/oglite.py +285 -0
- package/archetypes/idle/tsconfig.json +17 -0
- package/archetypes/match3/.origin/setup +14 -0
- package/archetypes/match3/LICENSES.md +7 -0
- package/archetypes/match3/README.md +205 -0
- package/archetypes/match3/assets/audio/cascade.wav +0 -0
- package/archetypes/match3/assets/audio/clear.wav +0 -0
- package/archetypes/match3/assets/audio/lost.wav +0 -0
- package/archetypes/match3/assets/audio/refused.wav +0 -0
- package/archetypes/match3/assets/audio/select.wav +0 -0
- package/archetypes/match3/assets/audio/swap.wav +0 -0
- package/archetypes/match3/assets/audio/won.wav +0 -0
- package/archetypes/match3/assets/fonts/OFL.txt +93 -0
- package/archetypes/match3/assets/fonts/ui.ttf +0 -0
- package/archetypes/match3/assets/fonts/ui.ttf.ogt +11 -0
- package/archetypes/match3/assets/scenes/main.ogt +24 -0
- package/archetypes/match3/assets/sprites/backdrop.png +0 -0
- package/archetypes/match3/assets/sprites/board.ogt +21 -0
- package/archetypes/match3/assets/sprites/cells.ogt +7 -0
- package/archetypes/match3/assets/sprites/cells.png +0 -0
- package/archetypes/match3/assets/sprites/cells.png.ogt +7 -0
- package/archetypes/match3/assets/sprites/gems.ogt +75 -0
- package/archetypes/match3/assets/sprites/gems.png +0 -0
- package/archetypes/match3/assets/sprites/panel.png +0 -0
- package/archetypes/match3/assets/sprites/ring.png +0 -0
- package/archetypes/match3/gitattributes +22 -0
- package/archetypes/match3/host.d.ts +46 -0
- package/archetypes/match3/package.json +18 -0
- package/archetypes/match3/project.ogt +18 -0
- package/archetypes/match3/references/metal/cascade.png +0 -0
- package/archetypes/match3/references/metal/clearing.png +0 -0
- package/archetypes/match3/references/metal/dealt.png +0 -0
- package/archetypes/match3/src/art.ts +54 -0
- package/archetypes/match3/src/board.ts +112 -0
- package/archetypes/match3/src/components.ts +95 -0
- package/archetypes/match3/src/layout.ts +25 -0
- package/archetypes/match3/src/main.ts +199 -0
- package/archetypes/match3/src/systems.ts +631 -0
- package/archetypes/match3/tests/drag.og.ts +31 -0
- package/archetypes/match3/tests/endings.og.ts +40 -0
- package/archetypes/match3/tests/frames.og.ts +49 -0
- package/archetypes/match3/tests/frames.ts +134 -0
- package/archetypes/match3/tests/hidpi.og.ts +41 -0
- package/archetypes/match3/tests/lib.ts +64 -0
- package/archetypes/match3/tests/replay.og.ts +28 -0
- package/archetypes/match3/tests/sounds.og.ts +50 -0
- package/archetypes/match3/tests/swap.og.ts +67 -0
- package/archetypes/match3/tools/make-assets.py +404 -0
- package/archetypes/match3/tools/oglite.py +285 -0
- package/archetypes/match3/tsconfig.json +17 -0
- package/archetypes/rhythm/.origin/setup +14 -0
- package/archetypes/rhythm/LICENSES.md +13 -0
- package/archetypes/rhythm/README.md +235 -0
- package/archetypes/rhythm/assets/audio/bass0.wav +0 -0
- package/archetypes/rhythm/assets/audio/bass1.wav +0 -0
- package/archetypes/rhythm/assets/audio/bass2.wav +0 -0
- package/archetypes/rhythm/assets/audio/bass3.wav +0 -0
- package/archetypes/rhythm/assets/audio/chords0.wav +0 -0
- package/archetypes/rhythm/assets/audio/chords1.wav +0 -0
- package/archetypes/rhythm/assets/audio/chords2.wav +0 -0
- package/archetypes/rhythm/assets/audio/chords3.wav +0 -0
- package/archetypes/rhythm/assets/audio/clear.wav +0 -0
- package/archetypes/rhythm/assets/audio/click.wav +0 -0
- package/archetypes/rhythm/assets/audio/drums.wav +0 -0
- package/archetypes/rhythm/assets/audio/fail.wav +0 -0
- package/archetypes/rhythm/assets/audio/leadA.wav +0 -0
- package/archetypes/rhythm/assets/audio/leadB.wav +0 -0
- package/archetypes/rhythm/assets/audio/miss.wav +0 -0
- package/archetypes/rhythm/assets/audio/tap0.wav +0 -0
- package/archetypes/rhythm/assets/audio/tap1.wav +0 -0
- package/archetypes/rhythm/assets/audio/tap2.wav +0 -0
- package/archetypes/rhythm/assets/audio/ui-close.ogt +9 -0
- package/archetypes/rhythm/assets/audio/ui-error.ogt +9 -0
- package/archetypes/rhythm/assets/audio/ui-open.ogt +9 -0
- package/archetypes/rhythm/assets/audio/ui-press.ogt +9 -0
- package/archetypes/rhythm/assets/audio/ui-success.ogt +9 -0
- package/archetypes/rhythm/assets/charts/neon-pulse.ogt +919 -0
- package/archetypes/rhythm/assets/fonts/NotoSansSC-subset.ttf +0 -0
- package/archetypes/rhythm/assets/fonts/NotoSansSC-subset.ttf.ogt +10 -0
- package/archetypes/rhythm/assets/fonts/OFL.txt +93 -0
- package/archetypes/rhythm/assets/fx/hit.ogt +22 -0
- package/archetypes/rhythm/assets/skins/lanebeat/ChakraPetch-Medium.ttf +0 -0
- package/archetypes/rhythm/assets/skins/lanebeat/ChakraPetch-Medium.ttf.ogt +9 -0
- package/archetypes/rhythm/assets/skins/lanebeat/JetBrainsMono-Regular.ttf +0 -0
- package/archetypes/rhythm/assets/skins/lanebeat/JetBrainsMono-Regular.ttf.ogt +9 -0
- package/archetypes/rhythm/assets/skins/lanebeat/LICENSES.md +17 -0
- package/archetypes/rhythm/assets/skins/lanebeat/OFL.txt +95 -0
- package/archetypes/rhythm/assets/skins/lanebeat/Orbitron-Bold.ttf +0 -0
- package/archetypes/rhythm/assets/skins/lanebeat/Orbitron-Bold.ttf.ogt +9 -0
- package/archetypes/rhythm/assets/skins/lanebeat/atlas.png +0 -0
- package/archetypes/rhythm/assets/skins/lanebeat/atlas.png.ogt +7 -0
- package/archetypes/rhythm/assets/skins/lanebeat/icons.png +0 -0
- package/archetypes/rhythm/assets/skins/lanebeat/icons.png.ogt +7 -0
- package/archetypes/rhythm/assets/skins/lanebeat/skin.ogt +110 -0
- package/archetypes/rhythm/assets/sprites/lane.png +0 -0
- package/archetypes/rhythm/assets/sprites/lane.png.ogt +7 -0
- package/archetypes/rhythm/assets/sprites/note.png +0 -0
- package/archetypes/rhythm/assets/sprites/note.png.ogt +7 -0
- package/archetypes/rhythm/assets/sprites/ring.png +0 -0
- package/archetypes/rhythm/assets/sprites/ring.png.ogt +7 -0
- package/archetypes/rhythm/assets/sprites/spark.png +0 -0
- package/archetypes/rhythm/assets/sprites/spark.png.ogt +7 -0
- package/archetypes/rhythm/assets/strings/en.ogt +61 -0
- package/archetypes/rhythm/assets/strings/zh-CN.ogt +61 -0
- package/archetypes/rhythm/gitattributes +22 -0
- package/archetypes/rhythm/host.d.ts +46 -0
- package/archetypes/rhythm/package.json +18 -0
- package/archetypes/rhythm/project.ogt +14 -0
- package/archetypes/rhythm/references/metal/highway.png +0 -0
- package/archetypes/rhythm/references/metal/results.png +0 -0
- package/archetypes/rhythm/references/metal/title.png +0 -0
- package/archetypes/rhythm/src/components.ts +147 -0
- package/archetypes/rhythm/src/main.ts +202 -0
- package/archetypes/rhythm/src/systems.ts +490 -0
- package/archetypes/rhythm/src/ui.ts +421 -0
- package/archetypes/rhythm/tests/band.og.ts +45 -0
- package/archetypes/rhythm/tests/calibrate.og.ts +49 -0
- package/archetypes/rhythm/tests/clear.og.ts +51 -0
- package/archetypes/rhythm/tests/fail.og.ts +40 -0
- package/archetypes/rhythm/tests/flow.og.ts +54 -0
- package/archetypes/rhythm/tests/frames.og.ts +35 -0
- package/archetypes/rhythm/tests/frames.ts +134 -0
- package/archetypes/rhythm/tests/lib.ts +123 -0
- package/archetypes/rhythm/tests/pad.og.ts +41 -0
- package/archetypes/rhythm/tests/pause.og.ts +77 -0
- package/archetypes/rhythm/tests/phone.og.ts +44 -0
- package/archetypes/rhythm/tests/replay.og.ts +27 -0
- package/archetypes/rhythm/tests/timing.og.ts +37 -0
- package/archetypes/rhythm/tools/make-assets.py +383 -0
- package/archetypes/rhythm/tools/oglite.py +285 -0
- package/archetypes/rhythm/tsconfig.json +17 -0
- package/archetypes/roguelike/.origin/setup +14 -0
- package/archetypes/roguelike/LICENSES.md +14 -0
- package/archetypes/roguelike/README.md +256 -0
- package/archetypes/roguelike/assets/ai/foe.ogt +28 -0
- package/archetypes/roguelike/assets/ai/guardian.ogt +26 -0
- package/archetypes/roguelike/assets/audio/bump.wav +0 -0
- package/archetypes/roguelike/assets/audio/drink.wav +0 -0
- package/archetypes/roguelike/assets/audio/fall.wav +0 -0
- package/archetypes/roguelike/assets/audio/hit.wav +0 -0
- package/archetypes/roguelike/assets/audio/hurt.wav +0 -0
- package/archetypes/roguelike/assets/audio/item.wav +0 -0
- package/archetypes/roguelike/assets/audio/kill.wav +0 -0
- package/archetypes/roguelike/assets/audio/pickup.wav +0 -0
- package/archetypes/roguelike/assets/audio/roar.wav +0 -0
- package/archetypes/roguelike/assets/audio/stairs.wav +0 -0
- package/archetypes/roguelike/assets/audio/step.ogt +9 -0
- package/archetypes/roguelike/assets/audio/telegraph.wav +0 -0
- package/archetypes/roguelike/assets/audio/tomb.wav +0 -0
- package/archetypes/roguelike/assets/audio/ui-close.ogt +9 -0
- package/archetypes/roguelike/assets/audio/ui-error.ogt +9 -0
- package/archetypes/roguelike/assets/audio/ui-open.ogt +9 -0
- package/archetypes/roguelike/assets/audio/ui-press.ogt +9 -0
- package/archetypes/roguelike/assets/audio/ui-success.ogt +9 -0
- package/archetypes/roguelike/assets/audio/won.wav +0 -0
- package/archetypes/roguelike/assets/fonts/NotoSansSC-subset.ttf +0 -0
- package/archetypes/roguelike/assets/fonts/NotoSansSC-subset.ttf.ogt +10 -0
- package/archetypes/roguelike/assets/fonts/OFL.txt +93 -0
- package/archetypes/roguelike/assets/maps/dive.ogt +106 -0
- package/archetypes/roguelike/assets/skins/lampdive/DotGothic16-Regular.ttf +0 -0
- package/archetypes/roguelike/assets/skins/lampdive/DotGothic16-Regular.ttf.ogt +9 -0
- package/archetypes/roguelike/assets/skins/lampdive/LICENSES.md +16 -0
- package/archetypes/roguelike/assets/skins/lampdive/OFL.txt +93 -0
- package/archetypes/roguelike/assets/skins/lampdive/atlas.png +0 -0
- package/archetypes/roguelike/assets/skins/lampdive/atlas.png.ogt +7 -0
- package/archetypes/roguelike/assets/skins/lampdive/icons.png +0 -0
- package/archetypes/roguelike/assets/skins/lampdive/icons.png.ogt +7 -0
- package/archetypes/roguelike/assets/skins/lampdive/skin.ogt +115 -0
- package/archetypes/roguelike/assets/sprites/dive.ogt +50 -0
- package/archetypes/roguelike/assets/sprites/dive.png +0 -0
- package/archetypes/roguelike/assets/sprites/dive.png.ogt +7 -0
- package/archetypes/roguelike/assets/sprites/glow.png +0 -0
- package/archetypes/roguelike/assets/sprites/glow.png.ogt +7 -0
- package/archetypes/roguelike/assets/strings/en.ogt +57 -0
- package/archetypes/roguelike/assets/strings/zh-CN.ogt +57 -0
- package/archetypes/roguelike/assets/tiles/tomb.ogt +31 -0
- package/archetypes/roguelike/assets/tiles/tomb.png +0 -0
- package/archetypes/roguelike/assets/tiles/tomb.png.ogt +7 -0
- package/archetypes/roguelike/gitattributes +22 -0
- package/archetypes/roguelike/host.d.ts +46 -0
- package/archetypes/roguelike/package.json +18 -0
- package/archetypes/roguelike/project.ogt +14 -0
- package/archetypes/roguelike/references/metal/dive.png +0 -0
- package/archetypes/roguelike/references/metal/over.png +0 -0
- package/archetypes/roguelike/references/metal/title.png +0 -0
- package/archetypes/roguelike/src/art.ts +23 -0
- package/archetypes/roguelike/src/components.ts +169 -0
- package/archetypes/roguelike/src/dive.ts +144 -0
- package/archetypes/roguelike/src/foes.ts +174 -0
- package/archetypes/roguelike/src/main.ts +258 -0
- package/archetypes/roguelike/src/systems.ts +620 -0
- package/archetypes/roguelike/src/ui.ts +350 -0
- package/archetypes/roguelike/tests/flow.og.ts +54 -0
- package/archetypes/roguelike/tests/foes.og.ts +45 -0
- package/archetypes/roguelike/tests/frames.og.ts +32 -0
- package/archetypes/roguelike/tests/frames.ts +134 -0
- package/archetypes/roguelike/tests/lib.ts +83 -0
- package/archetypes/roguelike/tests/lose.og.ts +44 -0
- package/archetypes/roguelike/tests/pad.og.ts +54 -0
- package/archetypes/roguelike/tests/pause.og.ts +59 -0
- package/archetypes/roguelike/tests/phone.og.ts +54 -0
- package/archetypes/roguelike/tests/replay.og.ts +24 -0
- package/archetypes/roguelike/tests/win.og.ts +60 -0
- package/archetypes/roguelike/tools/make-assets.py +518 -0
- package/archetypes/roguelike/tools/oglite.py +285 -0
- package/archetypes/roguelike/tsconfig.json +17 -0
- package/archetypes/runner/.origin/setup +14 -0
- package/archetypes/runner/LICENSES.md +10 -0
- package/archetypes/runner/README.md +225 -0
- package/archetypes/runner/assets/audio/coin.wav +0 -0
- package/archetypes/runner/assets/audio/crash.wav +0 -0
- package/archetypes/runner/assets/audio/hold.ogt +9 -0
- package/archetypes/runner/assets/audio/jump.wav +0 -0
- package/archetypes/runner/assets/audio/start.wav +0 -0
- package/archetypes/runner/assets/fonts/OFL.txt +93 -0
- package/archetypes/runner/assets/fonts/ui.ttf +0 -0
- package/archetypes/runner/assets/fonts/ui.ttf.ogt +11 -0
- package/archetypes/runner/assets/maps/far.ogt +25 -0
- package/archetypes/runner/assets/maps/near.ogt +25 -0
- package/archetypes/runner/assets/maps/roofs.ogt +19 -0
- package/archetypes/runner/assets/scenes/main.ogt +35 -0
- package/archetypes/runner/assets/sprites/coin.ogt +11 -0
- package/archetypes/runner/assets/sprites/coin.png +0 -0
- package/archetypes/runner/assets/sprites/coin.png.ogt +7 -0
- package/archetypes/runner/assets/sprites/courier.ogt +32 -0
- package/archetypes/runner/assets/sprites/courier.png +0 -0
- package/archetypes/runner/assets/sprites/courier.png.ogt +7 -0
- package/archetypes/runner/assets/sprites/props.ogt +21 -0
- package/archetypes/runner/assets/sprites/props.png +0 -0
- package/archetypes/runner/assets/sprites/props.png.ogt +7 -0
- package/archetypes/runner/assets/sprites/sky.png +0 -0
- package/archetypes/runner/assets/sprites/sky.png.ogt +7 -0
- package/archetypes/runner/assets/tiles/city.ogt +18 -0
- package/archetypes/runner/assets/tiles/city.png +0 -0
- package/archetypes/runner/assets/tiles/city.png.ogt +7 -0
- package/archetypes/runner/gitattributes +22 -0
- package/archetypes/runner/host.d.ts +46 -0
- package/archetypes/runner/package.json +18 -0
- package/archetypes/runner/project.ogt +18 -0
- package/archetypes/runner/references/metal/frames-coin.png +0 -0
- package/archetypes/runner/references/metal/frames-crash.png +0 -0
- package/archetypes/runner/references/metal/frames-title.png +0 -0
- package/archetypes/runner/src/art.ts +57 -0
- package/archetypes/runner/src/components.ts +94 -0
- package/archetypes/runner/src/main.ts +241 -0
- package/archetypes/runner/src/systems.ts +553 -0
- package/archetypes/runner/tests/coins.og.ts +30 -0
- package/archetypes/runner/tests/flow.og.ts +72 -0
- package/archetypes/runner/tests/frames.og.ts +37 -0
- package/archetypes/runner/tests/frames.ts +134 -0
- package/archetypes/runner/tests/jump.og.ts +44 -0
- package/archetypes/runner/tests/lib.ts +42 -0
- package/archetypes/runner/tests/records.og.ts +43 -0
- package/archetypes/runner/tests/replay.og.ts +36 -0
- package/archetypes/runner/tests/sounds.og.ts +43 -0
- package/archetypes/runner/tests/tune.og.ts +36 -0
- package/archetypes/runner/tools/make-assets.py +603 -0
- package/archetypes/runner/tools/oglite.py +285 -0
- package/archetypes/runner/tsconfig.json +17 -0
- package/archetypes/third-person/.origin/setup +14 -0
- package/archetypes/third-person/LICENSES.md +23 -0
- package/archetypes/third-person/README.md +249 -0
- package/archetypes/third-person/assets/ai/sentinel-east.ogt +69 -0
- package/archetypes/third-person/assets/ai/sentinel-north.ogt +69 -0
- package/archetypes/third-person/assets/ai/sentinel-west.ogt +69 -0
- package/archetypes/third-person/assets/anims/humanoid-clips.glb +0 -0
- package/archetypes/third-person/assets/audio/alarm.wav +0 -0
- package/archetypes/third-person/assets/audio/dawn.wav +0 -0
- package/archetypes/third-person/assets/audio/grab.wav +0 -0
- package/archetypes/third-person/assets/audio/ignite.wav +0 -0
- package/archetypes/third-person/assets/audio/jump.wav +0 -0
- package/archetypes/third-person/assets/audio/night.wav +0 -0
- package/archetypes/third-person/assets/audio/splash.wav +0 -0
- package/archetypes/third-person/assets/audio/step.ogt +9 -0
- package/archetypes/third-person/assets/audio/ui-close.ogt +9 -0
- package/archetypes/third-person/assets/audio/ui-error.ogt +9 -0
- package/archetypes/third-person/assets/audio/ui-open.ogt +9 -0
- package/archetypes/third-person/assets/audio/ui-press.ogt +9 -0
- package/archetypes/third-person/assets/audio/ui-success.ogt +9 -0
- package/archetypes/third-person/assets/audio/vale.wav +0 -0
- package/archetypes/third-person/assets/fonts/NotoSansSC-subset.ttf +0 -0
- package/archetypes/third-person/assets/fonts/NotoSansSC-subset.ttf.ogt +10 -0
- package/archetypes/third-person/assets/fonts/OFL.txt +93 -0
- package/archetypes/third-person/assets/fx/burst.ogt +25 -0
- package/archetypes/third-person/assets/fx/fire.ogt +24 -0
- package/archetypes/third-person/assets/fx/smoke.ogt +24 -0
- package/archetypes/third-person/assets/fx/splash.ogt +24 -0
- package/archetypes/third-person/assets/luts/teal-orange.cube +4917 -0
- package/archetypes/third-person/assets/models/stout.glb +0 -0
- package/archetypes/third-person/assets/models/strider.glb +0 -0
- package/archetypes/third-person/assets/models/strider.glb.ogt +9 -0
- package/archetypes/third-person/assets/nav/vale.ogt +43 -0
- package/archetypes/third-person/assets/rigs/strider.ogt +6 -0
- package/archetypes/third-person/assets/skins/ember/Cinzel-Bold.ttf +0 -0
- package/archetypes/third-person/assets/skins/ember/Cinzel-Bold.ttf.ogt +9 -0
- package/archetypes/third-person/assets/skins/ember/LICENSES.md +13 -0
- package/archetypes/third-person/assets/skins/ember/Newsreader-Medium.ttf +0 -0
- package/archetypes/third-person/assets/skins/ember/Newsreader-Medium.ttf.ogt +9 -0
- package/archetypes/third-person/assets/skins/ember/OFL.txt +94 -0
- package/archetypes/third-person/assets/skins/ember/atlas.png +0 -0
- package/archetypes/third-person/assets/skins/ember/atlas.png.ogt +7 -0
- package/archetypes/third-person/assets/skins/ember/icons.png +0 -0
- package/archetypes/third-person/assets/skins/ember/icons.png.ogt +7 -0
- package/archetypes/third-person/assets/skins/ember/skin.ogt +109 -0
- package/archetypes/third-person/assets/strings/en.ogt +47 -0
- package/archetypes/third-person/assets/strings/zh-CN.ogt +47 -0
- package/archetypes/third-person/assets/terrain/vale-control.png +0 -0
- package/archetypes/third-person/assets/terrain/vale.ogt +42 -0
- package/archetypes/third-person/assets/terrain/vale.png +0 -0
- package/archetypes/third-person/assets/textures/decals.png +0 -0
- package/archetypes/third-person/assets/textures/flame.png +0 -0
- package/archetypes/third-person/assets/textures/smoke.png +0 -0
- package/archetypes/third-person/assets/textures/spark.png +0 -0
- package/archetypes/third-person/assets/textures/terrain-grass.png +0 -0
- package/archetypes/third-person/assets/textures/terrain-path.png +0 -0
- package/archetypes/third-person/assets/textures/terrain-rock.png +0 -0
- package/archetypes/third-person/assets/textures/terrain-sand.png +0 -0
- package/archetypes/third-person/gitattributes +22 -0
- package/archetypes/third-person/host.d.ts +46 -0
- package/archetypes/third-person/package.json +18 -0
- package/archetypes/third-person/project.ogt +14 -0
- package/archetypes/third-person/references/metal/beacon.png +0 -0
- package/archetypes/third-person/references/metal/dawn.png +0 -0
- package/archetypes/third-person/references/metal/title.png +0 -0
- package/archetypes/third-person/references/webgl2/beacon.png +0 -0
- package/archetypes/third-person/src/anim.ts +87 -0
- package/archetypes/third-person/src/beacons.ts +80 -0
- package/archetypes/third-person/src/components.ts +148 -0
- package/archetypes/third-person/src/hero.ts +293 -0
- package/archetypes/third-person/src/main.ts +164 -0
- package/archetypes/third-person/src/sentinels.ts +159 -0
- package/archetypes/third-person/src/sound.ts +66 -0
- package/archetypes/third-person/src/ui.ts +451 -0
- package/archetypes/third-person/src/world.ts +212 -0
- package/archetypes/third-person/tests/flow.og.ts +70 -0
- package/archetypes/third-person/tests/frames.og.ts +35 -0
- package/archetypes/third-person/tests/frames.ts +134 -0
- package/archetypes/third-person/tests/hitstop.og.ts +26 -0
- package/archetypes/third-person/tests/lib.ts +87 -0
- package/archetypes/third-person/tests/lose.og.ts +44 -0
- package/archetypes/third-person/tests/pause.og.ts +64 -0
- package/archetypes/third-person/tests/phone.og.ts +65 -0
- package/archetypes/third-person/tests/replay.og.ts +32 -0
- package/archetypes/third-person/tests/restart.og.ts +28 -0
- package/archetypes/third-person/tests/sentinels.og.ts +48 -0
- package/archetypes/third-person/tests/win.og.ts +62 -0
- package/archetypes/third-person/tools/make-assets.py +353 -0
- package/archetypes/third-person/tools/oglite.py +285 -0
- package/archetypes/third-person/tsconfig.json +17 -0
- package/archetypes/topdown/.origin/setup +14 -0
- package/archetypes/topdown/LICENSES.md +10 -0
- package/archetypes/topdown/README.md +235 -0
- package/archetypes/topdown/assets/ai/slime.ogt +49 -0
- package/archetypes/topdown/assets/audio/coin.wav +0 -0
- package/archetypes/topdown/assets/audio/door.wav +0 -0
- package/archetypes/topdown/assets/audio/hit.wav +0 -0
- package/archetypes/topdown/assets/audio/hurt.wav +0 -0
- package/archetypes/topdown/assets/audio/key.wav +0 -0
- package/archetypes/topdown/assets/audio/step.ogt +9 -0
- package/archetypes/topdown/assets/fonts/OFL.txt +93 -0
- package/archetypes/topdown/assets/fonts/ui.ttf +0 -0
- package/archetypes/topdown/assets/fonts/ui.ttf.ogt +9 -0
- package/archetypes/topdown/assets/maps/tomb.tmj +2183 -0
- package/archetypes/topdown/assets/sprites/hero.ogt +58 -0
- package/archetypes/topdown/assets/sprites/hero.png +0 -0
- package/archetypes/topdown/assets/sprites/hero.png.ogt +7 -0
- package/archetypes/topdown/assets/sprites/items.ogt +15 -0
- package/archetypes/topdown/assets/sprites/items.png +0 -0
- package/archetypes/topdown/assets/sprites/items.png.ogt +7 -0
- package/archetypes/topdown/assets/sprites/slime.ogt +17 -0
- package/archetypes/topdown/assets/sprites/slime.png +0 -0
- package/archetypes/topdown/assets/sprites/slime.png.ogt +7 -0
- package/archetypes/topdown/assets/tiles/dungeon.ogt +65 -0
- package/archetypes/topdown/assets/tiles/dungeon.png +0 -0
- package/archetypes/topdown/assets/tiles/dungeon.png.ogt +7 -0
- package/archetypes/topdown/gitattributes +22 -0
- package/archetypes/topdown/host.d.ts +46 -0
- package/archetypes/topdown/package.json +18 -0
- package/archetypes/topdown/project.ogt +14 -0
- package/archetypes/topdown/references/metal/crit.png +0 -0
- package/archetypes/topdown/references/metal/dash.png +0 -0
- package/archetypes/topdown/references/metal/east.png +0 -0
- package/archetypes/topdown/references/metal/start.png +0 -0
- package/archetypes/topdown/src/art.ts +48 -0
- package/archetypes/topdown/src/components.ts +128 -0
- package/archetypes/topdown/src/main.ts +275 -0
- package/archetypes/topdown/src/systems.ts +503 -0
- package/archetypes/topdown/tests/ai.og.ts +64 -0
- package/archetypes/topdown/tests/combat.og.ts +72 -0
- package/archetypes/topdown/tests/door.og.ts +62 -0
- package/archetypes/topdown/tests/flee.og.ts +49 -0
- package/archetypes/topdown/tests/frames.og.ts +45 -0
- package/archetypes/topdown/tests/frames.ts +134 -0
- package/archetypes/topdown/tests/lib.ts +71 -0
- package/archetypes/topdown/tests/replay.og.ts +40 -0
- package/archetypes/topdown/tests/walk.og.ts +46 -0
- package/archetypes/topdown/tools/make-assets.py +623 -0
- package/archetypes/topdown/tools/oglite.py +285 -0
- package/archetypes/topdown/tsconfig.json +17 -0
- package/archetypes/tower-defense/.origin/setup +14 -0
- package/archetypes/tower-defense/LICENSES.md +15 -0
- package/archetypes/tower-defense/README.md +240 -0
- package/archetypes/tower-defense/assets/ai/plant.ogt +16 -0
- package/archetypes/tower-defense/assets/audio/clear.wav +0 -0
- package/archetypes/tower-defense/assets/audio/frost.wav +0 -0
- package/archetypes/tower-defense/assets/audio/leak.wav +0 -0
- package/archetypes/tower-defense/assets/audio/lost.wav +0 -0
- package/archetypes/tower-defense/assets/audio/night.wav +0 -0
- package/archetypes/tower-defense/assets/audio/plant.wav +0 -0
- package/archetypes/tower-defense/assets/audio/pop.wav +0 -0
- package/archetypes/tower-defense/assets/audio/thorn.wav +0 -0
- package/archetypes/tower-defense/assets/audio/ui-close.ogt +9 -0
- package/archetypes/tower-defense/assets/audio/ui-error.ogt +9 -0
- package/archetypes/tower-defense/assets/audio/ui-open.ogt +9 -0
- package/archetypes/tower-defense/assets/audio/ui-press.ogt +9 -0
- package/archetypes/tower-defense/assets/audio/ui-success.ogt +9 -0
- package/archetypes/tower-defense/assets/audio/wave.wav +0 -0
- package/archetypes/tower-defense/assets/audio/won.wav +0 -0
- package/archetypes/tower-defense/assets/fonts/NotoSansSC-subset.ttf +0 -0
- package/archetypes/tower-defense/assets/fonts/NotoSansSC-subset.ttf.ogt +10 -0
- package/archetypes/tower-defense/assets/fonts/OFL.txt +93 -0
- package/archetypes/tower-defense/assets/fx/fireflies.ogt +21 -0
- package/archetypes/tower-defense/assets/fx/pop.ogt +21 -0
- package/archetypes/tower-defense/assets/maps/garden.ogt +91 -0
- package/archetypes/tower-defense/assets/skins/pathguard/Fredoka-SemiBold.ttf +0 -0
- package/archetypes/tower-defense/assets/skins/pathguard/Fredoka-SemiBold.ttf.ogt +9 -0
- package/archetypes/tower-defense/assets/skins/pathguard/LICENSES.md +13 -0
- package/archetypes/tower-defense/assets/skins/pathguard/LilitaOne-Regular.ttf +0 -0
- package/archetypes/tower-defense/assets/skins/pathguard/LilitaOne-Regular.ttf.ogt +9 -0
- package/archetypes/tower-defense/assets/skins/pathguard/OFL.txt +94 -0
- package/archetypes/tower-defense/assets/skins/pathguard/atlas.png +0 -0
- package/archetypes/tower-defense/assets/skins/pathguard/atlas.png.ogt +7 -0
- package/archetypes/tower-defense/assets/skins/pathguard/icons.png +0 -0
- package/archetypes/tower-defense/assets/skins/pathguard/icons.png.ogt +7 -0
- package/archetypes/tower-defense/assets/skins/pathguard/skin.ogt +111 -0
- package/archetypes/tower-defense/assets/sprites/garden.ogt +66 -0
- package/archetypes/tower-defense/assets/sprites/garden.png +0 -0
- package/archetypes/tower-defense/assets/sprites/garden.png.ogt +7 -0
- package/archetypes/tower-defense/assets/sprites/glow.png +0 -0
- package/archetypes/tower-defense/assets/sprites/glow.png.ogt +7 -0
- package/archetypes/tower-defense/assets/sprites/ring.png +0 -0
- package/archetypes/tower-defense/assets/sprites/ring.png.ogt +7 -0
- package/archetypes/tower-defense/assets/sprites/spark.png +0 -0
- package/archetypes/tower-defense/assets/sprites/spark.png.ogt +7 -0
- package/archetypes/tower-defense/assets/strings/en.ogt +47 -0
- package/archetypes/tower-defense/assets/strings/zh-CN.ogt +47 -0
- package/archetypes/tower-defense/assets/tiles/garden.ogt +10 -0
- package/archetypes/tower-defense/assets/tiles/garden.png +0 -0
- package/archetypes/tower-defense/assets/tiles/garden.png.ogt +7 -0
- package/archetypes/tower-defense/gitattributes +22 -0
- package/archetypes/tower-defense/host.d.ts +46 -0
- package/archetypes/tower-defense/package.json +18 -0
- package/archetypes/tower-defense/project.ogt +14 -0
- package/archetypes/tower-defense/references/metal/end.png +0 -0
- package/archetypes/tower-defense/references/metal/title.png +0 -0
- package/archetypes/tower-defense/references/metal/wave.png +0 -0
- package/archetypes/tower-defense/src/art.ts +24 -0
- package/archetypes/tower-defense/src/components.ts +156 -0
- package/archetypes/tower-defense/src/main.ts +253 -0
- package/archetypes/tower-defense/src/systems.ts +658 -0
- package/archetypes/tower-defense/src/ui.ts +382 -0
- package/archetypes/tower-defense/tests/flow.og.ts +56 -0
- package/archetypes/tower-defense/tests/frames.og.ts +31 -0
- package/archetypes/tower-defense/tests/frames.ts +134 -0
- package/archetypes/tower-defense/tests/lib.ts +81 -0
- package/archetypes/tower-defense/tests/lose.og.ts +40 -0
- package/archetypes/tower-defense/tests/maze.og.ts +53 -0
- package/archetypes/tower-defense/tests/pad.og.ts +41 -0
- package/archetypes/tower-defense/tests/pause.og.ts +59 -0
- package/archetypes/tower-defense/tests/phone.og.ts +49 -0
- package/archetypes/tower-defense/tests/replay.og.ts +28 -0
- package/archetypes/tower-defense/tests/win.og.ts +58 -0
- package/archetypes/tower-defense/tools/make-assets.py +640 -0
- package/archetypes/tower-defense/tools/oglite.py +285 -0
- package/archetypes/tower-defense/tsconfig.json +17 -0
- package/bin/create.ts +496 -0
- package/looks/catalogue.json +1871 -0
- package/package.json +31 -4
- package/template/.origin/setup +14 -0
- package/template/LICENSES.md +23 -0
- package/template/README.md +37 -0
- package/template/assets/ai/guard.ogt +48 -0
- package/template/assets/audio/blip.wav +0 -0
- package/template/assets/audio/click.ogt +9 -0
- package/template/assets/fonts/NotoSansSC-Regular-subset.ttf +0 -0
- package/template/assets/fonts/NotoSansSC-Regular-subset.ttf.ogt +12 -0
- package/template/assets/fonts/OFL.txt +93 -0
- package/template/assets/looks/origin-game.ogt +12 -0
- package/template/assets/models/dropship.glb +0 -0
- package/template/assets/models/walker.glb +0 -0
- package/template/assets/nav/yard.ogt +27 -0
- package/template/assets/scenes/main.ogt +34 -0
- package/template/assets/strings/en.ogt +14 -0
- package/template/assets/textures/stone.png +0 -0
- package/template/assets/textures/stone_n.png +0 -0
- package/template/assets/textures/stone_n.png.ogt +7 -0
- package/template/gitattributes +22 -0
- package/template/package.json +18 -0
- package/template/project.ogt +25 -0
- package/template/src/main.ts +246 -0
- package/template/tests/guard.og.ts +67 -0
- package/template/tests/smoke.og.ts +43 -0
- package/template/tsconfig.json +17 -0
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
// Path Guard's screens on og.ui and the skin in assets/skins/pathguard:
|
|
2
|
+
// the title, the HUD (the light and the coins in the top-left corner, the
|
|
3
|
+
// wave and pause in the top-right, the plant tray on the right on a wide
|
|
4
|
+
// screen and along the bottom on a phone), the pause menu, the settings
|
|
5
|
+
// dialog and the end card. Screens change through an iris (a fade with
|
|
6
|
+
// reduced motion). Every string is a key of assets/strings/*.ogt.
|
|
7
|
+
//
|
|
8
|
+
// The Ui system also frames the camera on the field for the surface (the
|
|
9
|
+
// field beside the tray on a wide screen, between the HUD rows on a
|
|
10
|
+
// phone), sets the buses from the settings and reads and writes the
|
|
11
|
+
// settings and the best score through og.platform.
|
|
12
|
+
|
|
13
|
+
import { og, defineSystem } from "@origingame/engine";
|
|
14
|
+
import type { Entity, Value, World } from "@origingame/engine";
|
|
15
|
+
import { Game, Phase, Plant, PLANTS, Prefs, Tuning } from "./components.ts";
|
|
16
|
+
import { COLS, cost, lazyTuning, ROWS, WAVES } from "./systems.ts";
|
|
17
|
+
|
|
18
|
+
/** The languages the settings offer, each named in its own language. */
|
|
19
|
+
export const LANGUAGES = [
|
|
20
|
+
{ code: "en", key: "lang.en" },
|
|
21
|
+
{ code: "zh-CN", key: "lang.zh" },
|
|
22
|
+
] as const;
|
|
23
|
+
|
|
24
|
+
type GameV = Value<typeof Game>;
|
|
25
|
+
type TuneV = Value<typeof Tuning>;
|
|
26
|
+
type PrefsV = Value<typeof Prefs>;
|
|
27
|
+
/**
|
|
28
|
+
* The tokens' spacing scale in CSS px (the same at every density). og.ui's
|
|
29
|
+
* frameTheme answers it too, but builds the whole theme each call (about a
|
|
30
|
+
* millisecond), so the screens read it from here.
|
|
31
|
+
*/
|
|
32
|
+
const SPACE = { xxs: 2, xs: 4, sm: 8, md: 12, lg: 16, xl: 24 } as const;
|
|
33
|
+
type Theme = { readonly space: typeof SPACE };
|
|
34
|
+
const THEME: Theme = { space: SPACE };
|
|
35
|
+
|
|
36
|
+
/** A string of the active locale (og.i18n). */
|
|
37
|
+
export function say(world: World, key: string, args?: Record<string, string | number>): string {
|
|
38
|
+
return og.i18n.t(world, key, args);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const grow = { kind: "grow" } as const;
|
|
42
|
+
const px = (n: number) => ({ kind: "fixed", px: n }) as const;
|
|
43
|
+
|
|
44
|
+
function must(r: { ok: true } | { ok: false; reason: string }): void {
|
|
45
|
+
if (!r.ok) throw new Error(r.reason);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** The phone layouts: a portrait or landscape phone. */
|
|
49
|
+
function phone(): boolean {
|
|
50
|
+
const b = og.ui.frameViewport().breakpoint;
|
|
51
|
+
return b === "phonePortrait" || b === "phoneLandscape";
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The sheet frame of a plant, for the tray's pictures. */
|
|
55
|
+
const PICTURE = [8, 11, 14] as const;
|
|
56
|
+
function uvOf(frame: number): [number, number, number, number] {
|
|
57
|
+
return [(frame % 8) / 8, Math.floor(frame / 8) / 3, ((frame % 8) + 1) / 8, (Math.floor(frame / 8) + 1) / 3];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** A new round: the field cleared, the purse and the light full, the first wave three seconds off. */
|
|
61
|
+
export function startRound(world: World, g: GameV, t: TuneV): void {
|
|
62
|
+
g.phase = Phase.Play;
|
|
63
|
+
g.paused = false;
|
|
64
|
+
g.won = false;
|
|
65
|
+
g.rounds += 1;
|
|
66
|
+
g.lives = t.startLives;
|
|
67
|
+
g.gold = t.startGold;
|
|
68
|
+
g.wave = 0;
|
|
69
|
+
g.inWave = false;
|
|
70
|
+
g.toSpawn = 0;
|
|
71
|
+
g.spawned = 0;
|
|
72
|
+
g.breakTicks = 180;
|
|
73
|
+
g.callNext = false;
|
|
74
|
+
g.kills = 0;
|
|
75
|
+
g.leaks = 0;
|
|
76
|
+
g.placed = 0;
|
|
77
|
+
g.refused = 0;
|
|
78
|
+
g.shots = 0;
|
|
79
|
+
g.score = 0;
|
|
80
|
+
g.newBest = false;
|
|
81
|
+
g.selected = Plant.Thorn;
|
|
82
|
+
g.cursorX = 4;
|
|
83
|
+
g.cursorY = 9;
|
|
84
|
+
const grid = g.grid as unknown as never;
|
|
85
|
+
for (let y = 1; y < ROWS - 1; y++) {
|
|
86
|
+
for (let x = 1; x < COLS - 1; x++) {
|
|
87
|
+
must(og.tilemap.setTile(world, { entity: g.map as unknown as Entity, layer: "pads", x, y, tile: -1 }));
|
|
88
|
+
must(og.nav.setCost(world, grid, x, ROWS - 1 - y, 1));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// The Plants and Visitors systems clear their rows on their next run.
|
|
92
|
+
g.reset = true;
|
|
93
|
+
g.pendingPlants = 0;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Frames the camera on the field for this surface: beside the tray on a wide screen, between the HUD rows on a phone. */
|
|
97
|
+
function frameCamera(world: World, g: GameV): void {
|
|
98
|
+
const vp = og.ui.frameViewport();
|
|
99
|
+
if (vp.width <= 0 || vp.height <= 0 || (vp.width === g.viewW && vp.height === g.viewH && vp.safeArea.top === g.viewTop)) return;
|
|
100
|
+
g.viewW = vp.width;
|
|
101
|
+
g.viewH = vp.height;
|
|
102
|
+
g.viewTop = vp.safeArea.top;
|
|
103
|
+
const cam = world.resource(og.Camera);
|
|
104
|
+
if (!cam.ok) return;
|
|
105
|
+
const portrait = vp.width < vp.height;
|
|
106
|
+
// The rectangle the field may use, in CSS pixels: room for the HUD's rows and the tray.
|
|
107
|
+
const top = vp.safeArea.top + (portrait ? 84 : 76);
|
|
108
|
+
const bottom = vp.safeArea.bottom + (portrait ? 176 : 24);
|
|
109
|
+
const right = vp.safeArea.right + (portrait ? 0 : 200);
|
|
110
|
+
const left = vp.safeArea.left + (portrait ? 0 : 200);
|
|
111
|
+
const w = vp.width - left - right;
|
|
112
|
+
const h = vp.height - top - bottom;
|
|
113
|
+
const scale = Math.min(w / (COLS + 0.4), h / (ROWS + 0.4));
|
|
114
|
+
const cx = left + w / 2;
|
|
115
|
+
const cy = top + h / 2;
|
|
116
|
+
const c = cam.value;
|
|
117
|
+
c.orthographic = true;
|
|
118
|
+
c.height = vp.height / scale;
|
|
119
|
+
c.position = { x: COLS / 2 - (cx - vp.width / 2) / scale, y: ROWS / 2 + (cy - vp.height / 2) / scale, z: 50 };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** The settings applied: the buses, the language, the motion. */
|
|
123
|
+
function applyPrefs(world: World, p: PrefsV): void {
|
|
124
|
+
const audio = world.resource(og.Audio);
|
|
125
|
+
if (audio.ok) {
|
|
126
|
+
audio.value.master = p.master;
|
|
127
|
+
audio.value.music = p.music;
|
|
128
|
+
audio.value.sfx = p.effects;
|
|
129
|
+
audio.value.ui = p.effects;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function setLanguage(world: World, p: PrefsV, index: number): void {
|
|
134
|
+
p.language = Math.max(0, Math.min(LANGUAGES.length - 1, index));
|
|
135
|
+
og.i18n.setLocale(world, LANGUAGES[p.language]!.code);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** The settings as og.platform.saveSettings keeps them. */
|
|
139
|
+
function prefsValue(p: PrefsV) {
|
|
140
|
+
return { masterVolume: p.master, musicVolume: p.music, sfxVolume: p.effects, language: LANGUAGES[p.language]!.code, reducedMotion: p.reducedMotion };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** The first ticks: ask for the settings and the best score; apply each when it answers. A best written at a stale revision is read again and the higher written back. */
|
|
144
|
+
function platform(world: World, g: GameV, p: PrefsV): void {
|
|
145
|
+
if (world.tick === 0) {
|
|
146
|
+
p.loadRequest = og.platform.loadSettings(world);
|
|
147
|
+
const b = og.platform.storeGet(world, "best");
|
|
148
|
+
g.bestRequest = b.ok ? b.value : 0;
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (p.loadRequest !== 0) {
|
|
152
|
+
const r = og.platform.result(world, p.loadRequest);
|
|
153
|
+
if (r !== null) {
|
|
154
|
+
p.loadRequest = 0;
|
|
155
|
+
p.loaded = true;
|
|
156
|
+
const v = (r.ok ? r.data : null) as { value?: Record<string, unknown> } | null;
|
|
157
|
+
const s = v?.value ?? null;
|
|
158
|
+
if (s && typeof s === "object") {
|
|
159
|
+
if (typeof s.masterVolume === "number") p.master = s.masterVolume;
|
|
160
|
+
if (typeof s.musicVolume === "number") p.music = s.musicVolume;
|
|
161
|
+
if (typeof s.sfxVolume === "number") p.effects = s.sfxVolume;
|
|
162
|
+
if (typeof s.reducedMotion === "boolean") p.reducedMotion = s.reducedMotion;
|
|
163
|
+
const at = LANGUAGES.findIndex((l) => l.code === s.language);
|
|
164
|
+
if (at >= 0) setLanguage(world, p, at);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (g.bestRequest !== 0) {
|
|
169
|
+
const r = og.platform.result(world, g.bestRequest);
|
|
170
|
+
if (r !== null) {
|
|
171
|
+
g.bestRequest = 0;
|
|
172
|
+
const d = (r.ok ? r.data : null) as { value?: unknown; revision?: number } | null;
|
|
173
|
+
if (d && typeof d.value === "number") g.best = Math.max(g.best, d.value);
|
|
174
|
+
if (d && typeof d.revision === "number") g.bestRevision = d.revision;
|
|
175
|
+
// A best this device holds above the stored one (a write refused as stale) is written again at the revision just read.
|
|
176
|
+
if (d && g.best > (typeof d.value === "number" ? d.value : 0)) {
|
|
177
|
+
const w = og.platform.storeSet(world, { key: "best", value: g.best, revision: g.bestRevision });
|
|
178
|
+
if (w.ok) g.bestWrite = w.value;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (g.bestWrite !== 0) {
|
|
183
|
+
const r = og.platform.result(world, g.bestWrite);
|
|
184
|
+
if (r !== null) {
|
|
185
|
+
g.bestWrite = 0;
|
|
186
|
+
if (r.ok) g.bestRevision = (r.data as { revision: number }).revision;
|
|
187
|
+
else if (r.error?.code === "conflict") {
|
|
188
|
+
// Another device wrote `best` meanwhile: read it again; the answer keeps the higher and writes it back.
|
|
189
|
+
const again = og.platform.storeGet(world, "best");
|
|
190
|
+
g.bestRequest = again.ok ? again.value : 0;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** One HUD capsule: an icon and a number counting to its value. */
|
|
197
|
+
function capsule(t: Theme, id: string, icon: string, value: number, tone: "accent" | "danger" | "fg"): void {
|
|
198
|
+
og.ui.row(id, { gap: t.space.xs, cross: "center", padding: { left: t.space.sm, top: t.space.xs, right: t.space.md, bottom: t.space.xs }, frame: "capsule", background: { token: "surface" }, radius: 999 }, () => {
|
|
199
|
+
og.ui.icon("Icon", icon, { size: 26, tint: { token: tone === "fg" ? "fg" : tone } });
|
|
200
|
+
og.ui.counter("Value", value, { step: "xl", font: "display", durationMs: 300, width: px(56), align: "center" });
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function hud(world: World, theme: Theme, g: GameV, t: TuneV): void {
|
|
205
|
+
const small = phone();
|
|
206
|
+
og.ui.setNavigation(false);
|
|
207
|
+
og.ui.anchor("Purse", { anchor: "topLeft", gap: theme.space.sm }, () => {
|
|
208
|
+
capsule(theme, "Light", "heart", g.lives, g.lives <= 3 ? "danger" : "fg");
|
|
209
|
+
capsule(theme, "Coins", "coin", g.gold, "accent");
|
|
210
|
+
// A refused placement shakes the purse once, with the error sound (og-ui §6).
|
|
211
|
+
if (g.refusedTick === world.tick) og.ui.shake({ sound: true });
|
|
212
|
+
});
|
|
213
|
+
let paused = false;
|
|
214
|
+
og.ui.anchor("Waves", { anchor: "topRight", gap: theme.space.sm, cross: "center" }, () => {
|
|
215
|
+
og.ui.row("Wave", { cross: "center", padding: { left: theme.space.md, top: theme.space.xs, right: theme.space.md, bottom: theme.space.xs }, frame: "capsule", background: { token: "surface" }, radius: 999 }, () => {
|
|
216
|
+
og.ui.label("Label", say(world, "hud.wave", { n: Math.max(1, g.wave), total: WAVES.length }), { step: "lg", font: "display", nowrap: true });
|
|
217
|
+
});
|
|
218
|
+
if (og.ui.actionButton("Pause", say(world, "hud.pause"), { icon: "pause", size: 48 }).clicked) paused = true;
|
|
219
|
+
});
|
|
220
|
+
if (paused) g.paused = true;
|
|
221
|
+
// The tray: the three plants, the selected one in the accent, an unaffordable one disabled; and the next wave.
|
|
222
|
+
og.ui.anchor("Tray", { anchor: small ? "bottom" : "right", direction: small ? "row" : "column", gap: theme.space.sm, cross: "center" }, () => {
|
|
223
|
+
PLANTS.forEach((name, kind) => {
|
|
224
|
+
const price = cost(t, kind);
|
|
225
|
+
const chosen = g.selected === kind;
|
|
226
|
+
og.ui.column(og.ui.idi("Plant", kind), { cross: "center", gap: theme.space.xxs, padding: { left: theme.space.sm, top: theme.space.xs, right: theme.space.sm, bottom: theme.space.sm }, frame: "card", background: { token: "surface" }, radius: 18 }, () => {
|
|
227
|
+
og.ui.row("Top", { cross: "center", gap: theme.space.xs }, () => {
|
|
228
|
+
og.ui.image("Picture", { texture: g.sheet as unknown as never, uv: uvOf(PICTURE[kind]!), width: px(small ? 32 : 44), height: px(small ? 32 : 44) });
|
|
229
|
+
// The price: muted when the purse covers it, in danger's ink when it does not.
|
|
230
|
+
og.ui.label("Price", `${price}`, { step: "lg", font: "display", color: { token: g.gold >= price ? "fgMuted" : "danger" }, nowrap: true, width: px(40), align: "center" });
|
|
231
|
+
});
|
|
232
|
+
if (og.ui.button("Pick", say(world, `tower.${name}`), { variant: chosen ? "primary" : "secondary", size: small ? "medium" : "small", width: px(small ? 86 : 104) }).clicked) g.selected = kind;
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
if (!small) callButton(world, g, small);
|
|
236
|
+
});
|
|
237
|
+
// On a phone the call for the next wave sits over the tray, in the thumb's reach.
|
|
238
|
+
if (small) og.ui.anchor("Call", { anchor: "bottom", offsetY: -112 }, () => callButton(world, g, small));
|
|
239
|
+
if (g.wave === 0 && !small) {
|
|
240
|
+
og.ui.anchor("Hint", { anchor: "bottom", padding: { left: theme.space.md, top: theme.space.xs, right: theme.space.md, bottom: theme.space.xs }, frame: "capsule", background: { token: "surface" }, radius: 999 }, () => {
|
|
241
|
+
og.ui.label("Text", say(world, "hud.hint"), { nowrap: true });
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/** The next wave, early: shown in the break, with the seconds left (an early call pays them as coins). */
|
|
247
|
+
function callButton(world: World, g: GameV, small: boolean): void {
|
|
248
|
+
if (g.inWave || g.wave >= WAVES.length) return;
|
|
249
|
+
const secs = Math.ceil(g.breakTicks / 60);
|
|
250
|
+
if (og.ui.button("Next", `${say(world, "hud.next")} ${secs}`, { variant: "secondary", size: small ? "medium" : "medium" }).clicked) g.callNext = true;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** The settings dialog: volumes, language, motion; saved through og.platform when it closes. */
|
|
254
|
+
function settings(world: World, theme: Theme, g: GameV, p: PrefsV): void {
|
|
255
|
+
let done = false;
|
|
256
|
+
const before = JSON.stringify(prefsValue(p));
|
|
257
|
+
const m = og.ui.modal("Settings", g.settingsOpen, { title: say(world, "settings.title"), width: px(Math.min(420, og.ui.frameViewport().width - 32)) }, () => {
|
|
258
|
+
const slider = (id: string, key: string, value: number): number => {
|
|
259
|
+
let out = value;
|
|
260
|
+
og.ui.row(id, { width: grow, gap: theme.space.md, cross: "center" }, () => {
|
|
261
|
+
og.ui.label("Label", say(world, key), { width: px(110), nowrap: true });
|
|
262
|
+
out = og.ui.slider("Slider", value, { step: 0.05 }).value;
|
|
263
|
+
og.ui.label("Value", `${Math.round(out * 100)}`, { width: px(40), align: "end", font: "mono", nowrap: true });
|
|
264
|
+
});
|
|
265
|
+
return out;
|
|
266
|
+
};
|
|
267
|
+
p.master = slider("Master", "settings.master", p.master);
|
|
268
|
+
p.music = slider("Music", "settings.music", p.music);
|
|
269
|
+
p.effects = slider("Effects", "settings.effects", p.effects);
|
|
270
|
+
og.ui.label("LanguageLabel", say(world, "settings.language"), { color: { token: "fgMuted" } });
|
|
271
|
+
const r = og.ui.radio("Language", LANGUAGES.map((l) => say(world, l.key)), p.language, { horizontal: true });
|
|
272
|
+
if (r.selected !== p.language) setLanguage(world, p, r.selected);
|
|
273
|
+
p.reducedMotion = og.ui.toggle("Motion", p.reducedMotion, say(world, "settings.motion")).on;
|
|
274
|
+
og.ui.row("Footer", { width: grow, align: "end" }, () => {
|
|
275
|
+
if (og.ui.button("Done", say(world, "settings.done"), { variant: "primary" }).clicked) done = true;
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
if (JSON.stringify(prefsValue(p)) !== before) applyPrefs(world, p);
|
|
279
|
+
if (g.settingsOpen && (done || m.dismissed)) {
|
|
280
|
+
g.settingsOpen = false;
|
|
281
|
+
must(og.platform.saveSettings(world, prefsValue(p)));
|
|
282
|
+
p.saves += 1;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/** The end card: won or lost, stars by the light left, the score counting up, the best, the round's numbers. */
|
|
287
|
+
function endCard(world: World, theme: Theme, g: GameV, t: TuneV): "retry" | "menu" | null {
|
|
288
|
+
let chose: "retry" | "menu" | null = null;
|
|
289
|
+
const stars = !g.won ? 0 : g.lives >= t.startLives - 1 ? 3 : g.lives * 2 >= t.startLives ? 2 : 1;
|
|
290
|
+
const since = world.tick - g.overTick;
|
|
291
|
+
og.ui.modal("End", g.phase === Phase.Over, { title: say(world, g.won ? "over.won" : "over.lost"), locked: true, width: px(Math.min(400, og.ui.frameViewport().width - 32)) }, () => {
|
|
292
|
+
og.ui.row("Stars", { width: grow, align: "center", gap: theme.space.sm }, () => {
|
|
293
|
+
for (let k = 0; k < 3; k++) {
|
|
294
|
+
const lit = k < stars && since >= 20 + k * 12;
|
|
295
|
+
og.ui.transition(og.ui.idi("Star", k), true, { kind: "scale" }, () => {
|
|
296
|
+
og.ui.icon("Mark", "star", { size: 40, tint: { token: lit ? "accent" : "fillStrong" } });
|
|
297
|
+
});
|
|
298
|
+
if (lit && since === 20 + k * 12) og.ui.burst({ count: 10 });
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
og.ui.counter("Score", g.score, { from: 0, durationMs: 900, step: "displayMd", font: "display", align: "center", width: grow });
|
|
302
|
+
og.ui.row("BestRow", { width: grow, align: "center", gap: theme.space.sm, cross: "center" }, () => {
|
|
303
|
+
og.ui.label("Best", say(world, "over.best", { n: g.best }), { color: { token: "fgMuted" }, nowrap: true });
|
|
304
|
+
if (g.newBest) og.ui.transition("NewBest", since > 50, { kind: "pop" }, () => og.ui.badge("Badge", say(world, "over.newBest"), "accent"));
|
|
305
|
+
});
|
|
306
|
+
og.ui.column("Stats", { width: grow, gap: 0 }, () => {
|
|
307
|
+
og.ui.keyValue("Waves", say(world, "over.waves"), `${g.won ? g.wave : Math.max(0, g.wave - 1)}/${WAVES.length}`, true);
|
|
308
|
+
og.ui.keyValue("Kills", say(world, "over.kills"), `${g.kills}`, true);
|
|
309
|
+
og.ui.keyValue("Lives", say(world, "over.lives"), `${g.lives}/${t.startLives}`, true);
|
|
310
|
+
});
|
|
311
|
+
og.ui.row("Actions", { width: grow, gap: theme.space.sm }, () => {
|
|
312
|
+
if (og.ui.button("Retry", say(world, "over.retry"), { variant: "primary", width: grow }).clicked) chose = "retry";
|
|
313
|
+
if (og.ui.button("Menu", say(world, "over.menu"), { width: grow }).clicked) chose = "menu";
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
return chose;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/** The screens, the camera's framing, the buses, the platform's answers. */
|
|
320
|
+
export const Ui = defineSystem("Ui", { reads: [Tuning], writes: [Game, Prefs, og.Camera, og.Audio], after: ["Visitors"] }, (_q, time, world) => {
|
|
321
|
+
const game = world.resource(Game);
|
|
322
|
+
const prefs = world.resource(Prefs);
|
|
323
|
+
if (!game.ok || !prefs.ok) return;
|
|
324
|
+
const g = game.value;
|
|
325
|
+
const t = lazyTuning(world);
|
|
326
|
+
const p = prefs.value;
|
|
327
|
+
platform(world, g, p);
|
|
328
|
+
if (time.tick === 0) applyPrefs(world, p);
|
|
329
|
+
frameCamera(world, g);
|
|
330
|
+
// Paused: the garden holds (time scale 0); playing: it runs at 1 (og-feel §3: never left below 1).
|
|
331
|
+
const hold = g.phase === Phase.Play && (g.paused || g.settingsOpen);
|
|
332
|
+
if (hold !== g.held) {
|
|
333
|
+
must(og.time.setScale(world, hold ? 0 : 1));
|
|
334
|
+
g.held = hold;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const theme = THEME;
|
|
338
|
+
const screen = g.phase === Phase.Title ? "title" : g.phase === Phase.Play ? "play" : "over";
|
|
339
|
+
const shown = og.ui.screenTransition("Screens", screen, { kind: p.reducedMotion ? "fade" : "iris", durationMs: 600 }).shown;
|
|
340
|
+
if (shown !== "title") g.leftTitle = true;
|
|
341
|
+
if (shown === "title") {
|
|
342
|
+
og.ui.setNavigation(true);
|
|
343
|
+
const r = og.ui.mainMenu("Title", {
|
|
344
|
+
title: say(world, "title.name"),
|
|
345
|
+
subtitle: say(world, "title.tagline"),
|
|
346
|
+
items: [
|
|
347
|
+
{ id: "play", label: say(world, "title.play"), primary: true },
|
|
348
|
+
{ id: "settings", label: say(world, "title.settings") },
|
|
349
|
+
],
|
|
350
|
+
footer: say(world, "title.footer"),
|
|
351
|
+
// The title the game opens on is built settled: the web draws it behind the play gate, where
|
|
352
|
+
// the skin's entrance would stand part-way until the tap (og-platform-sdk §3). Later titles enter.
|
|
353
|
+
instant: !g.leftTitle,
|
|
354
|
+
});
|
|
355
|
+
if (!g.settingsOpen && r.selected === "play") startRound(world, g, t);
|
|
356
|
+
if (r.selected === "settings") g.settingsOpen = true;
|
|
357
|
+
} else if (shown === "play") {
|
|
358
|
+
hud(world, theme, g, t);
|
|
359
|
+
const m = og.ui.pauseMenu("Pause", {
|
|
360
|
+
open: g.paused && !g.settingsOpen,
|
|
361
|
+
title: say(world, "pause.title"),
|
|
362
|
+
items: [
|
|
363
|
+
{ id: "resume", label: say(world, "pause.resume"), primary: true },
|
|
364
|
+
{ id: "settings", label: say(world, "pause.settings") },
|
|
365
|
+
{ id: "quit", label: say(world, "pause.quit") },
|
|
366
|
+
],
|
|
367
|
+
});
|
|
368
|
+
if (m.selected === "resume") g.paused = false;
|
|
369
|
+
if (m.selected === "settings") g.settingsOpen = true;
|
|
370
|
+
if (m.selected === "quit") {
|
|
371
|
+
g.paused = false;
|
|
372
|
+
g.phase = Phase.Title;
|
|
373
|
+
}
|
|
374
|
+
} else {
|
|
375
|
+
og.ui.setNavigation(true);
|
|
376
|
+
const c = endCard(world, theme, g, t);
|
|
377
|
+
if (c === "retry") startRound(world, g, t);
|
|
378
|
+
if (c === "menu") g.phase = Phase.Title;
|
|
379
|
+
}
|
|
380
|
+
settings(world, theme, g, p);
|
|
381
|
+
if (g.language !== p.language) g.language = p.language;
|
|
382
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// The core loop through real input: Play on the title, a hedge picked on
|
|
2
|
+
// the tray and tapped onto the lawn (the tap also moves the cursor there),
|
|
3
|
+
// two thorns set beside it with the keys (1, the arrows, Space), then the first wave: visitors come through the gate and
|
|
4
|
+
// walk to the doorstep, the thorns see them (og.ai), shoot, and every
|
|
5
|
+
// visitor turned away pays its bounty.
|
|
6
|
+
import { playtest } from "@origingame/engine/playtest";
|
|
7
|
+
import { game, PLAY, play, press, TITLE, tap, tapCell } from "./lib.ts";
|
|
8
|
+
|
|
9
|
+
export default playtest({
|
|
10
|
+
name: "title, plants set by tap and by keys, the first wave walks in and is shot down",
|
|
11
|
+
commands: [
|
|
12
|
+
"0.3:screenshot:title.png",
|
|
13
|
+
"0.4:get:Game:title.json",
|
|
14
|
+
play(0.5),
|
|
15
|
+
tap("Plant#2/Pick", 1.3),
|
|
16
|
+
tapCell(4, 4, 1.5),
|
|
17
|
+
press("Digit1", 1.8),
|
|
18
|
+
press("ArrowLeft", 2.3),
|
|
19
|
+
press("Space", 2.4),
|
|
20
|
+
press("ArrowRight", 2.5),
|
|
21
|
+
press("ArrowRight", 2.6),
|
|
22
|
+
press("Space", 2.7),
|
|
23
|
+
"2.9:get:Game:set.json",
|
|
24
|
+
"2.95:screenshot:play.png",
|
|
25
|
+
"3.9:dump_entity:visitor-0:walker.json",
|
|
26
|
+
"4.2:dump_entity:visitor-0:walker2.json",
|
|
27
|
+
"8.0:screenshot:wave.png",
|
|
28
|
+
"13.0:get:Game:fought.json",
|
|
29
|
+
"13.1:quit",
|
|
30
|
+
].join(";"),
|
|
31
|
+
check(run, t) {
|
|
32
|
+
t.equal(run.warnings.join("; "), "", "the script ran without warnings");
|
|
33
|
+
t.ok(run.quit, "the script reached quit");
|
|
34
|
+
t.equal(game(run, "title.json").phase, TITLE, "the game opens on the title");
|
|
35
|
+
const set = game(run, "set.json");
|
|
36
|
+
t.equal(set.phase, PLAY, "Play started a round");
|
|
37
|
+
t.equal(set.placed, 3, "a hedge by tap and two thorns by keys");
|
|
38
|
+
t.equal(set.gold, 150 - 10 - 50 - 50, "each plant took its price");
|
|
39
|
+
t.equal(set.selected, 0, "1 picked the thorn back");
|
|
40
|
+
t.ok(set.cursorX === 5 && set.cursorY === 4, `the tap put the cursor on (4, 4) and the arrows walked it to (5, 4) (${set.cursorX}, ${set.cursorY})`);
|
|
41
|
+
t.equal(set.refused, 0, "nothing was refused");
|
|
42
|
+
const a = run.json<{ components: Record<string, { position?: number[]; seeking?: boolean }> }>("walker.json").components;
|
|
43
|
+
const b = run.json<{ components: Record<string, { position?: number[] }> }>("walker2.json").components;
|
|
44
|
+
t.equal(a["og.NavAgent"]!.seeking, true, "the first visitor walks the flow field");
|
|
45
|
+
const step = Math.hypot(b["og.Transform"]!.position![0]! - a["og.Transform"]!.position![0]!, b["og.Transform"]!.position![1]! - a["og.Transform"]!.position![1]!);
|
|
46
|
+
t.ok(step > 0.25 && step < 0.5, `it walks at a beetle's pace (${step.toFixed(2)} m in 0.3 s)`);
|
|
47
|
+
const fought = game(run, "fought.json");
|
|
48
|
+
t.equal(fought.wave, 1, "the first wave came");
|
|
49
|
+
t.ok(fought.shots >= 6, `the thorns shot at what they saw (${fought.shots} shots)`);
|
|
50
|
+
t.ok(fought.kills >= 3, `visitors were turned away (${fought.kills})`);
|
|
51
|
+
t.ok(fought.gold > set.gold, `bounties filled the purse (${set.gold} to ${fought.gold})`);
|
|
52
|
+
t.frame(["title.png", "play.png", "wave.png"], () => {
|
|
53
|
+
for (const f of ["title.png", "play.png", "wave.png"]) t.equal(run.png(f).width, 1280, `${f} is 1280 wide`);
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Three frames at 1280×720 compared with references/<tier>/: the title over
|
|
2
|
+
// the garden, the first wave in a small maze (a thorn shooting, a frosted
|
|
3
|
+
// visitor, the cursor and its range), and the won round's end card.
|
|
4
|
+
// `OG_FX_CAPTURE=1 og test .` records this tier's references.
|
|
5
|
+
import { playtest } from "@origingame/engine/playtest";
|
|
6
|
+
import { checkFrames } from "./frames.ts";
|
|
7
|
+
|
|
8
|
+
const FILES = ["title.png", "wave.png", "end.png"];
|
|
9
|
+
|
|
10
|
+
export default playtest({
|
|
11
|
+
name: "the title, a wave in the maze and the end card match their reference frames",
|
|
12
|
+
size: "1280x720",
|
|
13
|
+
commands: [
|
|
14
|
+
"0.5:screenshot:title.png",
|
|
15
|
+
"0.6:begin",
|
|
16
|
+
"0.7:plant:hedge:4:4",
|
|
17
|
+
"0.7:plant:thorn:3:4",
|
|
18
|
+
"0.7:plant:frost:5:4",
|
|
19
|
+
"6.0:screenshot:wave.png",
|
|
20
|
+
"6.1:win",
|
|
21
|
+
"8.0:screenshot:end.png",
|
|
22
|
+
"8.1:quit",
|
|
23
|
+
].join(";"),
|
|
24
|
+
check(run, t) {
|
|
25
|
+
t.equal(run.warnings.join("; "), "", "the script ran without warnings");
|
|
26
|
+
t.frame(FILES, () => {
|
|
27
|
+
for (const f of FILES) t.equal(run.png(f).width, 1280, `${f} is 1280 wide`);
|
|
28
|
+
});
|
|
29
|
+
checkFrames(run, t, FILES, "");
|
|
30
|
+
},
|
|
31
|
+
});
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// The reference-frame check: decode the PNGs a run wrote and compare them
|
|
2
|
+
// with references/<tier>/ under og-tests' tolerance (a channel off by more
|
|
3
|
+
// than 32/255 is an outlier; fail above 0.5 % outliers or an RGB RMSE above
|
|
4
|
+
// 0.01). A tier without its own references compares with `metal` and says
|
|
5
|
+
// so. `OG_FX_CAPTURE=1 og test .` records this tier's references instead.
|
|
6
|
+
// (Copied from templates/fx-showcase/tests/frames.ts so the archetype stands alone.)
|
|
7
|
+
|
|
8
|
+
import { copyFileSync, existsSync, mkdirSync, readFileSync } from "node:fs";
|
|
9
|
+
import { dirname, join, resolve } from "node:path";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
11
|
+
import { inflateSync } from "node:zlib";
|
|
12
|
+
import type { PlaytestChecks, PlaytestRun } from "@origingame/engine/playtest";
|
|
13
|
+
|
|
14
|
+
export interface Image {
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
/** RGBA8 rows. */
|
|
18
|
+
rgba: Uint8Array;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** An 8-bit RGB or RGBA, non-interlaced PNG, unfiltered. */
|
|
22
|
+
export function decodePng(bytes: Uint8Array): Image {
|
|
23
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
24
|
+
let at = 8;
|
|
25
|
+
let width = 0;
|
|
26
|
+
let height = 0;
|
|
27
|
+
let channels = 4;
|
|
28
|
+
const idat: Uint8Array[] = [];
|
|
29
|
+
while (at < bytes.length) {
|
|
30
|
+
const len = view.getUint32(at);
|
|
31
|
+
const type = String.fromCharCode(...bytes.subarray(at + 4, at + 8));
|
|
32
|
+
const data = bytes.subarray(at + 8, at + 8 + len);
|
|
33
|
+
if (type === "IHDR") {
|
|
34
|
+
width = view.getUint32(at + 8);
|
|
35
|
+
height = view.getUint32(at + 12);
|
|
36
|
+
const depth = data[8]!;
|
|
37
|
+
const color = data[9]!;
|
|
38
|
+
if (depth !== 8 || (color !== 6 && color !== 2) || data[12] !== 0) throw new Error(`unsupported PNG (depth ${depth}, colour ${color}, interlace ${data[12]})`);
|
|
39
|
+
channels = color === 6 ? 4 : 3;
|
|
40
|
+
} else if (type === "IDAT") idat.push(data);
|
|
41
|
+
else if (type === "IEND") break;
|
|
42
|
+
at += 12 + len;
|
|
43
|
+
}
|
|
44
|
+
const raw = inflateSync(Buffer.concat(idat));
|
|
45
|
+
const stride = width * channels;
|
|
46
|
+
const out = new Uint8Array(width * height * 4);
|
|
47
|
+
const prev = new Uint8Array(stride);
|
|
48
|
+
const cur = new Uint8Array(stride);
|
|
49
|
+
for (let y = 0; y < height; y++) {
|
|
50
|
+
const filter = raw[y * (stride + 1)]!;
|
|
51
|
+
const line = raw.subarray(y * (stride + 1) + 1, (y + 1) * (stride + 1));
|
|
52
|
+
for (let i = 0; i < stride; i++) {
|
|
53
|
+
const a = i >= channels ? cur[i - channels]! : 0;
|
|
54
|
+
const b = prev[i]!;
|
|
55
|
+
const c = i >= channels ? prev[i - channels]! : 0;
|
|
56
|
+
let v = line[i]!;
|
|
57
|
+
if (filter === 1) v += a;
|
|
58
|
+
else if (filter === 2) v += b;
|
|
59
|
+
else if (filter === 3) v += (a + b) >> 1;
|
|
60
|
+
else if (filter === 4) {
|
|
61
|
+
const p = a + b - c;
|
|
62
|
+
const pa = Math.abs(p - a), pb = Math.abs(p - b), pc = Math.abs(p - c);
|
|
63
|
+
v += pa <= pb && pa <= pc ? a : pb <= pc ? b : c;
|
|
64
|
+
}
|
|
65
|
+
cur[i] = v & 255;
|
|
66
|
+
}
|
|
67
|
+
for (let x = 0; x < width; x++) {
|
|
68
|
+
for (let k = 0; k < 4; k++) out[(y * width + x) * 4 + k] = k < channels ? cur[x * channels + k]! : 255;
|
|
69
|
+
}
|
|
70
|
+
prev.set(cur);
|
|
71
|
+
}
|
|
72
|
+
return { width, height, rgba: out };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** og-tests' rule: outlier fraction and RGB RMSE between two equal-size frames. */
|
|
76
|
+
export function difference(a: Image, b: Image): { outliers: number; rmse: number } {
|
|
77
|
+
if (a.width !== b.width || a.height !== b.height) return { outliers: 1, rmse: 1 };
|
|
78
|
+
let outliers = 0;
|
|
79
|
+
let sum = 0;
|
|
80
|
+
const n = a.width * a.height;
|
|
81
|
+
for (let p = 0; p < n; p++) {
|
|
82
|
+
let out = false;
|
|
83
|
+
for (let k = 0; k < 3; k++) {
|
|
84
|
+
const d = Math.abs(a.rgba[p * 4 + k]! - b.rgba[p * 4 + k]!);
|
|
85
|
+
if (d > 32) out = true;
|
|
86
|
+
const f = d / 255;
|
|
87
|
+
sum += f * f;
|
|
88
|
+
}
|
|
89
|
+
if (out) outliers++;
|
|
90
|
+
}
|
|
91
|
+
return { outliers: outliers / n, rmse: Math.sqrt(sum / (n * 3)) };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** The playtest's output directory (the bundled playtest runs from it). */
|
|
95
|
+
export function outDir(): string {
|
|
96
|
+
return dirname(fileURLToPath(import.meta.url));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** The project's references/, from its og-out/test/<name>/. */
|
|
100
|
+
export function referencesDir(): string {
|
|
101
|
+
return resolve(outDir(), "..", "..", "..", "references");
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Compares each screenshot with its reference (`<prefix><file>`), or records it. */
|
|
105
|
+
export function checkFrames(run: PlaytestRun, t: PlaytestChecks, files: readonly string[], prefix: string): void {
|
|
106
|
+
// Read only where there is a renderer: without one (tier `none`) each frame is
|
|
107
|
+
// reported "no renderer, frame unchecked" and every other check still runs.
|
|
108
|
+
t.frame(files, () => {
|
|
109
|
+
const refs = referencesDir();
|
|
110
|
+
t.ok(existsSync(refs) || process.env.OG_FX_CAPTURE !== undefined, `the references directory exists at ${refs}`);
|
|
111
|
+
const own = join(refs, run.tier);
|
|
112
|
+
const capture = process.env.OG_FX_CAPTURE !== undefined;
|
|
113
|
+
for (const f of files) {
|
|
114
|
+
const actual = join(outDir(), f);
|
|
115
|
+
// Each file on its own: this tier's reference where it has one, metal's otherwise.
|
|
116
|
+
const mine = join(own, prefix + f);
|
|
117
|
+
const ref = capture || existsSync(mine) ? mine : join(refs, "metal", prefix + f);
|
|
118
|
+
if (ref !== mine) process.stdout.write(` note: no ${run.tier} reference for ${prefix}${f}; comparing with metal\n`);
|
|
119
|
+
if (capture) {
|
|
120
|
+
mkdirSync(own, { recursive: true });
|
|
121
|
+
copyFileSync(actual, ref);
|
|
122
|
+
t.ok(true, `recorded ${ref}`);
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (!existsSync(ref)) {
|
|
126
|
+
t.ok(false, `${ref} is missing: record it with OG_FX_CAPTURE=1 og test .`);
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
const d = difference(decodePng(readFileSync(actual)), decodePng(readFileSync(ref)));
|
|
130
|
+
process.stdout.write(` ${f}: ${(d.outliers * 100).toFixed(3)} % outliers, RMSE ${d.rmse.toFixed(5)} against ${ref}\n`);
|
|
131
|
+
t.ok(d.outliers <= 0.005 && d.rmse <= 0.01, `${f} matches ${prefix}${f}: ${(d.outliers * 100).toFixed(3)} % outliers (≤ 0.5 %), RMSE ${d.rmse.toFixed(5)} (≤ 0.01)`);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|