@origingame/create-game 0.0.0-stage → 0.1.1
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/gitignore +8 -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/gitignore +8 -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/gitignore +8 -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/gitignore +8 -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/gitignore +8 -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/gitignore +8 -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/gitignore +8 -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/gitignore +8 -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 +503 -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/gitignore +8 -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,350 @@
|
|
|
1
|
+
// Lamp Dive's screens on og.ui and the skin in assets/skins/lampdive (the
|
|
2
|
+
// engine's pixel pack in tomb colours): the title, the HUD (health, strike,
|
|
3
|
+
// armour and gold in the top-left corner, the floor and pause in the
|
|
4
|
+
// top-right, the draught and, on a touch screen, Wait and a d-pad along the
|
|
5
|
+
// bottom), the pause menu, the settings dialog and the run's summary when
|
|
6
|
+
// the lamp goes out or the relic is taken. Screens change through a
|
|
7
|
+
// dissolve (a fade with reduced motion). Every string is a key of
|
|
8
|
+
// assets/strings/*.ogt.
|
|
9
|
+
//
|
|
10
|
+
// The Ui system also starts dives (a fresh seed from og.Rng), ends them a
|
|
11
|
+
// beat after the lamp goes out or the relic is taken, sizes the camera for
|
|
12
|
+
// the surface, sets the buses and keeps the settings and the dive record
|
|
13
|
+
// in og.platform (the record written at the revision read, and merged when
|
|
14
|
+
// another device wrote it first).
|
|
15
|
+
|
|
16
|
+
import { og, defineSystem } from "@origingame/engine";
|
|
17
|
+
import type { Value, World } from "@origingame/engine";
|
|
18
|
+
import { FOES, Game, Phase, Prefs, Tuning } from "./components.ts";
|
|
19
|
+
import { lazyTuning, must, OVER_DELAY } from "./systems.ts";
|
|
20
|
+
|
|
21
|
+
export const LANGUAGES = [
|
|
22
|
+
{ code: "en", key: "lang.en" },
|
|
23
|
+
{ code: "zh-CN", key: "lang.zh" },
|
|
24
|
+
] as const;
|
|
25
|
+
|
|
26
|
+
/** The floors of a dive. */
|
|
27
|
+
export const FLOORS = 2;
|
|
28
|
+
|
|
29
|
+
/** The tokens' spacing scale in CSS px (og.ui.frameTheme answers it too, but builds the whole theme each call). */
|
|
30
|
+
const S = { xxs: 2, xs: 4, sm: 8, md: 12, lg: 16 } as const;
|
|
31
|
+
|
|
32
|
+
type GameV = Value<typeof Game>;
|
|
33
|
+
type PrefsV = Value<typeof Prefs>;
|
|
34
|
+
|
|
35
|
+
export function say(world: World, key: string, args?: Record<string, string | number>): string {
|
|
36
|
+
return og.i18n.t(world, key, args);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const grow = { kind: "grow" } as const;
|
|
40
|
+
const px = (n: number) => ({ kind: "fixed", px: n }) as const;
|
|
41
|
+
|
|
42
|
+
/** A new dive: a fresh seed, the lamp-bearer whole, floor 1 carved on this tick. */
|
|
43
|
+
export function startDive(world: World, g: GameV): void {
|
|
44
|
+
const t = lazyTuning(world);
|
|
45
|
+
const rng = world.resource(og.Rng);
|
|
46
|
+
g.seed = rng.ok ? rng.value.integer(1, 1_000_000_000) : 1;
|
|
47
|
+
g.phase = Phase.Play;
|
|
48
|
+
g.paused = false;
|
|
49
|
+
g.won = false;
|
|
50
|
+
g.floor = 1;
|
|
51
|
+
g.deepest = 1;
|
|
52
|
+
g.hpMax = t.heroHp;
|
|
53
|
+
g.hp = t.heroHp;
|
|
54
|
+
g.attack = t.heroAttack;
|
|
55
|
+
g.armour = 0;
|
|
56
|
+
g.lamp = t.lamp;
|
|
57
|
+
g.potions = 1;
|
|
58
|
+
g.gold = 0;
|
|
59
|
+
g.kills = 0;
|
|
60
|
+
g.hits = 0;
|
|
61
|
+
g.hurts = 0;
|
|
62
|
+
g.finds = 0;
|
|
63
|
+
g.turns = 0;
|
|
64
|
+
g.killedBy = -1;
|
|
65
|
+
g.overTicks = 0;
|
|
66
|
+
g.lock = 0;
|
|
67
|
+
g.queued = 0;
|
|
68
|
+
g.foesTurn = false;
|
|
69
|
+
g.newRecord = false;
|
|
70
|
+
g.build = true;
|
|
71
|
+
g.dives += 1;
|
|
72
|
+
saveRecord(world, g);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The dive record ({dives, relics}) written at the revision it was read at. */
|
|
76
|
+
function saveRecord(world: World, g: GameV): void {
|
|
77
|
+
const r = og.platform.storeSet(world, { key: "record", value: { dives: g.dives, relics: g.relics }, revision: g.recordRevision });
|
|
78
|
+
if (r.ok) g.recordWrite = r.value;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function applyPrefs(world: World, p: PrefsV): void {
|
|
82
|
+
const audio = world.resource(og.Audio);
|
|
83
|
+
if (audio.ok) {
|
|
84
|
+
audio.value.master = p.master;
|
|
85
|
+
audio.value.music = p.music;
|
|
86
|
+
audio.value.sfx = p.effects;
|
|
87
|
+
audio.value.ui = p.effects;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function setLanguage(world: World, p: PrefsV, index: number): void {
|
|
92
|
+
p.language = Math.max(0, Math.min(LANGUAGES.length - 1, index));
|
|
93
|
+
og.i18n.setLocale(world, LANGUAGES[p.language]!.code);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function prefsValue(p: PrefsV) {
|
|
97
|
+
return { masterVolume: p.master, musicVolume: p.music, sfxVolume: p.effects, language: LANGUAGES[p.language]!.code, reducedMotion: p.reducedMotion };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* og.platform: the settings and the record asked for on tick 0 and applied
|
|
102
|
+
* when they answer; a record write refused for a stale revision (another
|
|
103
|
+
* device dived meanwhile) is read again, merged (the stored counts plus
|
|
104
|
+
* what this device added since it last read or wrote them) and written at
|
|
105
|
+
* the new revision.
|
|
106
|
+
*/
|
|
107
|
+
function platform(world: World, g: GameV, p: PrefsV): void {
|
|
108
|
+
if (world.tick === 0) {
|
|
109
|
+
p.loadRequest = og.platform.loadSettings(world);
|
|
110
|
+
const r = og.platform.storeGet(world, "record");
|
|
111
|
+
g.recordRequest = r.ok ? r.value : 0;
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (p.loadRequest !== 0) {
|
|
115
|
+
const r = og.platform.result(world, p.loadRequest);
|
|
116
|
+
if (r !== null) {
|
|
117
|
+
p.loadRequest = 0;
|
|
118
|
+
const s = ((r.ok ? r.data : null) as { value?: Record<string, unknown> } | null)?.value ?? null;
|
|
119
|
+
if (s && typeof s === "object") {
|
|
120
|
+
if (typeof s.masterVolume === "number") p.master = s.masterVolume;
|
|
121
|
+
if (typeof s.musicVolume === "number") p.music = s.musicVolume;
|
|
122
|
+
if (typeof s.sfxVolume === "number") p.effects = s.sfxVolume;
|
|
123
|
+
if (typeof s.reducedMotion === "boolean") p.reducedMotion = s.reducedMotion;
|
|
124
|
+
const at = LANGUAGES.findIndex((l) => l.code === s.language);
|
|
125
|
+
if (at >= 0) setLanguage(world, p, at);
|
|
126
|
+
applyPrefs(world, p);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (g.recordRequest !== 0) {
|
|
131
|
+
const r = og.platform.result(world, g.recordRequest);
|
|
132
|
+
if (r !== null) {
|
|
133
|
+
g.recordRequest = 0;
|
|
134
|
+
const d = (r.ok ? r.data : null) as { value?: { dives?: number; relics?: number } | null; revision?: number } | null;
|
|
135
|
+
// The stored counts plus what this device added since it last read or wrote them.
|
|
136
|
+
const dives = d?.value?.dives ?? 0;
|
|
137
|
+
const relics = d?.value?.relics ?? 0;
|
|
138
|
+
g.dives = dives + g.dives - g.recordDives;
|
|
139
|
+
g.relics = relics + g.relics - g.recordRelics;
|
|
140
|
+
g.recordDives = dives;
|
|
141
|
+
g.recordRelics = relics;
|
|
142
|
+
if (typeof d?.revision === "number") g.recordRevision = d.revision;
|
|
143
|
+
if (g.recordMerge) {
|
|
144
|
+
g.recordMerge = false;
|
|
145
|
+
saveRecord(world, g);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (g.recordWrite !== 0) {
|
|
150
|
+
const r = og.platform.result(world, g.recordWrite);
|
|
151
|
+
if (r !== null) {
|
|
152
|
+
g.recordWrite = 0;
|
|
153
|
+
if (r.ok) {
|
|
154
|
+
g.recordRevision = (r.data as { revision: number }).revision;
|
|
155
|
+
g.recordDives = g.dives;
|
|
156
|
+
g.recordRelics = g.relics;
|
|
157
|
+
}
|
|
158
|
+
else if (r.error?.code === "conflict") {
|
|
159
|
+
// Someone else wrote the record: read it again and write the merge.
|
|
160
|
+
g.recordConflicts += 1;
|
|
161
|
+
g.recordMerge = true;
|
|
162
|
+
const again = og.platform.storeGet(world, "record");
|
|
163
|
+
g.recordRequest = again.ok ? again.value : 0;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function capsule(id: string, build: () => void): void {
|
|
170
|
+
og.ui.row(id, { gap: S.xs, cross: "center", padding: { left: S.sm, top: S.xs, right: S.md, bottom: S.xs }, frame: "capsule", background: { token: "surface" } }, build);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function hud(world: World, g: GameV): void {
|
|
174
|
+
const vp = og.ui.frameViewport();
|
|
175
|
+
const touch = vp.coarsePointer;
|
|
176
|
+
og.ui.setNavigation(false);
|
|
177
|
+
og.ui.anchor("Status", { anchor: "topLeft", direction: "column", gap: S.sm }, () => {
|
|
178
|
+
capsule("Health", () => {
|
|
179
|
+
og.ui.icon("Heart", "heart", { size: 22, tint: { token: g.hp * 3 <= g.hpMax ? "danger" : "fg" } });
|
|
180
|
+
og.ui.meter("Bar", g.hp, g.hpMax, { kind: "health", label: `${g.hp}/${g.hpMax}`, width: px(touch ? 110 : 150) });
|
|
181
|
+
});
|
|
182
|
+
capsule("Stats", () => {
|
|
183
|
+
og.ui.icon("Sword", "sword", { size: 20 });
|
|
184
|
+
og.ui.counter("Attack", g.attack, { font: "mono", width: px(22) });
|
|
185
|
+
og.ui.icon("Shield", "shield", { size: 20 });
|
|
186
|
+
og.ui.counter("Armour", g.armour, { font: "mono", width: px(22) });
|
|
187
|
+
og.ui.icon("Coin", "coin", { size: 20, tint: { token: "accent" } });
|
|
188
|
+
og.ui.counter("Gold", g.gold, { font: "mono", width: px(40) });
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
let paused = false;
|
|
192
|
+
og.ui.anchor("Depth", { anchor: "topRight", gap: S.sm, cross: "center" }, () => {
|
|
193
|
+
capsule("Floor", () => og.ui.label("Label", say(world, "hud.floor", { n: g.floor, total: FLOORS }), { step: "lg", nowrap: true }));
|
|
194
|
+
if (og.ui.actionButton("Pause", say(world, "hud.pause"), { icon: "pause", size: 48 }).clicked) paused = true;
|
|
195
|
+
});
|
|
196
|
+
if (paused) g.paused = true;
|
|
197
|
+
og.ui.anchor("Hands", { anchor: "bottomLeft", gap: S.md, cross: "end" }, () => {
|
|
198
|
+
og.ui.column("Flask", { cross: "center", gap: S.xxs }, () => {
|
|
199
|
+
if (og.ui.actionButton("Drink", say(world, "hud.drink"), { icon: "potion", size: 60 }).clicked) g.padDrink = true;
|
|
200
|
+
// A refused draught (the Hero system, after this one, refused it last tick) shakes the flask once, with the error sound (og-ui §6).
|
|
201
|
+
if (g.refusedTick === world.tick - 1) og.ui.shake({ sound: true });
|
|
202
|
+
og.ui.label("Count", `× ${g.potions}`, { font: "mono", nowrap: true });
|
|
203
|
+
});
|
|
204
|
+
if (touch && og.ui.actionButton("Wait", say(world, "hud.wait"), { icon: "clock", size: 52 }).clicked) g.padWait = true;
|
|
205
|
+
});
|
|
206
|
+
let dir = 0;
|
|
207
|
+
if (touch) {
|
|
208
|
+
og.ui.anchor("Move", { anchor: "bottomRight" }, () => {
|
|
209
|
+
const d = og.ui.dpad("Pad", { size: 150 });
|
|
210
|
+
dir = d.up ? 1 : d.right ? 2 : d.down ? 3 : d.left ? 4 : 0;
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
if (dir !== g.padDir) g.padDir = dir;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function settings(world: World, g: GameV, p: PrefsV): void {
|
|
217
|
+
let done = false;
|
|
218
|
+
const before = JSON.stringify(prefsValue(p));
|
|
219
|
+
const m = og.ui.modal("Settings", g.settingsOpen, { title: say(world, "settings.title"), width: px(Math.min(420, og.ui.frameViewport().width - 32)) }, () => {
|
|
220
|
+
const slider = (id: string, key: string, value: number): number => {
|
|
221
|
+
let out = value;
|
|
222
|
+
og.ui.row(id, { width: grow, gap: S.md, cross: "center" }, () => {
|
|
223
|
+
og.ui.label("Label", say(world, key), { width: px(110), nowrap: true });
|
|
224
|
+
out = og.ui.slider("Slider", value, { step: 0.05 }).value;
|
|
225
|
+
og.ui.label("Value", `${Math.round(out * 100)}`, { width: px(40), align: "end", font: "mono", nowrap: true });
|
|
226
|
+
});
|
|
227
|
+
return out;
|
|
228
|
+
};
|
|
229
|
+
p.master = slider("Master", "settings.master", p.master);
|
|
230
|
+
p.music = slider("Music", "settings.music", p.music);
|
|
231
|
+
p.effects = slider("Effects", "settings.effects", p.effects);
|
|
232
|
+
og.ui.label("LanguageLabel", say(world, "settings.language"), { color: { token: "fgMuted" } });
|
|
233
|
+
const r = og.ui.radio("Language", LANGUAGES.map((l) => say(world, l.key)), p.language, { horizontal: true });
|
|
234
|
+
if (r.selected !== p.language) setLanguage(world, p, r.selected);
|
|
235
|
+
p.reducedMotion = og.ui.toggle("Motion", p.reducedMotion, say(world, "settings.motion")).on;
|
|
236
|
+
og.ui.row("Footer", { width: grow, align: "end" }, () => {
|
|
237
|
+
if (og.ui.button("Done", say(world, "settings.done"), { variant: "primary" }).clicked) done = true;
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
if (JSON.stringify(prefsValue(p)) !== before) applyPrefs(world, p);
|
|
241
|
+
if (g.settingsOpen && (done || m.dismissed)) {
|
|
242
|
+
g.settingsOpen = false;
|
|
243
|
+
must(og.platform.saveSettings(world, prefsValue(p)));
|
|
244
|
+
p.saves += 1;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/** The run's summary: how it ended, how deep, how long, what fell, what was found. */
|
|
249
|
+
function summary(world: World, g: GameV): "again" | "menu" | null {
|
|
250
|
+
let chose: "again" | "menu" | null = null;
|
|
251
|
+
og.ui.modal("Summary", g.phase === Phase.Over, { title: g.won ? say(world, "over.won") : say(world, "over.lost", { n: g.floor }), locked: true, width: px(Math.min(400, og.ui.frameViewport().width - 32)) }, () => {
|
|
252
|
+
og.ui.row("Mark", { width: grow, align: "center" }, () => {
|
|
253
|
+
og.ui.transition("Icon", true, { kind: "pop" }, () => og.ui.icon("Glyph", g.won ? "crown" : "skull", { size: 48, tint: { token: g.won ? "accent" : "fgMuted" } }));
|
|
254
|
+
if (g.won && g.overTicks === OVER_DELAY + 20) og.ui.burst({ count: 12 });
|
|
255
|
+
});
|
|
256
|
+
og.ui.column("Stats", { width: grow, gap: 0 }, () => {
|
|
257
|
+
og.ui.keyValue("Floor", say(world, "over.floor"), `${g.deepest}/${FLOORS}`, true);
|
|
258
|
+
og.ui.keyValue("Turns", say(world, "over.turns"), `${g.turns}`, true);
|
|
259
|
+
og.ui.keyValue("Kills", say(world, "over.kills"), `${g.kills}`, true);
|
|
260
|
+
og.ui.keyValue("Gold", say(world, "over.gold"), `${g.gold}`, true);
|
|
261
|
+
og.ui.keyValue("Finds", say(world, "over.finds"), `${g.finds}`, true);
|
|
262
|
+
if (!g.won) og.ui.keyValue("By", say(world, "over.by"), say(world, g.killedBy >= 0 ? `foe.${FOES[g.killedBy]}` : "foe.none"), false);
|
|
263
|
+
});
|
|
264
|
+
og.ui.label("Record", say(world, "over.record", { dives: g.dives, relics: g.relics }), { color: { token: "fgMuted" }, align: "center", width: grow });
|
|
265
|
+
og.ui.row("Actions", { width: grow, gap: S.sm }, () => {
|
|
266
|
+
if (og.ui.button("Again", say(world, "over.again"), { variant: "primary", width: grow }).clicked) chose = "again";
|
|
267
|
+
if (og.ui.button("Menu", say(world, "over.menu"), { width: grow }).clicked) chose = "menu";
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
return chose;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** The screens, the dive's start and end, the camera, the buses, the platform's answers. */
|
|
274
|
+
export const Ui = defineSystem("Ui", { reads: [Tuning], writes: [Game, Prefs, og.Camera, og.Audio, og.Rng] }, (_q, time, world) => {
|
|
275
|
+
const game = world.resource(Game);
|
|
276
|
+
const prefs = world.resource(Prefs);
|
|
277
|
+
if (!game.ok || !prefs.ok) return;
|
|
278
|
+
const g = game.value;
|
|
279
|
+
const p = prefs.value;
|
|
280
|
+
platform(world, g, p);
|
|
281
|
+
if (time.tick === 0) applyPrefs(world, p);
|
|
282
|
+
// The camera: 13 cells tall on a wide screen, 10 cells across a portrait one.
|
|
283
|
+
const vp = og.ui.frameViewport();
|
|
284
|
+
if (vp.width > 0 && (vp.width !== g.viewW || vp.height !== g.viewH)) {
|
|
285
|
+
g.viewW = vp.width;
|
|
286
|
+
g.viewH = vp.height;
|
|
287
|
+
const cam = world.resource(og.Camera);
|
|
288
|
+
if (cam.ok) cam.value.height = vp.width < vp.height ? (10 * vp.height) / vp.width : 13;
|
|
289
|
+
}
|
|
290
|
+
const hold = g.phase === Phase.Play && (g.paused || g.settingsOpen);
|
|
291
|
+
if (hold !== g.held) {
|
|
292
|
+
must(og.time.setScale(world, hold ? 0 : 1));
|
|
293
|
+
g.held = hold;
|
|
294
|
+
}
|
|
295
|
+
// A beat after the lamp goes out or the relic is taken, the summary.
|
|
296
|
+
if (g.phase === Phase.Play && (g.hp <= 0 || g.won)) {
|
|
297
|
+
g.overTicks += 1;
|
|
298
|
+
if (g.overTicks === OVER_DELAY) {
|
|
299
|
+
g.phase = Phase.Over;
|
|
300
|
+
if (g.won) g.relics += 1;
|
|
301
|
+
saveRecord(world, g);
|
|
302
|
+
must(og.platform.telemetry(world, "dive.over", { won: g.won, floor: g.deepest, turns: g.turns, kills: g.kills, gold: g.gold }));
|
|
303
|
+
}
|
|
304
|
+
} else if (g.phase === Phase.Over) g.overTicks += 1;
|
|
305
|
+
|
|
306
|
+
const screen = g.phase === Phase.Title ? "title" : g.phase === Phase.Play ? "play" : "over";
|
|
307
|
+
const shown = og.ui.screenTransition("Screens", screen, { kind: p.reducedMotion ? "fade" : "dissolve", durationMs: 600 }).shown;
|
|
308
|
+
if (shown !== "title") g.leftTitle = true;
|
|
309
|
+
if (shown === "title") {
|
|
310
|
+
og.ui.setNavigation(true);
|
|
311
|
+
const r = og.ui.mainMenu("Title", {
|
|
312
|
+
title: say(world, "title.name"),
|
|
313
|
+
subtitle: say(world, "title.tagline"),
|
|
314
|
+
items: [
|
|
315
|
+
{ id: "play", label: say(world, "title.play"), primary: true },
|
|
316
|
+
{ id: "settings", label: say(world, "title.settings") },
|
|
317
|
+
],
|
|
318
|
+
footer: say(world, "title.footer"),
|
|
319
|
+
// The title the game opens on is built settled: the web draws it behind the play gate, where
|
|
320
|
+
// the skin's entrance would stand part-way until the tap (og-platform-sdk §3). Later titles enter.
|
|
321
|
+
instant: !g.leftTitle,
|
|
322
|
+
});
|
|
323
|
+
if (!g.settingsOpen && r.selected === "play") startDive(world, g);
|
|
324
|
+
if (r.selected === "settings") g.settingsOpen = true;
|
|
325
|
+
} else if (shown === "play") {
|
|
326
|
+
hud(world, g);
|
|
327
|
+
const m = og.ui.pauseMenu("Pause", {
|
|
328
|
+
open: g.paused && !g.settingsOpen,
|
|
329
|
+
title: say(world, "pause.title"),
|
|
330
|
+
items: [
|
|
331
|
+
{ id: "resume", label: say(world, "pause.resume"), primary: true },
|
|
332
|
+
{ id: "settings", label: say(world, "pause.settings") },
|
|
333
|
+
{ id: "quit", label: say(world, "pause.quit") },
|
|
334
|
+
],
|
|
335
|
+
});
|
|
336
|
+
if (m.selected === "resume") g.paused = false;
|
|
337
|
+
if (m.selected === "settings") g.settingsOpen = true;
|
|
338
|
+
if (m.selected === "quit") {
|
|
339
|
+
g.paused = false;
|
|
340
|
+
g.phase = Phase.Title;
|
|
341
|
+
}
|
|
342
|
+
} else {
|
|
343
|
+
og.ui.setNavigation(true);
|
|
344
|
+
const c = summary(world, g);
|
|
345
|
+
if (c === "again") startDive(world, g);
|
|
346
|
+
if (c === "menu") g.phase = Phase.Title;
|
|
347
|
+
}
|
|
348
|
+
settings(world, g, p);
|
|
349
|
+
if (g.language !== p.language) g.language = p.language;
|
|
350
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// The core loop through real input: Dive on the title starts a dive on a
|
|
2
|
+
// fresh seed; then seed 7's first floor (the same start as Dive, with a
|
|
3
|
+
// known seed) is walked with the arrows: up the corridor (each step a
|
|
4
|
+
// turn, the lamp lighting what it reaches), a bump into the stone (no
|
|
5
|
+
// turn), then on up into the rats coming to meet the lamp (walking into a
|
|
6
|
+
// foe strikes it), and Q drinks the flask.
|
|
7
|
+
import { playtest } from "@origingame/engine/playtest";
|
|
8
|
+
import { component, game, PLAY, press, presses, tap, TITLE } from "./lib.ts";
|
|
9
|
+
|
|
10
|
+
export default playtest({
|
|
11
|
+
name: "a dive from the title: steps, a bump, the lamp's light, strikes and a draught",
|
|
12
|
+
commands: [
|
|
13
|
+
"0.3:get:Game:title.json",
|
|
14
|
+
"0.9:screenshot:title.png",
|
|
15
|
+
tap("play", 1.0),
|
|
16
|
+
"1.4:get:Game:started.json",
|
|
17
|
+
"1.45:dive:7",
|
|
18
|
+
"1.5:get:Game:start7.json",
|
|
19
|
+
presses(["ArrowUp", "ArrowUp", "ArrowUp", "ArrowUp"], 1.6),
|
|
20
|
+
press("ArrowLeft", 2.7),
|
|
21
|
+
"3.0:get:Game:walked.json",
|
|
22
|
+
presses(Array(12).fill("ArrowUp"), 3.1),
|
|
23
|
+
"6.2:get:Game:fought.json",
|
|
24
|
+
"6.25:screenshot:fought.png",
|
|
25
|
+
press("KeyQ", 6.3),
|
|
26
|
+
"6.7:get:Game:drank.json",
|
|
27
|
+
"6.7:dump_entity:hero:hero.json",
|
|
28
|
+
"6.8:quit",
|
|
29
|
+
].join(";"),
|
|
30
|
+
check(run, t) {
|
|
31
|
+
t.equal(run.warnings.join("; "), "", "the script ran without warnings");
|
|
32
|
+
t.ok(run.quit, "the script reached quit");
|
|
33
|
+
t.equal(game(run, "title.json").phase, TITLE, "the game opens on the title");
|
|
34
|
+
const started = game(run, "started.json");
|
|
35
|
+
t.equal(started.phase, PLAY, "Dive started a dive");
|
|
36
|
+
t.ok(started.seed !== 0 && started.seed !== 1, `on a fresh seed (${started.seed})`);
|
|
37
|
+
t.ok(started.floor === 1 && started.hp === 20 && started.potions === 1 && started.dives === 1, "on floor 1 with full health and one draught");
|
|
38
|
+
t.ok(started.lit > 0, `the lamp lights the first room (${started.lit} cells)`);
|
|
39
|
+
const s7 = game(run, "start7.json");
|
|
40
|
+
t.equal(`${s7.heroX},${s7.heroY}`, "4,15", "seed 7 starts the lamp-bearer in its first room");
|
|
41
|
+
const walked = game(run, "walked.json");
|
|
42
|
+
t.equal(`${walked.heroX},${walked.heroY}`, "4,11", "four presses walked four cells up the corridor");
|
|
43
|
+
t.equal(walked.turns, 4, "four steps, four turns; the bump into the stone took none");
|
|
44
|
+
t.ok(walked.seen > s7.seen, `the lamp lit new cells on the way (${s7.seen} → ${walked.seen})`);
|
|
45
|
+
t.equal(component<{ bumps: number }>(run, "hero.json", "Hero").bumps >= 1, true, "the stone refused the step to the left");
|
|
46
|
+
const fought = game(run, "fought.json");
|
|
47
|
+
t.ok(fought.hits >= 2 && fought.kills >= 1, `walking into the rats struck them (${fought.hits} strikes, ${fought.kills} felled)`);
|
|
48
|
+
t.ok(fought.hurts >= 1 && fought.hp < 20, `the rats struck back (${fought.hurts} times, health ${fought.hp})`);
|
|
49
|
+
t.ok(fought.heroY < 11, "and the lamp-bearer pressed on up");
|
|
50
|
+
const drank = game(run, "drank.json");
|
|
51
|
+
t.equal(drank.potions, fought.potions - 1, "Q drank the draught");
|
|
52
|
+
t.ok(drank.hp > fought.hp, `and it healed (${fought.hp} → ${drank.hp})`);
|
|
53
|
+
},
|
|
54
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// The foes' minds (assets/ai/foe.ogt on og.ai): a rat that sees the lamp
|
|
2
|
+
// hunts it along og.nav's path, a cell a turn, and strikes once beside it;
|
|
3
|
+
// the lamp-bearer's strikes land on a rat (a hit stop, the number) and the
|
|
4
|
+
// second fells it. Seed 7's first floor has a rat at (6, 7).
|
|
5
|
+
import { playtest } from "@origingame/engine/playtest";
|
|
6
|
+
import { foe, game, press, presses } from "./lib.ts";
|
|
7
|
+
|
|
8
|
+
export default playtest({
|
|
9
|
+
name: "a rat hunts and strikes; two strikes fell it",
|
|
10
|
+
commands: [
|
|
11
|
+
"0.3:dive:7",
|
|
12
|
+
"0.5:warp:3:7",
|
|
13
|
+
"0.6:get:Foes:before.json",
|
|
14
|
+
presses(["Space", "Space"], 0.7),
|
|
15
|
+
"1.3:get:Foes:closer.json",
|
|
16
|
+
presses(["Space", "Space"], 1.4),
|
|
17
|
+
"2.0:get:Game:struck.json",
|
|
18
|
+
"2.2:dive:7",
|
|
19
|
+
"2.4:warp:5:7",
|
|
20
|
+
press("ArrowRight", 2.6),
|
|
21
|
+
"2.75:get:Game:hit.json",
|
|
22
|
+
"2.75:dump_entity:foe-0:hit-foe.json",
|
|
23
|
+
presses(["ArrowRight", "ArrowRight"], 2.9),
|
|
24
|
+
"3.6:get:Game:felled.json",
|
|
25
|
+
"3.6:get:Foes:felled-foes.json",
|
|
26
|
+
"3.7:quit",
|
|
27
|
+
].join(";"),
|
|
28
|
+
check(run, t) {
|
|
29
|
+
t.equal(run.warnings.join("; "), "", "the script ran without warnings");
|
|
30
|
+
const [x0, y0] = foe(run, "before.json", 0);
|
|
31
|
+
t.equal(`${x0},${y0}`, "6,7", "the rat stands at (6, 7)");
|
|
32
|
+
const [x1] = foe(run, "closer.json", 0);
|
|
33
|
+
t.ok(x1 < x0, `two turns waited, it came along the row toward the lamp (x ${x0} → ${x1})`);
|
|
34
|
+
const struck = game(run, "struck.json");
|
|
35
|
+
t.ok(struck.hurts >= 1 && struck.hp < struck.hpMax, `beside the lamp-bearer it struck (${struck.hurts} strikes, health ${struck.hp})`);
|
|
36
|
+
const hit = game(run, "hit.json");
|
|
37
|
+
t.equal(hit.hits, 1, "walking into it struck it");
|
|
38
|
+
const rat = run.json<{ components: { Foe: { hp: number; hpMax: number; active: boolean } } }>("hit-foe.json").components.Foe;
|
|
39
|
+
t.ok(rat.active && rat.hp < rat.hpMax, `the strike took its health (${rat.hp}/${rat.hpMax})`);
|
|
40
|
+
const felled = game(run, "felled.json");
|
|
41
|
+
t.equal(felled.kills, 1, "the second strike felled it");
|
|
42
|
+
t.equal(foe(run, "felled-foes.json", 0).join(","), "-1,-1", "and it left the board");
|
|
43
|
+
t.equal(`${felled.heroX},${felled.heroY}`, "6,7", "the third press stepped where it stood");
|
|
44
|
+
},
|
|
45
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Three frames at 1280×720 compared with references/<tier>/: the title over
|
|
2
|
+
// the lit first room, seed 7's corridor after a strike (the lamp's light,
|
|
3
|
+
// the fog remembered behind, a rat), and the summary when the lamp went
|
|
4
|
+
// out. `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
|
+
import { press, presses } from "./lib.ts";
|
|
8
|
+
|
|
9
|
+
const FILES = ["title.png", "dive.png", "over.png"];
|
|
10
|
+
|
|
11
|
+
export default playtest({
|
|
12
|
+
name: "the title, the lamp in the tomb and the summary match their reference frames",
|
|
13
|
+
size: "1280x720",
|
|
14
|
+
commands: [
|
|
15
|
+
"0.9:screenshot:title.png",
|
|
16
|
+
"0.95:dive:7",
|
|
17
|
+
presses(Array(7).fill("ArrowUp"), 1.15),
|
|
18
|
+
"3.65:screenshot:dive.png",
|
|
19
|
+
"3.75:hp:1",
|
|
20
|
+
"3.75:warp:6:7",
|
|
21
|
+
press("Space", 3.85),
|
|
22
|
+
"6.0:screenshot:over.png",
|
|
23
|
+
"6.1:quit",
|
|
24
|
+
].join(";"),
|
|
25
|
+
check(run, t) {
|
|
26
|
+
t.equal(run.warnings.join("; "), "", "the script ran without warnings");
|
|
27
|
+
t.frame(FILES, () => {
|
|
28
|
+
for (const f of FILES) t.equal(run.png(f).width, 1280, `${f} is 1280 wide`);
|
|
29
|
+
});
|
|
30
|
+
checkFrames(run, t, FILES, "");
|
|
31
|
+
},
|
|
32
|
+
});
|
|
@@ -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
|
+
}
|