@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,658 @@
|
|
|
1
|
+
// Path Guard's systems, in tick order: Control (the cursor, the tray keys,
|
|
2
|
+
// a tap or a key setting a plant), Plants (reloads, sight, the shooting
|
|
3
|
+
// clip), Visitors (the waves, the walk, hits landing, pops and leaks) and
|
|
4
|
+
// Voices (each requested sound once). The UI is src/ui.ts; `fire`, the
|
|
5
|
+
// plants' behaviour command, is here.
|
|
6
|
+
//
|
|
7
|
+
// A plant's mind is data: assets/ai/plant.ogt, run by og.ai before these
|
|
8
|
+
// systems, checks that the plant is set and reloaded and sees a visitor
|
|
9
|
+
// (og.Perception picks the nearest within range), then raises the `fire`
|
|
10
|
+
// command, which sends a shot along a tween. The tween's tag names the
|
|
11
|
+
// visitor's pool slot and the plant's kind, so Visitors applies the hit on
|
|
12
|
+
// the tick it lands. The visitors walk og.nav's flow field to the doorstep;
|
|
13
|
+
// every plant set re-costs the field's grid, and a plant that would close
|
|
14
|
+
// the path (for the gate or any visitor on the field) is refused.
|
|
15
|
+
|
|
16
|
+
import { og, defineSystem, NAV_ARRIVED } from "@origingame/engine";
|
|
17
|
+
import type { Entity, Value, View, World } from "@origingame/engine";
|
|
18
|
+
import { Bed, Cursor, Game, Phase, Plant, PLANTS, Prefs, Refusal, Sfx, Shot, Sound, Tuning, Visitor } from "./components.ts";
|
|
19
|
+
import { clipOf } from "./art.ts";
|
|
20
|
+
import { say } from "./ui.ts";
|
|
21
|
+
|
|
22
|
+
/** The field: 9 × 13 cells of one world unit; the map's top-left corner is at (0, 13). */
|
|
23
|
+
export const COLS = 9;
|
|
24
|
+
export const ROWS = 13;
|
|
25
|
+
/** The gate's cell (the visitors' spawn) and the doorstep's (their goal), map columns and rows. */
|
|
26
|
+
export const GATE = { x: 4, y: 0 } as const;
|
|
27
|
+
export const DOOR = { x: 4, y: 12 } as const;
|
|
28
|
+
/** Pool sizes. */
|
|
29
|
+
export const VISITORS = 24;
|
|
30
|
+
export const SHOTS = 24;
|
|
31
|
+
/** A visitor's pop lasts this long before its row is parked. */
|
|
32
|
+
const POP_TICKS = 36;
|
|
33
|
+
/** Where parked rows wait, far outside every plant's sight. */
|
|
34
|
+
const PARK = { x: -40, y: -40, z: 0 } as const;
|
|
35
|
+
|
|
36
|
+
/** A visitor's base numbers by Kind.*: health, speed (m/s), bounty (coins), light it takes. */
|
|
37
|
+
export const KINDS = [
|
|
38
|
+
{ name: "beetle", hp: 34, speed: 1.3, bounty: 6, harm: 1 },
|
|
39
|
+
{ name: "moth", hp: 22, speed: 2.1, bounty: 5, harm: 1 },
|
|
40
|
+
{ name: "snail", hp: 140, speed: 0.75, bounty: 20, harm: 3 },
|
|
41
|
+
] as const;
|
|
42
|
+
|
|
43
|
+
/** The waves, one letter per visitor in the order they come: b beetle, m moth, s snail. */
|
|
44
|
+
export const WAVES = ["bbbbbb", "bbmbbmbbmb", "mmbmmbmmbmmb", "bbsbbmbbmbbsbb", "sbbmmbbsmmbbmmbbsm"] as const;
|
|
45
|
+
|
|
46
|
+
const WHITE = { r: 1, g: 1, b: 1 };
|
|
47
|
+
const GOLD = { r: 1, g: 0.78, b: 0.25 };
|
|
48
|
+
const RED = { r: 1, g: 0.32, b: 0.3 };
|
|
49
|
+
const MINT = { r: 0.6, g: 1, b: 0.75 };
|
|
50
|
+
const FROSTED = { r: 0.55, g: 0.8, b: 1 };
|
|
51
|
+
|
|
52
|
+
type GameV = Value<typeof Game>;
|
|
53
|
+
type TuneV = Value<typeof Tuning>;
|
|
54
|
+
|
|
55
|
+
/** The camera feel's scale: 0.3 under reduced motion (og-feel), 1 otherwise. */
|
|
56
|
+
export function feel(world: World): number {
|
|
57
|
+
const p = world.resource(Prefs);
|
|
58
|
+
return p.ok && p.value.reducedMotion ? 0.3 : 1;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function must(r: { ok: true } | { ok: false; reason: string }): void {
|
|
62
|
+
if (!r.ok) throw new Error(r.reason);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Tuning, read on its first use in this call: a resource read is a call into
|
|
67
|
+
* the engine that encodes every field, so a system that needs the knobs only
|
|
68
|
+
* on an event does not pay for them every tick.
|
|
69
|
+
*/
|
|
70
|
+
export function lazyTuning(world: World): TuneV {
|
|
71
|
+
let v: TuneV | null = null;
|
|
72
|
+
return new Proxy({} as TuneV, { get: (_, k) => ((v ??= must2(world.resource(Tuning))) as unknown as Record<string | symbol, unknown>)[k] });
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function must2<T>(r: { ok: true; value: T } | { ok: false; reason: string }): T {
|
|
76
|
+
if (!r.ok) throw new Error(r.reason);
|
|
77
|
+
return r.value;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** A cell's centre in world units (map rows count down from the top). */
|
|
81
|
+
export function cellCenter(x: number, y: number): { x: number; y: number } {
|
|
82
|
+
return { x: x + 0.5, y: ROWS - y - 0.5 };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** The map cell under a world point. */
|
|
86
|
+
export function cellOf(px: number, py: number): { x: number; y: number } {
|
|
87
|
+
return { x: Math.floor(px), y: ROWS - 1 - Math.floor(py) };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Whether a map cell can take a plant: the lawn inside the hedge, not a stone. */
|
|
91
|
+
export function buildable(world: World, g: GameV, x: number, y: number): boolean {
|
|
92
|
+
if (x < 1 || x > COLS - 2 || y < 1 || y > ROWS - 2) return false;
|
|
93
|
+
return og.tilemap.getTile(world, g.map as unknown as Entity, "walls", x, y) < 0;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** The pads tile of each plant (tiles/garden.ogt): the map remembers what grows where. */
|
|
97
|
+
export const PAD = [6, 8, 9] as const;
|
|
98
|
+
|
|
99
|
+
/** The plant on a cell by its pads tile (Plant.*), or -1. */
|
|
100
|
+
export function padOf(world: World, g: GameV, x: number, y: number): number {
|
|
101
|
+
return (PAD as readonly number[]).indexOf(og.tilemap.getTile(world, g.map as unknown as Entity, "pads", x, y));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function cost(t: TuneV, kind: number): number {
|
|
105
|
+
return kind === Plant.Thorn ? t.thornCost : kind === Plant.Frost ? t.frostCost : t.hedgeCost;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function range(t: TuneV, kind: number): number {
|
|
109
|
+
return kind === Plant.Thorn ? t.thornRange : kind === Plant.Frost ? t.frostRange : 0;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function occupied(g: GameV, x: number, y: number): boolean {
|
|
113
|
+
const i = y * COLS + x;
|
|
114
|
+
const word = [g.occ0, g.occ1, g.occ2, g.occ3][i >> 5]!;
|
|
115
|
+
return (word & (1 << (i & 31))) !== 0;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function float(world: World, text: string, x: number, y: number, color: { r: number; g: number; b: number }, crit = false, size = 0.42): void {
|
|
119
|
+
must(og.render.floatingText(world, { text, position: { x, y, z: 0 }, size, color, crit, rise: 1, lifetime: 0.8 }));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Sets the selected plant on a cell, or refuses with the reason: too few
|
|
124
|
+
* coins, the cell taken, a visitor standing there, or a path closed (the
|
|
125
|
+
* gate's to the doorstep or any visitor's). The grid's cost is set first and
|
|
126
|
+
* put back when the path check fails.
|
|
127
|
+
*/
|
|
128
|
+
export function place(world: World, g: GameV, t: TuneV, x: number, y: number): boolean {
|
|
129
|
+
const refuse = (why: number, text: string) => {
|
|
130
|
+
g.refused += 1;
|
|
131
|
+
g.refusal = why;
|
|
132
|
+
g.refusedTick = world.tick;
|
|
133
|
+
const c = cellCenter(x, y);
|
|
134
|
+
float(world, text, c.x, c.y + 0.6, RED, false, 0.36);
|
|
135
|
+
return false;
|
|
136
|
+
};
|
|
137
|
+
if (!buildable(world, g, x, y) || padOf(world, g, x, y) >= 0 || occupied(g, x, y)) return refuse(Refusal.Taken, say(world, "float.taken"));
|
|
138
|
+
const price = cost(t, g.selected);
|
|
139
|
+
if (g.gold < price) return refuse(Refusal.Poor, say(world, "float.poor", { n: price - g.gold }));
|
|
140
|
+
const grid = g.grid as unknown as never;
|
|
141
|
+
const navY = ROWS - 1 - y;
|
|
142
|
+
must(og.nav.setCost(world, grid, x, navY, 0));
|
|
143
|
+
if (!pathsOpen(world, g)) {
|
|
144
|
+
must(og.nav.setCost(world, grid, x, navY, 1));
|
|
145
|
+
return refuse(Refusal.Blocked, say(world, "float.blocked"));
|
|
146
|
+
}
|
|
147
|
+
g.gold -= price;
|
|
148
|
+
g.placed += 1;
|
|
149
|
+
// The pads layer holds which plant stands on each cell; the Plants system switches the cell's row on.
|
|
150
|
+
must(og.tilemap.setTile(world, { entity: g.map as unknown as Entity, layer: "pads", x, y, tile: PAD[g.selected]! }));
|
|
151
|
+
g.pendingPlants += 1;
|
|
152
|
+
g.sfx |= Sound.Plant;
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Whether the gate and every cell a visitor stands on still reach the doorstep. */
|
|
157
|
+
function pathsOpen(world: World, g: GameV): boolean {
|
|
158
|
+
const grid = g.grid as unknown as never;
|
|
159
|
+
const goal = cellCenter(DOOR.x, DOOR.y);
|
|
160
|
+
const to = { x: goal.x, y: goal.y, z: 0 };
|
|
161
|
+
const reaches = (cx: number, cy: number) => {
|
|
162
|
+
const from = cellCenter(cx, cy);
|
|
163
|
+
const p = og.nav.findPath(world, { nav: grid, from: { x: from.x, y: from.y, z: 0 }, to, smooth: false });
|
|
164
|
+
return p.ok && p.value.complete;
|
|
165
|
+
};
|
|
166
|
+
if (!reaches(GATE.x, GATE.y)) return false;
|
|
167
|
+
for (let i = 0; i < COLS * ROWS; i++) if (occupied(g, i % COLS, Math.floor(i / COLS)) && !reaches(i % COLS, Math.floor(i / COLS))) return false;
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** The world point under a CSS pixel of the play surface, through the camera Frame wrote. */
|
|
172
|
+
export function screenToWorld(world: World, px: number, py: number): { x: number; y: number } | null {
|
|
173
|
+
const cam = world.resource(og.Camera);
|
|
174
|
+
const vp = og.ui.viewport(world);
|
|
175
|
+
if (!cam.ok || vp.height <= 0) return null;
|
|
176
|
+
const scale = vp.height / cam.value.height;
|
|
177
|
+
return { x: cam.value.position.x + (px - vp.width / 2) / scale, y: cam.value.position.y - (py - vp.height / 2) / scale };
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* The player's hands: the cursor (arrows, WASD, the pad's d-pad), the tray
|
|
182
|
+
* (1, 2, 3, the pad's X), setting a plant (Space, Enter, the pad's A, or a
|
|
183
|
+
* tap on the lawn, which also moves the cursor), the next wave (N, the
|
|
184
|
+
* pad's Y) and pause (Escape, P, the pad's Start). Every input is answered
|
|
185
|
+
* on its tick: the cursor moves with a tick of sound, a plant pops up, a
|
|
186
|
+
* refusal says why.
|
|
187
|
+
*/
|
|
188
|
+
export const Control = defineSystem(
|
|
189
|
+
"Control",
|
|
190
|
+
{ reads: [og.Input, og.Gamepad, og.Camera, Tuning], writes: [Game, Cursor, og.Transform] },
|
|
191
|
+
(q, time, world) => {
|
|
192
|
+
const game = world.resource(Game);
|
|
193
|
+
const input = world.resource(og.Input);
|
|
194
|
+
const pad = world.resource(og.Gamepad);
|
|
195
|
+
if (!game.ok || !input.ok || !pad.ok) return;
|
|
196
|
+
const g = game.value;
|
|
197
|
+
const t = lazyTuning(world);
|
|
198
|
+
const inp = input.value;
|
|
199
|
+
const gp = pad.value;
|
|
200
|
+
const playing = g.phase === Phase.Play && !g.paused && !g.settingsOpen;
|
|
201
|
+
for (const a of q.archetypes()) {
|
|
202
|
+
const cur = a.column(Cursor);
|
|
203
|
+
const p = a.column(og.Transform).position;
|
|
204
|
+
for (let i = 0; i < a.count; i++) {
|
|
205
|
+
if (!playing) {
|
|
206
|
+
p[i * 3] = PARK.x;
|
|
207
|
+
p[i * 3 + 1] = PARK.y;
|
|
208
|
+
// Focus moving over a menu ticks (og-ui plays nothing when keyboard or pad focus moves).
|
|
209
|
+
const nav = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Tab"].some((k) => inp.pressed(k)) || (["up", "down", "left", "right"] as const).some((b) => gp.pressed(b));
|
|
210
|
+
if (nav) g.sfx |= Sound.Move;
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
let dx = 0;
|
|
214
|
+
let dy = 0;
|
|
215
|
+
if (inp.pressed("ArrowLeft") || inp.pressed("KeyA") || gp.pressed("left")) dx -= 1;
|
|
216
|
+
if (inp.pressed("ArrowRight") || inp.pressed("KeyD") || gp.pressed("right")) dx += 1;
|
|
217
|
+
if (inp.pressed("ArrowUp") || inp.pressed("KeyW") || gp.pressed("up")) dy -= 1;
|
|
218
|
+
if (inp.pressed("ArrowDown") || inp.pressed("KeyS") || gp.pressed("down")) dy += 1;
|
|
219
|
+
if (dx !== 0 || dy !== 0) {
|
|
220
|
+
g.cursorX = Math.max(1, Math.min(COLS - 2, g.cursorX + dx));
|
|
221
|
+
g.cursorY = Math.max(1, Math.min(ROWS - 2, g.cursorY + dy));
|
|
222
|
+
cur.moves[i] = cur.moves[i]! + 1;
|
|
223
|
+
g.sfx |= Sound.Move;
|
|
224
|
+
}
|
|
225
|
+
if (inp.pressed("Digit1")) select(g, Plant.Thorn);
|
|
226
|
+
if (inp.pressed("Digit2")) select(g, Plant.Frost);
|
|
227
|
+
if (inp.pressed("Digit3")) select(g, Plant.Hedge);
|
|
228
|
+
if (gp.pressed("x")) select(g, (g.selected + 1) % PLANTS.length);
|
|
229
|
+
if (inp.pressed("KeyN") || gp.pressed("y")) g.callNext = true;
|
|
230
|
+
if (inp.pressed("Escape") || inp.pressed("KeyP") || gp.pressed("start")) g.paused = true;
|
|
231
|
+
if (inp.pressed("Space") || inp.pressed("Enter") || gp.pressed("a")) place(world, g, t, g.cursorX, g.cursorY);
|
|
232
|
+
// A tap on the lawn moves the cursor there and plants.
|
|
233
|
+
if (inp.buttonPressed("left")) {
|
|
234
|
+
const at = screenToWorld(world, inp.pointer.x, inp.pointer.y);
|
|
235
|
+
if (at !== null && at.x >= 0 && at.x < COLS && at.y >= 0 && at.y < ROWS) {
|
|
236
|
+
const c = cellOf(at.x, at.y);
|
|
237
|
+
g.cursorX = c.x;
|
|
238
|
+
g.cursorY = c.y;
|
|
239
|
+
place(world, g, t, c.x, c.y);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
const c = cellCenter(g.cursorX, g.cursorY);
|
|
243
|
+
p[i * 3] = c.x;
|
|
244
|
+
p[i * 3 + 1] = c.y;
|
|
245
|
+
// The cursor and, for a shooting plant, its range: drawn this tick.
|
|
246
|
+
const ok = buildable(world, g, g.cursorX, g.cursorY) && g.gold >= cost(t, g.selected);
|
|
247
|
+
const frame = ok ? 18 : 19;
|
|
248
|
+
const sheet = g.sheet as unknown as never;
|
|
249
|
+
must(og.render.sprite(world, { texture: sheet, position: { x: c.x, y: c.y, z: 0 }, width: 1, height: 1, uv: [(frame % 8) / 8, Math.floor(frame / 8) / 3, (frame % 8 + 1) / 8, (Math.floor(frame / 8) + 1) / 3], layer: 8 }));
|
|
250
|
+
const r = range(t, g.selected);
|
|
251
|
+
if (ok && r > 0) must(og.render.sprite(world, { texture: g.ring as unknown as never, position: { x: c.x, y: c.y, z: 0 }, width: r * 2, height: r * 2, layer: 7, opacity: 0.85 }));
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
void time;
|
|
255
|
+
},
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
function select(g: GameV, kind: number): void {
|
|
259
|
+
if (g.selected !== kind) g.sfx |= Sound.Move;
|
|
260
|
+
g.selected = kind;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/** Plants: reload, sight from the tunables, the shooting clip back to the sway. Held by a hit stop. */
|
|
264
|
+
export const Plants = defineSystem(
|
|
265
|
+
"Plants",
|
|
266
|
+
{ reads: [Tuning], writes: [Game, Bed, og.Perception, og.Flipbook, og.Sprite, og.AiAgent], after: ["Control"] },
|
|
267
|
+
(q, time, world) => {
|
|
268
|
+
const game = world.resource(Game);
|
|
269
|
+
if (!game.ok) return;
|
|
270
|
+
const t = lazyTuning(world);
|
|
271
|
+
// Sight follows the tunables twice a second (Tune writes them live).
|
|
272
|
+
const refresh = world.tick % 30 === 0;
|
|
273
|
+
const g = game.value;
|
|
274
|
+
const held = time.hitStop > 0 || g.paused || g.phase !== Phase.Play;
|
|
275
|
+
const reset = g.reset;
|
|
276
|
+
const pending = g.pendingPlants > 0;
|
|
277
|
+
if (pending) g.pendingPlants = 0;
|
|
278
|
+
for (const a of q.archetypes()) {
|
|
279
|
+
const b = a.column(Bed);
|
|
280
|
+
const per = a.column(og.Perception);
|
|
281
|
+
const fb = a.column(og.Flipbook);
|
|
282
|
+
const sprite = a.column(og.Sprite);
|
|
283
|
+
const ai = a.column(og.AiAgent);
|
|
284
|
+
for (let i = 0; i < a.count; i++) {
|
|
285
|
+
if (reset) {
|
|
286
|
+
b.planted[i] = 0;
|
|
287
|
+
b.cool[i] = 0;
|
|
288
|
+
b.anim[i] = 0;
|
|
289
|
+
b.shots[i] = 0;
|
|
290
|
+
sprite.visible[i] = 0;
|
|
291
|
+
ai.active[i] = 0;
|
|
292
|
+
per.sight[i] = 0;
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
if (pending && !b.planted[i]) {
|
|
296
|
+
// A plant set this tick: its cell's pads tile names it.
|
|
297
|
+
const kind = padOf(world, g, b.cellX[i]!, b.cellY[i]!);
|
|
298
|
+
if (kind >= 0) {
|
|
299
|
+
b.planted[i] = 1;
|
|
300
|
+
b.kind[i] = kind;
|
|
301
|
+
b.cool[i] = 20;
|
|
302
|
+
b.anim[i] = 0;
|
|
303
|
+
sprite.visible[i] = 1;
|
|
304
|
+
fb.clip[i] = clipOf(PLANTS[kind]!);
|
|
305
|
+
ai.active[i] = kind === Plant.Hedge ? 0 : 1;
|
|
306
|
+
per.sight[i] = range(t, kind);
|
|
307
|
+
must(og.tween.squash(world, { entity: a.entity(i), impact: { x: 0.6, y: 1.5 }, duration: 0.25 }));
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
if (!b.planted[i]) continue;
|
|
311
|
+
if (refresh) per.sight[i] = range(t, b.kind[i]!);
|
|
312
|
+
if (held) continue;
|
|
313
|
+
if (b.cool[i]! > 0) b.cool[i] = b.cool[i]! - 1;
|
|
314
|
+
if (b.anim[i]! > 0) {
|
|
315
|
+
b.anim[i] = b.anim[i]! - 1;
|
|
316
|
+
if (b.anim[i] === 0) fb.clip[i] = clipOf(PLANTS[b.kind[i]!]!);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
);
|
|
322
|
+
|
|
323
|
+
/** Tween tags of shots: (kind + 1) × 1000 + the visitor's slot. */
|
|
324
|
+
const TAG = 1000;
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* `fire:<plant>`: the behaviour's shot (og.ai queues it with the plant's
|
|
328
|
+
* handle). It sends a free shot from the plant to where its target will be
|
|
329
|
+
* when the shot lands, on a tween whose tag names the target and the kind.
|
|
330
|
+
*/
|
|
331
|
+
export function fire(world: World, args: readonly string[]): void {
|
|
332
|
+
const me = Number(args[0]) as Entity;
|
|
333
|
+
const game = world.resource(Game);
|
|
334
|
+
const tune = world.resource(Tuning);
|
|
335
|
+
const bed = world.get(me, Bed);
|
|
336
|
+
const eyes = world.get(me, og.Perception);
|
|
337
|
+
const at = world.get(me, og.Transform);
|
|
338
|
+
if (!game.ok || !tune.ok || !bed.ok || !eyes.ok || !at.ok) throw new Error(`fire: ${args[0]} is not a plant`);
|
|
339
|
+
const g = game.value;
|
|
340
|
+
const t = tune.value;
|
|
341
|
+
const b = bed.value;
|
|
342
|
+
if (!b.planted || b.cool > 0 || !eyes.value.sees || g.phase !== Phase.Play || g.paused) return;
|
|
343
|
+
const target = eyes.value.target as Entity;
|
|
344
|
+
const v = world.get(target, Visitor);
|
|
345
|
+
const tp = world.get(target, og.Transform);
|
|
346
|
+
const nav = world.get(target, og.NavAgent);
|
|
347
|
+
if (!v.ok || !tp.ok || !nav.ok || !v.value.active || v.value.dying > 0) return;
|
|
348
|
+
let shot: Entity | null = null;
|
|
349
|
+
for (let k = 0; k < SHOTS && shot === null; k++) {
|
|
350
|
+
const e = world.find(`shot-${(g.shots + k) % SHOTS}`);
|
|
351
|
+
if (e !== null) {
|
|
352
|
+
const s = world.get(e, Shot);
|
|
353
|
+
if (s.ok && (s.value.tween === 0 || !og.tween.active(world, s.value.tween as unknown as never))) shot = e;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
if (shot === null) return;
|
|
357
|
+
const from = { x: at.value.position.x, y: at.value.position.y + 0.2 };
|
|
358
|
+
let to = { x: tp.value.position.x, y: tp.value.position.y };
|
|
359
|
+
const flight = Math.min(0.5, Math.hypot(to.x - from.x, to.y - from.y) / t.shotSpeed);
|
|
360
|
+
// Lead the target by where it walks during the flight.
|
|
361
|
+
to = { x: to.x + nav.value.velocity.x * flight, y: to.y + nav.value.velocity.y * flight };
|
|
362
|
+
const kind = b.kind;
|
|
363
|
+
must(world.set(shot, og.Transform, { position: { x: from.x, y: from.y, z: 0 } }));
|
|
364
|
+
must(world.set(shot, og.Sprite, { opacity: 1, visible: true }));
|
|
365
|
+
must(world.set(shot, og.Flipbook, { clip: clipOf(kind === Plant.Frost ? "flake" : "seed") }));
|
|
366
|
+
const flightTween = must2(
|
|
367
|
+
og.tween.sequence(
|
|
368
|
+
world,
|
|
369
|
+
[
|
|
370
|
+
{ entity: shot, field: "position", from: [from.x, from.y, 0], to: [to.x, to.y, 0], duration: flight, ease: "linear" },
|
|
371
|
+
{ entity: shot, component: og.Sprite, field: "opacity", to: [0], duration: 0.05, ease: "linear" },
|
|
372
|
+
],
|
|
373
|
+
{ tag: (kind + 1) * TAG + v.value.slot },
|
|
374
|
+
),
|
|
375
|
+
);
|
|
376
|
+
must(world.set(shot, Shot, { tween: flightTween as unknown as number }));
|
|
377
|
+
must(world.set(me, Bed, { cool: kind === Plant.Frost ? t.frostReload : t.thornReload, anim: 12, shots: b.shots + 1 }));
|
|
378
|
+
must(world.set(me, og.Flipbook, { clip: clipOf(`${PLANTS[kind]}_shoot`) }));
|
|
379
|
+
must(og.tween.squash(world, { entity: me, impact: { x: 1.15, y: 0.85 }, duration: 0.15 }));
|
|
380
|
+
g.shots += 1;
|
|
381
|
+
g.sfx |= kind === Plant.Frost ? Sound.Frost : Sound.Thorn;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* The visitors and the waves: a wave starts after the break (or at once,
|
|
386
|
+
* on the player's call, which pays a bonus for the seconds saved), its
|
|
387
|
+
* visitors come through the gate one gap apart and walk the flow field;
|
|
388
|
+
* shots land by their tween's tag; a visitor at 0 health pops (a coin
|
|
389
|
+
* count, a burst of petals, a light hit stop at most every 10 ticks); one
|
|
390
|
+
* that reaches the doorstep takes its light (shake, hit stop, a red
|
|
391
|
+
* number). The last visitor of the last wave gone ends the round as won;
|
|
392
|
+
* the light at 0 ends it lost.
|
|
393
|
+
*/
|
|
394
|
+
export const Visitors = defineSystem(
|
|
395
|
+
"Visitors",
|
|
396
|
+
{
|
|
397
|
+
reads: [Tuning, Prefs, og.TweenCompleted],
|
|
398
|
+
writes: [Game, Visitor, og.Transform, og.Sprite, og.NavAgent, og.Flipbook, og.ParticleSystem],
|
|
399
|
+
after: ["Plants"],
|
|
400
|
+
},
|
|
401
|
+
(q, time, world) => {
|
|
402
|
+
const game = world.resource(Game);
|
|
403
|
+
if (!game.ok) return;
|
|
404
|
+
const g = game.value;
|
|
405
|
+
const t = lazyTuning(world);
|
|
406
|
+
// Shots that landed this tick: damage and frost by the visitor's slot.
|
|
407
|
+
const damage = new Array<number>(VISITORS).fill(0);
|
|
408
|
+
const frost = new Array<boolean>(VISITORS).fill(false);
|
|
409
|
+
for (const e of world.events(og.TweenCompleted)) {
|
|
410
|
+
if (e.tag < TAG) continue;
|
|
411
|
+
const kind = Math.floor(e.tag / TAG) - 1;
|
|
412
|
+
const slot = e.tag % TAG;
|
|
413
|
+
if (slot < VISITORS) {
|
|
414
|
+
damage[slot] = damage[slot]! + (kind === Plant.Frost ? t.frostDamage : t.thornDamage);
|
|
415
|
+
if (kind === Plant.Frost) frost[slot] = true;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
const playing = g.phase === Phase.Play && !g.paused;
|
|
419
|
+
const held = time.hitStop > 0 || !playing;
|
|
420
|
+
|
|
421
|
+
// The wave clock.
|
|
422
|
+
let spawnKind = -1;
|
|
423
|
+
if (playing && time.hitStop === 0) {
|
|
424
|
+
if (!g.inWave && g.wave < WAVES.length) {
|
|
425
|
+
if (g.callNext && g.breakTicks > 0) {
|
|
426
|
+
const bonus = Math.ceil(g.breakTicks / 60) * 2;
|
|
427
|
+
g.gold += bonus;
|
|
428
|
+
g.breakTicks = 0;
|
|
429
|
+
}
|
|
430
|
+
if (g.breakTicks > 0) g.breakTicks -= 1;
|
|
431
|
+
if (g.breakTicks === 0) startWave(world, g);
|
|
432
|
+
} else if (g.inWave && g.toSpawn > 0) {
|
|
433
|
+
if (g.spawnTicks > 0) g.spawnTicks -= 1;
|
|
434
|
+
if (g.spawnTicks === 0) {
|
|
435
|
+
const letters = WAVES[g.wave - 1]!;
|
|
436
|
+
spawnKind = "bms".indexOf(letters[g.spawned]!);
|
|
437
|
+
g.spawned += 1;
|
|
438
|
+
g.toSpawn -= 1;
|
|
439
|
+
g.spawnTicks = Math.max(1, Math.round(t.spawnGap * 60));
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
if (g.callNext) g.callNext = false;
|
|
444
|
+
|
|
445
|
+
let walking = 0;
|
|
446
|
+
const occ = [0, 0, 0, 0];
|
|
447
|
+
const goal = cellCenter(DOOR.x, DOOR.y);
|
|
448
|
+
const gate = cellCenter(GATE.x, GATE.y);
|
|
449
|
+
for (const a of q.archetypes()) {
|
|
450
|
+
const v = a.column(Visitor);
|
|
451
|
+
const p = a.column(og.Transform).position;
|
|
452
|
+
const sprite = a.column(og.Sprite);
|
|
453
|
+
const nav = a.column(og.NavAgent);
|
|
454
|
+
const fb = a.column(og.Flipbook);
|
|
455
|
+
const fx = a.column(og.ParticleSystem);
|
|
456
|
+
for (let i = 0; i < a.count; i++) {
|
|
457
|
+
const me = a.entity(i);
|
|
458
|
+
if (g.reset) {
|
|
459
|
+
v.active[i] = 0;
|
|
460
|
+
v.dying[i] = 0;
|
|
461
|
+
sprite.visible[i] = 0;
|
|
462
|
+
park(p, nav, fx, i);
|
|
463
|
+
continue;
|
|
464
|
+
}
|
|
465
|
+
if (v.dying[i]! > 0) {
|
|
466
|
+
if (!held) v.dying[i] = v.dying[i]! - 1;
|
|
467
|
+
if (v.dying[i] === 0) park(p, nav, fx, i);
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
if (!v.active[i]) {
|
|
471
|
+
if (spawnKind >= 0) {
|
|
472
|
+
// Through the gate: this row is the next visitor.
|
|
473
|
+
const k = KINDS[spawnKind]!;
|
|
474
|
+
const hp = Math.round(k.hp * (1 + t.hpGrowth * (g.wave - 1)));
|
|
475
|
+
v.active[i] = 1;
|
|
476
|
+
v.kind[i] = spawnKind;
|
|
477
|
+
v.hp[i] = hp;
|
|
478
|
+
v.maxHp[i] = hp;
|
|
479
|
+
v.speed[i] = k.speed;
|
|
480
|
+
v.slow[i] = 0;
|
|
481
|
+
p[i * 3] = gate.x;
|
|
482
|
+
p[i * 3 + 1] = gate.y + 0.3;
|
|
483
|
+
sprite.visible[i] = 1;
|
|
484
|
+
sprite.opacity[i] = 1;
|
|
485
|
+
sprite.color[i * 3] = 1;
|
|
486
|
+
sprite.color[i * 3 + 1] = 1;
|
|
487
|
+
sprite.color[i * 3 + 2] = 1;
|
|
488
|
+
fb.clip[i] = clipOf(k.name);
|
|
489
|
+
nav.seeking[i] = 1;
|
|
490
|
+
nav.speed[i] = k.speed;
|
|
491
|
+
spawnKind = -1;
|
|
492
|
+
}
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
495
|
+
if (damage[v.slot[i]!]! > 0 && !held) {
|
|
496
|
+
v.hp[i] = Math.max(0, v.hp[i]! - damage[v.slot[i]!]!);
|
|
497
|
+
if (frost[v.slot[i]!]) v.slow[i] = t.frostTicks;
|
|
498
|
+
must(og.tween.flash(world, { entity: me, duration: 0.08 }));
|
|
499
|
+
}
|
|
500
|
+
const x = p[i * 3]!;
|
|
501
|
+
const y = p[i * 3 + 1]!;
|
|
502
|
+
if (v.hp[i]! <= 0) {
|
|
503
|
+
pop(world, g, t, v, sprite, nav, fx, i, x, y);
|
|
504
|
+
continue;
|
|
505
|
+
}
|
|
506
|
+
if (Math.hypot(x - goal.x, y - goal.y) < 0.45 || nav.status[i] === NAV_ARRIVED) {
|
|
507
|
+
leak(world, g, t, v, i);
|
|
508
|
+
park(p, nav, fx, i);
|
|
509
|
+
sprite.visible[i] = 0;
|
|
510
|
+
continue;
|
|
511
|
+
}
|
|
512
|
+
if (!held && v.slow[i]! > 0) v.slow[i] = v.slow[i]! - 1;
|
|
513
|
+
const slowed = v.slow[i]! > 0;
|
|
514
|
+
nav.speed[i] = v.speed[i]! * (slowed ? t.frostSlow : 1);
|
|
515
|
+
fb.speed[i] = slowed ? t.frostSlow : 1;
|
|
516
|
+
const tint = slowed ? FROSTED : WHITE;
|
|
517
|
+
sprite.color[i * 3] = tint.r;
|
|
518
|
+
sprite.color[i * 3 + 1] = tint.g;
|
|
519
|
+
sprite.color[i * 3 + 2] = tint.b;
|
|
520
|
+
walking += 1;
|
|
521
|
+
const c = cellOf(x, y);
|
|
522
|
+
if (c.x >= 0 && c.x < COLS && c.y >= 0 && c.y < ROWS) {
|
|
523
|
+
const idx = c.y * COLS + c.x;
|
|
524
|
+
occ[idx >> 5] = (occ[idx >> 5]! | (1 << (idx & 31))) >>> 0;
|
|
525
|
+
}
|
|
526
|
+
// A health bar over a hurt visitor.
|
|
527
|
+
if (v.hp[i]! < v.maxHp[i]!) {
|
|
528
|
+
const f = v.hp[i]! / v.maxHp[i]!;
|
|
529
|
+
must(og.render.sprite(world, { position: { x: x - 0.35, y: y + 0.5, z: 0 }, width: 0.7, height: 0.1, anchor: { x: 0, y: 0.5 }, color: { r: 0.05, g: 0.08, b: 0.06 }, layer: 9 }));
|
|
530
|
+
must(og.render.sprite(world, { position: { x: x - 0.35, y: y + 0.5, z: 0 }, width: 0.7 * f, height: 0.1, anchor: { x: 0, y: 0.5 }, color: f > 0.5 ? { r: 0.35, g: 0.9, b: 0.45 } : { r: 1, g: 0.55, b: 0.2 }, layer: 9 }));
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
// A resource field written is a call into the engine: write only what changed.
|
|
535
|
+
if (g.reset) g.reset = false;
|
|
536
|
+
if (occ[0] !== g.occ0) g.occ0 = occ[0]!;
|
|
537
|
+
if (occ[1] !== g.occ1) g.occ1 = occ[1]!;
|
|
538
|
+
if (occ[2] !== g.occ2) g.occ2 = occ[2]!;
|
|
539
|
+
if (occ[3] !== g.occ3) g.occ3 = occ[3]!;
|
|
540
|
+
if (walking !== g.walking) g.walking = walking;
|
|
541
|
+
|
|
542
|
+
if (!playing) return;
|
|
543
|
+
if (g.lives === 0) {
|
|
544
|
+
endRound(world, g, false);
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
if (g.inWave && g.toSpawn === 0 && walking === 0 && time.hitStop === 0) {
|
|
548
|
+
g.inWave = false;
|
|
549
|
+
const bonus = 20 + 5 * g.wave;
|
|
550
|
+
g.gold += bonus;
|
|
551
|
+
g.sfx |= Sound.Clear;
|
|
552
|
+
float(world, say(world, "float.clear", { n: bonus }), goal.x, goal.y + 2.2, MINT, true, 0.45);
|
|
553
|
+
if (g.wave >= WAVES.length) endRound(world, g, true);
|
|
554
|
+
else g.breakTicks = Math.max(1, Math.round(t.waveBreak * 60));
|
|
555
|
+
}
|
|
556
|
+
},
|
|
557
|
+
);
|
|
558
|
+
|
|
559
|
+
function startWave(world: World, g: GameV): void {
|
|
560
|
+
g.wave += 1;
|
|
561
|
+
g.inWave = true;
|
|
562
|
+
g.toSpawn = WAVES[g.wave - 1]!.length;
|
|
563
|
+
g.spawned = 0;
|
|
564
|
+
g.spawnTicks = 1;
|
|
565
|
+
g.sfx |= Sound.Wave;
|
|
566
|
+
const gate = cellCenter(GATE.x, GATE.y);
|
|
567
|
+
float(world, say(world, "float.wave", { n: g.wave }), gate.x, gate.y - 1.2, GOLD, true, 0.5);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
function park(p: Float32Array, nav: View<typeof og.NavAgent>, fx: View<typeof og.ParticleSystem>, i: number): void {
|
|
571
|
+
p[i * 3] = PARK.x;
|
|
572
|
+
p[i * 3 + 1] = PARK.y;
|
|
573
|
+
nav.seeking[i] = 0;
|
|
574
|
+
fx.visible[i] = 0;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
function pop(world: World, g: GameV, t: TuneV, v: View<typeof Visitor>, sprite: View<typeof og.Sprite>, nav: View<typeof og.NavAgent>, fx: View<typeof og.ParticleSystem>, i: number, x: number, y: number): void {
|
|
578
|
+
const k = KINDS[v.kind[i]!]!;
|
|
579
|
+
v.active[i] = 0;
|
|
580
|
+
v.dying[i] = POP_TICKS;
|
|
581
|
+
sprite.visible[i] = 0;
|
|
582
|
+
nav.seeking[i] = 0;
|
|
583
|
+
fx.visible[i] = 1;
|
|
584
|
+
fx.startTick[i] = world.tick;
|
|
585
|
+
g.kills += 1;
|
|
586
|
+
g.gold += k.bounty;
|
|
587
|
+
g.sfx |= Sound.Pop;
|
|
588
|
+
float(world, say(world, "float.gold", { n: k.bounty }), x, y + 0.4, GOLD);
|
|
589
|
+
// A light hit stop, at most one per 10 ticks so a stream of pops does not stutter (og-feel §3).
|
|
590
|
+
if (world.tick - g.lastStop >= 10 && t.killStop > 0) {
|
|
591
|
+
must(og.time.hitStop(world, t.killStop));
|
|
592
|
+
g.lastStop = world.tick;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
function leak(world: World, g: GameV, t: TuneV, v: View<typeof Visitor>, i: number): void {
|
|
597
|
+
const k = KINDS[v.kind[i]!]!;
|
|
598
|
+
v.active[i] = 0;
|
|
599
|
+
g.leaks += 1;
|
|
600
|
+
g.lives = Math.max(0, g.lives - k.harm);
|
|
601
|
+
g.sfx |= Sound.Leak;
|
|
602
|
+
const goal = cellCenter(DOOR.x, DOOR.y);
|
|
603
|
+
float(world, say(world, "float.leak", { n: k.harm }), goal.x, goal.y + 0.8, RED, true, 0.5);
|
|
604
|
+
must(og.time.hitStop(world, t.leakStop));
|
|
605
|
+
const feelK = feel(world);
|
|
606
|
+
must(og.camera.shake(world, t.leakShake * feelK));
|
|
607
|
+
must(og.camera.kick(world, { x: 0, y: -1, z: 0 }, 0.15 * feelK));
|
|
608
|
+
const lantern = world.find("lantern");
|
|
609
|
+
if (lantern !== null) {
|
|
610
|
+
must(og.tween.flash(world, { entity: lantern, color: RED, duration: 0.25 }));
|
|
611
|
+
must(og.tween.squash(world, { entity: lantern, impact: { x: 1.25, y: 0.8 }, duration: 0.25 }));
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
/** The round is over: the score, the best (saved with its revision), the board and the telemetry. */
|
|
616
|
+
export function endRound(world: World, g: GameV, won: boolean): void {
|
|
617
|
+
g.phase = Phase.Over;
|
|
618
|
+
g.won = won;
|
|
619
|
+
g.inWave = false;
|
|
620
|
+
g.overTick = world.tick;
|
|
621
|
+
g.score = g.kills * 10 + g.lives * 50 + g.gold;
|
|
622
|
+
g.newBest = g.score > g.best;
|
|
623
|
+
g.sfx |= won ? Sound.Won : Sound.Lost;
|
|
624
|
+
if (g.newBest) {
|
|
625
|
+
g.best = g.score;
|
|
626
|
+
g.bestWrite = must2(og.platform.storeSet(world, { key: "best", value: g.score, revision: g.bestRevision }));
|
|
627
|
+
}
|
|
628
|
+
must(og.platform.leaderboardSubmit(world, { board: "main", score: g.score }));
|
|
629
|
+
must(og.platform.telemetry(world, "round.over", { won, wave: g.wave, kills: g.kills, lives: g.lives, score: g.score }));
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
/** Plays each requested sound once: a voice already playing is stopped this tick and restarted the next. */
|
|
633
|
+
export const Voices = defineSystem("Voices", { writes: [Game, Sfx, og.AudioSource, og.Rng], after: ["Visitors"] }, (q, _time, world) => {
|
|
634
|
+
const game = world.resource(Game);
|
|
635
|
+
if (!game.ok) return;
|
|
636
|
+
const g = game.value;
|
|
637
|
+
if (g.sfx === 0) return;
|
|
638
|
+
const rng = world.resource(og.Rng);
|
|
639
|
+
let left = g.sfx;
|
|
640
|
+
for (const a of q.archetypes()) {
|
|
641
|
+
const sfx = a.column(Sfx);
|
|
642
|
+
const src = a.column(og.AudioSource);
|
|
643
|
+
for (let i = 0; i < a.count; i++) {
|
|
644
|
+
const b = sfx.bit[i]!;
|
|
645
|
+
if ((g.sfx & b) === 0) continue;
|
|
646
|
+
if (src.playing[i]) {
|
|
647
|
+
src.playing[i] = 0;
|
|
648
|
+
} else {
|
|
649
|
+
src.playing[i] = 1;
|
|
650
|
+
sfx.plays[i] = sfx.plays[i]! + 1;
|
|
651
|
+
// Shots and pops vary a little, so a stream of them does not machine-gun (og-audio §1).
|
|
652
|
+
if ((b === Sound.Thorn || b === Sound.Pop || b === Sound.Frost) && rng.ok) src.pitch[i] = rng.value.range(0.92, 1.08);
|
|
653
|
+
left &= ~b;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
g.sfx = left;
|
|
658
|
+
});
|