@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.
Files changed (590) hide show
  1. package/README.md +57 -2
  2. package/archetypes/README.md +99 -0
  3. package/archetypes/idle/.origin/setup +14 -0
  4. package/archetypes/idle/LICENSES.md +12 -0
  5. package/archetypes/idle/README.md +234 -0
  6. package/archetypes/idle/assets/audio/buy.wav +0 -0
  7. package/archetypes/idle/assets/audio/milestone.wav +0 -0
  8. package/archetypes/idle/assets/audio/nova.wav +0 -0
  9. package/archetypes/idle/assets/audio/orbit.wav +0 -0
  10. package/archetypes/idle/assets/audio/tap.wav +0 -0
  11. package/archetypes/idle/assets/audio/ui-close.ogt +9 -0
  12. package/archetypes/idle/assets/audio/ui-error.ogt +9 -0
  13. package/archetypes/idle/assets/audio/ui-open.ogt +9 -0
  14. package/archetypes/idle/assets/audio/ui-press.ogt +9 -0
  15. package/archetypes/idle/assets/audio/ui-success.ogt +9 -0
  16. package/archetypes/idle/assets/fonts/NotoSansSC-subset.ttf +0 -0
  17. package/archetypes/idle/assets/fonts/NotoSansSC-subset.ttf.ogt +10 -0
  18. package/archetypes/idle/assets/fonts/OFL.txt +93 -0
  19. package/archetypes/idle/assets/fx/drift.ogt +21 -0
  20. package/archetypes/idle/assets/fx/milestone.ogt +21 -0
  21. package/archetypes/idle/assets/fx/nova.ogt +22 -0
  22. package/archetypes/idle/assets/fx/stars.ogt +20 -0
  23. package/archetypes/idle/assets/fx/tap.ogt +23 -0
  24. package/archetypes/idle/assets/looks/idle.ogt +17 -0
  25. package/archetypes/idle/assets/skins/sparkorb/ChakraPetch-BoldItalic.ttf +0 -0
  26. package/archetypes/idle/assets/skins/sparkorb/ChakraPetch-BoldItalic.ttf.ogt +9 -0
  27. package/archetypes/idle/assets/skins/sparkorb/LICENSES.md +19 -0
  28. package/archetypes/idle/assets/skins/sparkorb/OFL.txt +95 -0
  29. package/archetypes/idle/assets/skins/sparkorb/Orbitron-Medium.ttf +0 -0
  30. package/archetypes/idle/assets/skins/sparkorb/Orbitron-Medium.ttf.ogt +9 -0
  31. package/archetypes/idle/assets/skins/sparkorb/Rajdhani-Bold.ttf +0 -0
  32. package/archetypes/idle/assets/skins/sparkorb/Rajdhani-Bold.ttf.ogt +9 -0
  33. package/archetypes/idle/assets/skins/sparkorb/atlas.png +0 -0
  34. package/archetypes/idle/assets/skins/sparkorb/atlas.png.ogt +7 -0
  35. package/archetypes/idle/assets/skins/sparkorb/icons.png +0 -0
  36. package/archetypes/idle/assets/skins/sparkorb/icons.png.ogt +7 -0
  37. package/archetypes/idle/assets/skins/sparkorb/skin.ogt +113 -0
  38. package/archetypes/idle/assets/sprites/glow.png +0 -0
  39. package/archetypes/idle/assets/sprites/glow.png.ogt +8 -0
  40. package/archetypes/idle/assets/sprites/mote-crystal.png +0 -0
  41. package/archetypes/idle/assets/sprites/mote-crystal.png.ogt +7 -0
  42. package/archetypes/idle/assets/sprites/mote-ember.png +0 -0
  43. package/archetypes/idle/assets/sprites/mote-ember.png.ogt +7 -0
  44. package/archetypes/idle/assets/sprites/mote-star.png +0 -0
  45. package/archetypes/idle/assets/sprites/mote-star.png.ogt +7 -0
  46. package/archetypes/idle/assets/sprites/mote-storm.png +0 -0
  47. package/archetypes/idle/assets/sprites/mote-storm.png.ogt +7 -0
  48. package/archetypes/idle/assets/sprites/orb.png +0 -0
  49. package/archetypes/idle/assets/sprites/orb.png.ogt +7 -0
  50. package/archetypes/idle/assets/sprites/spark.png +0 -0
  51. package/archetypes/idle/assets/sprites/spark.png.ogt +7 -0
  52. package/archetypes/idle/assets/strings/en.ogt +62 -0
  53. package/archetypes/idle/assets/strings/zh-CN.ogt +62 -0
  54. package/archetypes/idle/gitattributes +22 -0
  55. package/archetypes/idle/gitignore +8 -0
  56. package/archetypes/idle/host.d.ts +46 -0
  57. package/archetypes/idle/package.json +18 -0
  58. package/archetypes/idle/project.ogt +14 -0
  59. package/archetypes/idle/references/metal/card.png +0 -0
  60. package/archetypes/idle/references/metal/orbit.png +0 -0
  61. package/archetypes/idle/references/metal/title.png +0 -0
  62. package/archetypes/idle/src/components.ts +139 -0
  63. package/archetypes/idle/src/main.ts +247 -0
  64. package/archetypes/idle/src/numbers.ts +126 -0
  65. package/archetypes/idle/src/systems.ts +340 -0
  66. package/archetypes/idle/src/ui.ts +412 -0
  67. package/archetypes/idle/tests/away.og.ts +42 -0
  68. package/archetypes/idle/tests/flow.og.ts +57 -0
  69. package/archetypes/idle/tests/frames.og.ts +33 -0
  70. package/archetypes/idle/tests/frames.ts +134 -0
  71. package/archetypes/idle/tests/lib.ts +74 -0
  72. package/archetypes/idle/tests/milestone.og.ts +32 -0
  73. package/archetypes/idle/tests/nova.og.ts +52 -0
  74. package/archetypes/idle/tests/offline.og.ts +60 -0
  75. package/archetypes/idle/tests/pad.og.ts +55 -0
  76. package/archetypes/idle/tests/pause.og.ts +68 -0
  77. package/archetypes/idle/tests/phone.og.ts +50 -0
  78. package/archetypes/idle/tests/replay.og.ts +28 -0
  79. package/archetypes/idle/tools/make-assets.py +448 -0
  80. package/archetypes/idle/tools/oglite.py +285 -0
  81. package/archetypes/idle/tsconfig.json +17 -0
  82. package/archetypes/match3/.origin/setup +14 -0
  83. package/archetypes/match3/LICENSES.md +7 -0
  84. package/archetypes/match3/README.md +205 -0
  85. package/archetypes/match3/assets/audio/cascade.wav +0 -0
  86. package/archetypes/match3/assets/audio/clear.wav +0 -0
  87. package/archetypes/match3/assets/audio/lost.wav +0 -0
  88. package/archetypes/match3/assets/audio/refused.wav +0 -0
  89. package/archetypes/match3/assets/audio/select.wav +0 -0
  90. package/archetypes/match3/assets/audio/swap.wav +0 -0
  91. package/archetypes/match3/assets/audio/won.wav +0 -0
  92. package/archetypes/match3/assets/fonts/OFL.txt +93 -0
  93. package/archetypes/match3/assets/fonts/ui.ttf +0 -0
  94. package/archetypes/match3/assets/fonts/ui.ttf.ogt +11 -0
  95. package/archetypes/match3/assets/scenes/main.ogt +24 -0
  96. package/archetypes/match3/assets/sprites/backdrop.png +0 -0
  97. package/archetypes/match3/assets/sprites/board.ogt +21 -0
  98. package/archetypes/match3/assets/sprites/cells.ogt +7 -0
  99. package/archetypes/match3/assets/sprites/cells.png +0 -0
  100. package/archetypes/match3/assets/sprites/cells.png.ogt +7 -0
  101. package/archetypes/match3/assets/sprites/gems.ogt +75 -0
  102. package/archetypes/match3/assets/sprites/gems.png +0 -0
  103. package/archetypes/match3/assets/sprites/panel.png +0 -0
  104. package/archetypes/match3/assets/sprites/ring.png +0 -0
  105. package/archetypes/match3/gitattributes +22 -0
  106. package/archetypes/match3/gitignore +8 -0
  107. package/archetypes/match3/host.d.ts +46 -0
  108. package/archetypes/match3/package.json +18 -0
  109. package/archetypes/match3/project.ogt +18 -0
  110. package/archetypes/match3/references/metal/cascade.png +0 -0
  111. package/archetypes/match3/references/metal/clearing.png +0 -0
  112. package/archetypes/match3/references/metal/dealt.png +0 -0
  113. package/archetypes/match3/src/art.ts +54 -0
  114. package/archetypes/match3/src/board.ts +112 -0
  115. package/archetypes/match3/src/components.ts +95 -0
  116. package/archetypes/match3/src/layout.ts +25 -0
  117. package/archetypes/match3/src/main.ts +199 -0
  118. package/archetypes/match3/src/systems.ts +631 -0
  119. package/archetypes/match3/tests/drag.og.ts +31 -0
  120. package/archetypes/match3/tests/endings.og.ts +40 -0
  121. package/archetypes/match3/tests/frames.og.ts +49 -0
  122. package/archetypes/match3/tests/frames.ts +134 -0
  123. package/archetypes/match3/tests/hidpi.og.ts +41 -0
  124. package/archetypes/match3/tests/lib.ts +64 -0
  125. package/archetypes/match3/tests/replay.og.ts +28 -0
  126. package/archetypes/match3/tests/sounds.og.ts +50 -0
  127. package/archetypes/match3/tests/swap.og.ts +67 -0
  128. package/archetypes/match3/tools/make-assets.py +404 -0
  129. package/archetypes/match3/tools/oglite.py +285 -0
  130. package/archetypes/match3/tsconfig.json +17 -0
  131. package/archetypes/rhythm/.origin/setup +14 -0
  132. package/archetypes/rhythm/LICENSES.md +13 -0
  133. package/archetypes/rhythm/README.md +235 -0
  134. package/archetypes/rhythm/assets/audio/bass0.wav +0 -0
  135. package/archetypes/rhythm/assets/audio/bass1.wav +0 -0
  136. package/archetypes/rhythm/assets/audio/bass2.wav +0 -0
  137. package/archetypes/rhythm/assets/audio/bass3.wav +0 -0
  138. package/archetypes/rhythm/assets/audio/chords0.wav +0 -0
  139. package/archetypes/rhythm/assets/audio/chords1.wav +0 -0
  140. package/archetypes/rhythm/assets/audio/chords2.wav +0 -0
  141. package/archetypes/rhythm/assets/audio/chords3.wav +0 -0
  142. package/archetypes/rhythm/assets/audio/clear.wav +0 -0
  143. package/archetypes/rhythm/assets/audio/click.wav +0 -0
  144. package/archetypes/rhythm/assets/audio/drums.wav +0 -0
  145. package/archetypes/rhythm/assets/audio/fail.wav +0 -0
  146. package/archetypes/rhythm/assets/audio/leadA.wav +0 -0
  147. package/archetypes/rhythm/assets/audio/leadB.wav +0 -0
  148. package/archetypes/rhythm/assets/audio/miss.wav +0 -0
  149. package/archetypes/rhythm/assets/audio/tap0.wav +0 -0
  150. package/archetypes/rhythm/assets/audio/tap1.wav +0 -0
  151. package/archetypes/rhythm/assets/audio/tap2.wav +0 -0
  152. package/archetypes/rhythm/assets/audio/ui-close.ogt +9 -0
  153. package/archetypes/rhythm/assets/audio/ui-error.ogt +9 -0
  154. package/archetypes/rhythm/assets/audio/ui-open.ogt +9 -0
  155. package/archetypes/rhythm/assets/audio/ui-press.ogt +9 -0
  156. package/archetypes/rhythm/assets/audio/ui-success.ogt +9 -0
  157. package/archetypes/rhythm/assets/charts/neon-pulse.ogt +919 -0
  158. package/archetypes/rhythm/assets/fonts/NotoSansSC-subset.ttf +0 -0
  159. package/archetypes/rhythm/assets/fonts/NotoSansSC-subset.ttf.ogt +10 -0
  160. package/archetypes/rhythm/assets/fonts/OFL.txt +93 -0
  161. package/archetypes/rhythm/assets/fx/hit.ogt +22 -0
  162. package/archetypes/rhythm/assets/skins/lanebeat/ChakraPetch-Medium.ttf +0 -0
  163. package/archetypes/rhythm/assets/skins/lanebeat/ChakraPetch-Medium.ttf.ogt +9 -0
  164. package/archetypes/rhythm/assets/skins/lanebeat/JetBrainsMono-Regular.ttf +0 -0
  165. package/archetypes/rhythm/assets/skins/lanebeat/JetBrainsMono-Regular.ttf.ogt +9 -0
  166. package/archetypes/rhythm/assets/skins/lanebeat/LICENSES.md +17 -0
  167. package/archetypes/rhythm/assets/skins/lanebeat/OFL.txt +95 -0
  168. package/archetypes/rhythm/assets/skins/lanebeat/Orbitron-Bold.ttf +0 -0
  169. package/archetypes/rhythm/assets/skins/lanebeat/Orbitron-Bold.ttf.ogt +9 -0
  170. package/archetypes/rhythm/assets/skins/lanebeat/atlas.png +0 -0
  171. package/archetypes/rhythm/assets/skins/lanebeat/atlas.png.ogt +7 -0
  172. package/archetypes/rhythm/assets/skins/lanebeat/icons.png +0 -0
  173. package/archetypes/rhythm/assets/skins/lanebeat/icons.png.ogt +7 -0
  174. package/archetypes/rhythm/assets/skins/lanebeat/skin.ogt +110 -0
  175. package/archetypes/rhythm/assets/sprites/lane.png +0 -0
  176. package/archetypes/rhythm/assets/sprites/lane.png.ogt +7 -0
  177. package/archetypes/rhythm/assets/sprites/note.png +0 -0
  178. package/archetypes/rhythm/assets/sprites/note.png.ogt +7 -0
  179. package/archetypes/rhythm/assets/sprites/ring.png +0 -0
  180. package/archetypes/rhythm/assets/sprites/ring.png.ogt +7 -0
  181. package/archetypes/rhythm/assets/sprites/spark.png +0 -0
  182. package/archetypes/rhythm/assets/sprites/spark.png.ogt +7 -0
  183. package/archetypes/rhythm/assets/strings/en.ogt +61 -0
  184. package/archetypes/rhythm/assets/strings/zh-CN.ogt +61 -0
  185. package/archetypes/rhythm/gitattributes +22 -0
  186. package/archetypes/rhythm/gitignore +8 -0
  187. package/archetypes/rhythm/host.d.ts +46 -0
  188. package/archetypes/rhythm/package.json +18 -0
  189. package/archetypes/rhythm/project.ogt +14 -0
  190. package/archetypes/rhythm/references/metal/highway.png +0 -0
  191. package/archetypes/rhythm/references/metal/results.png +0 -0
  192. package/archetypes/rhythm/references/metal/title.png +0 -0
  193. package/archetypes/rhythm/src/components.ts +147 -0
  194. package/archetypes/rhythm/src/main.ts +202 -0
  195. package/archetypes/rhythm/src/systems.ts +490 -0
  196. package/archetypes/rhythm/src/ui.ts +421 -0
  197. package/archetypes/rhythm/tests/band.og.ts +45 -0
  198. package/archetypes/rhythm/tests/calibrate.og.ts +49 -0
  199. package/archetypes/rhythm/tests/clear.og.ts +51 -0
  200. package/archetypes/rhythm/tests/fail.og.ts +40 -0
  201. package/archetypes/rhythm/tests/flow.og.ts +54 -0
  202. package/archetypes/rhythm/tests/frames.og.ts +35 -0
  203. package/archetypes/rhythm/tests/frames.ts +134 -0
  204. package/archetypes/rhythm/tests/lib.ts +123 -0
  205. package/archetypes/rhythm/tests/pad.og.ts +41 -0
  206. package/archetypes/rhythm/tests/pause.og.ts +77 -0
  207. package/archetypes/rhythm/tests/phone.og.ts +44 -0
  208. package/archetypes/rhythm/tests/replay.og.ts +27 -0
  209. package/archetypes/rhythm/tests/timing.og.ts +37 -0
  210. package/archetypes/rhythm/tools/make-assets.py +383 -0
  211. package/archetypes/rhythm/tools/oglite.py +285 -0
  212. package/archetypes/rhythm/tsconfig.json +17 -0
  213. package/archetypes/roguelike/.origin/setup +14 -0
  214. package/archetypes/roguelike/LICENSES.md +14 -0
  215. package/archetypes/roguelike/README.md +256 -0
  216. package/archetypes/roguelike/assets/ai/foe.ogt +28 -0
  217. package/archetypes/roguelike/assets/ai/guardian.ogt +26 -0
  218. package/archetypes/roguelike/assets/audio/bump.wav +0 -0
  219. package/archetypes/roguelike/assets/audio/drink.wav +0 -0
  220. package/archetypes/roguelike/assets/audio/fall.wav +0 -0
  221. package/archetypes/roguelike/assets/audio/hit.wav +0 -0
  222. package/archetypes/roguelike/assets/audio/hurt.wav +0 -0
  223. package/archetypes/roguelike/assets/audio/item.wav +0 -0
  224. package/archetypes/roguelike/assets/audio/kill.wav +0 -0
  225. package/archetypes/roguelike/assets/audio/pickup.wav +0 -0
  226. package/archetypes/roguelike/assets/audio/roar.wav +0 -0
  227. package/archetypes/roguelike/assets/audio/stairs.wav +0 -0
  228. package/archetypes/roguelike/assets/audio/step.ogt +9 -0
  229. package/archetypes/roguelike/assets/audio/telegraph.wav +0 -0
  230. package/archetypes/roguelike/assets/audio/tomb.wav +0 -0
  231. package/archetypes/roguelike/assets/audio/ui-close.ogt +9 -0
  232. package/archetypes/roguelike/assets/audio/ui-error.ogt +9 -0
  233. package/archetypes/roguelike/assets/audio/ui-open.ogt +9 -0
  234. package/archetypes/roguelike/assets/audio/ui-press.ogt +9 -0
  235. package/archetypes/roguelike/assets/audio/ui-success.ogt +9 -0
  236. package/archetypes/roguelike/assets/audio/won.wav +0 -0
  237. package/archetypes/roguelike/assets/fonts/NotoSansSC-subset.ttf +0 -0
  238. package/archetypes/roguelike/assets/fonts/NotoSansSC-subset.ttf.ogt +10 -0
  239. package/archetypes/roguelike/assets/fonts/OFL.txt +93 -0
  240. package/archetypes/roguelike/assets/maps/dive.ogt +106 -0
  241. package/archetypes/roguelike/assets/skins/lampdive/DotGothic16-Regular.ttf +0 -0
  242. package/archetypes/roguelike/assets/skins/lampdive/DotGothic16-Regular.ttf.ogt +9 -0
  243. package/archetypes/roguelike/assets/skins/lampdive/LICENSES.md +16 -0
  244. package/archetypes/roguelike/assets/skins/lampdive/OFL.txt +93 -0
  245. package/archetypes/roguelike/assets/skins/lampdive/atlas.png +0 -0
  246. package/archetypes/roguelike/assets/skins/lampdive/atlas.png.ogt +7 -0
  247. package/archetypes/roguelike/assets/skins/lampdive/icons.png +0 -0
  248. package/archetypes/roguelike/assets/skins/lampdive/icons.png.ogt +7 -0
  249. package/archetypes/roguelike/assets/skins/lampdive/skin.ogt +115 -0
  250. package/archetypes/roguelike/assets/sprites/dive.ogt +50 -0
  251. package/archetypes/roguelike/assets/sprites/dive.png +0 -0
  252. package/archetypes/roguelike/assets/sprites/dive.png.ogt +7 -0
  253. package/archetypes/roguelike/assets/sprites/glow.png +0 -0
  254. package/archetypes/roguelike/assets/sprites/glow.png.ogt +7 -0
  255. package/archetypes/roguelike/assets/strings/en.ogt +57 -0
  256. package/archetypes/roguelike/assets/strings/zh-CN.ogt +57 -0
  257. package/archetypes/roguelike/assets/tiles/tomb.ogt +31 -0
  258. package/archetypes/roguelike/assets/tiles/tomb.png +0 -0
  259. package/archetypes/roguelike/assets/tiles/tomb.png.ogt +7 -0
  260. package/archetypes/roguelike/gitattributes +22 -0
  261. package/archetypes/roguelike/gitignore +8 -0
  262. package/archetypes/roguelike/host.d.ts +46 -0
  263. package/archetypes/roguelike/package.json +18 -0
  264. package/archetypes/roguelike/project.ogt +14 -0
  265. package/archetypes/roguelike/references/metal/dive.png +0 -0
  266. package/archetypes/roguelike/references/metal/over.png +0 -0
  267. package/archetypes/roguelike/references/metal/title.png +0 -0
  268. package/archetypes/roguelike/src/art.ts +23 -0
  269. package/archetypes/roguelike/src/components.ts +169 -0
  270. package/archetypes/roguelike/src/dive.ts +144 -0
  271. package/archetypes/roguelike/src/foes.ts +174 -0
  272. package/archetypes/roguelike/src/main.ts +258 -0
  273. package/archetypes/roguelike/src/systems.ts +620 -0
  274. package/archetypes/roguelike/src/ui.ts +350 -0
  275. package/archetypes/roguelike/tests/flow.og.ts +54 -0
  276. package/archetypes/roguelike/tests/foes.og.ts +45 -0
  277. package/archetypes/roguelike/tests/frames.og.ts +32 -0
  278. package/archetypes/roguelike/tests/frames.ts +134 -0
  279. package/archetypes/roguelike/tests/lib.ts +83 -0
  280. package/archetypes/roguelike/tests/lose.og.ts +44 -0
  281. package/archetypes/roguelike/tests/pad.og.ts +54 -0
  282. package/archetypes/roguelike/tests/pause.og.ts +59 -0
  283. package/archetypes/roguelike/tests/phone.og.ts +54 -0
  284. package/archetypes/roguelike/tests/replay.og.ts +24 -0
  285. package/archetypes/roguelike/tests/win.og.ts +60 -0
  286. package/archetypes/roguelike/tools/make-assets.py +518 -0
  287. package/archetypes/roguelike/tools/oglite.py +285 -0
  288. package/archetypes/roguelike/tsconfig.json +17 -0
  289. package/archetypes/runner/.origin/setup +14 -0
  290. package/archetypes/runner/LICENSES.md +10 -0
  291. package/archetypes/runner/README.md +225 -0
  292. package/archetypes/runner/assets/audio/coin.wav +0 -0
  293. package/archetypes/runner/assets/audio/crash.wav +0 -0
  294. package/archetypes/runner/assets/audio/hold.ogt +9 -0
  295. package/archetypes/runner/assets/audio/jump.wav +0 -0
  296. package/archetypes/runner/assets/audio/start.wav +0 -0
  297. package/archetypes/runner/assets/fonts/OFL.txt +93 -0
  298. package/archetypes/runner/assets/fonts/ui.ttf +0 -0
  299. package/archetypes/runner/assets/fonts/ui.ttf.ogt +11 -0
  300. package/archetypes/runner/assets/maps/far.ogt +25 -0
  301. package/archetypes/runner/assets/maps/near.ogt +25 -0
  302. package/archetypes/runner/assets/maps/roofs.ogt +19 -0
  303. package/archetypes/runner/assets/scenes/main.ogt +35 -0
  304. package/archetypes/runner/assets/sprites/coin.ogt +11 -0
  305. package/archetypes/runner/assets/sprites/coin.png +0 -0
  306. package/archetypes/runner/assets/sprites/coin.png.ogt +7 -0
  307. package/archetypes/runner/assets/sprites/courier.ogt +32 -0
  308. package/archetypes/runner/assets/sprites/courier.png +0 -0
  309. package/archetypes/runner/assets/sprites/courier.png.ogt +7 -0
  310. package/archetypes/runner/assets/sprites/props.ogt +21 -0
  311. package/archetypes/runner/assets/sprites/props.png +0 -0
  312. package/archetypes/runner/assets/sprites/props.png.ogt +7 -0
  313. package/archetypes/runner/assets/sprites/sky.png +0 -0
  314. package/archetypes/runner/assets/sprites/sky.png.ogt +7 -0
  315. package/archetypes/runner/assets/tiles/city.ogt +18 -0
  316. package/archetypes/runner/assets/tiles/city.png +0 -0
  317. package/archetypes/runner/assets/tiles/city.png.ogt +7 -0
  318. package/archetypes/runner/gitattributes +22 -0
  319. package/archetypes/runner/gitignore +8 -0
  320. package/archetypes/runner/host.d.ts +46 -0
  321. package/archetypes/runner/package.json +18 -0
  322. package/archetypes/runner/project.ogt +18 -0
  323. package/archetypes/runner/references/metal/frames-coin.png +0 -0
  324. package/archetypes/runner/references/metal/frames-crash.png +0 -0
  325. package/archetypes/runner/references/metal/frames-title.png +0 -0
  326. package/archetypes/runner/src/art.ts +57 -0
  327. package/archetypes/runner/src/components.ts +94 -0
  328. package/archetypes/runner/src/main.ts +241 -0
  329. package/archetypes/runner/src/systems.ts +553 -0
  330. package/archetypes/runner/tests/coins.og.ts +30 -0
  331. package/archetypes/runner/tests/flow.og.ts +72 -0
  332. package/archetypes/runner/tests/frames.og.ts +37 -0
  333. package/archetypes/runner/tests/frames.ts +134 -0
  334. package/archetypes/runner/tests/jump.og.ts +44 -0
  335. package/archetypes/runner/tests/lib.ts +42 -0
  336. package/archetypes/runner/tests/records.og.ts +43 -0
  337. package/archetypes/runner/tests/replay.og.ts +36 -0
  338. package/archetypes/runner/tests/sounds.og.ts +43 -0
  339. package/archetypes/runner/tests/tune.og.ts +36 -0
  340. package/archetypes/runner/tools/make-assets.py +603 -0
  341. package/archetypes/runner/tools/oglite.py +285 -0
  342. package/archetypes/runner/tsconfig.json +17 -0
  343. package/archetypes/third-person/.origin/setup +14 -0
  344. package/archetypes/third-person/LICENSES.md +23 -0
  345. package/archetypes/third-person/README.md +249 -0
  346. package/archetypes/third-person/assets/ai/sentinel-east.ogt +69 -0
  347. package/archetypes/third-person/assets/ai/sentinel-north.ogt +69 -0
  348. package/archetypes/third-person/assets/ai/sentinel-west.ogt +69 -0
  349. package/archetypes/third-person/assets/anims/humanoid-clips.glb +0 -0
  350. package/archetypes/third-person/assets/audio/alarm.wav +0 -0
  351. package/archetypes/third-person/assets/audio/dawn.wav +0 -0
  352. package/archetypes/third-person/assets/audio/grab.wav +0 -0
  353. package/archetypes/third-person/assets/audio/ignite.wav +0 -0
  354. package/archetypes/third-person/assets/audio/jump.wav +0 -0
  355. package/archetypes/third-person/assets/audio/night.wav +0 -0
  356. package/archetypes/third-person/assets/audio/splash.wav +0 -0
  357. package/archetypes/third-person/assets/audio/step.ogt +9 -0
  358. package/archetypes/third-person/assets/audio/ui-close.ogt +9 -0
  359. package/archetypes/third-person/assets/audio/ui-error.ogt +9 -0
  360. package/archetypes/third-person/assets/audio/ui-open.ogt +9 -0
  361. package/archetypes/third-person/assets/audio/ui-press.ogt +9 -0
  362. package/archetypes/third-person/assets/audio/ui-success.ogt +9 -0
  363. package/archetypes/third-person/assets/audio/vale.wav +0 -0
  364. package/archetypes/third-person/assets/fonts/NotoSansSC-subset.ttf +0 -0
  365. package/archetypes/third-person/assets/fonts/NotoSansSC-subset.ttf.ogt +10 -0
  366. package/archetypes/third-person/assets/fonts/OFL.txt +93 -0
  367. package/archetypes/third-person/assets/fx/burst.ogt +25 -0
  368. package/archetypes/third-person/assets/fx/fire.ogt +24 -0
  369. package/archetypes/third-person/assets/fx/smoke.ogt +24 -0
  370. package/archetypes/third-person/assets/fx/splash.ogt +24 -0
  371. package/archetypes/third-person/assets/luts/teal-orange.cube +4917 -0
  372. package/archetypes/third-person/assets/models/stout.glb +0 -0
  373. package/archetypes/third-person/assets/models/strider.glb +0 -0
  374. package/archetypes/third-person/assets/models/strider.glb.ogt +9 -0
  375. package/archetypes/third-person/assets/nav/vale.ogt +43 -0
  376. package/archetypes/third-person/assets/rigs/strider.ogt +6 -0
  377. package/archetypes/third-person/assets/skins/ember/Cinzel-Bold.ttf +0 -0
  378. package/archetypes/third-person/assets/skins/ember/Cinzel-Bold.ttf.ogt +9 -0
  379. package/archetypes/third-person/assets/skins/ember/LICENSES.md +13 -0
  380. package/archetypes/third-person/assets/skins/ember/Newsreader-Medium.ttf +0 -0
  381. package/archetypes/third-person/assets/skins/ember/Newsreader-Medium.ttf.ogt +9 -0
  382. package/archetypes/third-person/assets/skins/ember/OFL.txt +94 -0
  383. package/archetypes/third-person/assets/skins/ember/atlas.png +0 -0
  384. package/archetypes/third-person/assets/skins/ember/atlas.png.ogt +7 -0
  385. package/archetypes/third-person/assets/skins/ember/icons.png +0 -0
  386. package/archetypes/third-person/assets/skins/ember/icons.png.ogt +7 -0
  387. package/archetypes/third-person/assets/skins/ember/skin.ogt +109 -0
  388. package/archetypes/third-person/assets/strings/en.ogt +47 -0
  389. package/archetypes/third-person/assets/strings/zh-CN.ogt +47 -0
  390. package/archetypes/third-person/assets/terrain/vale-control.png +0 -0
  391. package/archetypes/third-person/assets/terrain/vale.ogt +42 -0
  392. package/archetypes/third-person/assets/terrain/vale.png +0 -0
  393. package/archetypes/third-person/assets/textures/decals.png +0 -0
  394. package/archetypes/third-person/assets/textures/flame.png +0 -0
  395. package/archetypes/third-person/assets/textures/smoke.png +0 -0
  396. package/archetypes/third-person/assets/textures/spark.png +0 -0
  397. package/archetypes/third-person/assets/textures/terrain-grass.png +0 -0
  398. package/archetypes/third-person/assets/textures/terrain-path.png +0 -0
  399. package/archetypes/third-person/assets/textures/terrain-rock.png +0 -0
  400. package/archetypes/third-person/assets/textures/terrain-sand.png +0 -0
  401. package/archetypes/third-person/gitattributes +22 -0
  402. package/archetypes/third-person/gitignore +8 -0
  403. package/archetypes/third-person/host.d.ts +46 -0
  404. package/archetypes/third-person/package.json +18 -0
  405. package/archetypes/third-person/project.ogt +14 -0
  406. package/archetypes/third-person/references/metal/beacon.png +0 -0
  407. package/archetypes/third-person/references/metal/dawn.png +0 -0
  408. package/archetypes/third-person/references/metal/title.png +0 -0
  409. package/archetypes/third-person/references/webgl2/beacon.png +0 -0
  410. package/archetypes/third-person/src/anim.ts +87 -0
  411. package/archetypes/third-person/src/beacons.ts +80 -0
  412. package/archetypes/third-person/src/components.ts +148 -0
  413. package/archetypes/third-person/src/hero.ts +293 -0
  414. package/archetypes/third-person/src/main.ts +164 -0
  415. package/archetypes/third-person/src/sentinels.ts +159 -0
  416. package/archetypes/third-person/src/sound.ts +66 -0
  417. package/archetypes/third-person/src/ui.ts +451 -0
  418. package/archetypes/third-person/src/world.ts +212 -0
  419. package/archetypes/third-person/tests/flow.og.ts +70 -0
  420. package/archetypes/third-person/tests/frames.og.ts +35 -0
  421. package/archetypes/third-person/tests/frames.ts +134 -0
  422. package/archetypes/third-person/tests/hitstop.og.ts +26 -0
  423. package/archetypes/third-person/tests/lib.ts +87 -0
  424. package/archetypes/third-person/tests/lose.og.ts +44 -0
  425. package/archetypes/third-person/tests/pause.og.ts +64 -0
  426. package/archetypes/third-person/tests/phone.og.ts +65 -0
  427. package/archetypes/third-person/tests/replay.og.ts +32 -0
  428. package/archetypes/third-person/tests/restart.og.ts +28 -0
  429. package/archetypes/third-person/tests/sentinels.og.ts +48 -0
  430. package/archetypes/third-person/tests/win.og.ts +62 -0
  431. package/archetypes/third-person/tools/make-assets.py +353 -0
  432. package/archetypes/third-person/tools/oglite.py +285 -0
  433. package/archetypes/third-person/tsconfig.json +17 -0
  434. package/archetypes/topdown/.origin/setup +14 -0
  435. package/archetypes/topdown/LICENSES.md +10 -0
  436. package/archetypes/topdown/README.md +235 -0
  437. package/archetypes/topdown/assets/ai/slime.ogt +49 -0
  438. package/archetypes/topdown/assets/audio/coin.wav +0 -0
  439. package/archetypes/topdown/assets/audio/door.wav +0 -0
  440. package/archetypes/topdown/assets/audio/hit.wav +0 -0
  441. package/archetypes/topdown/assets/audio/hurt.wav +0 -0
  442. package/archetypes/topdown/assets/audio/key.wav +0 -0
  443. package/archetypes/topdown/assets/audio/step.ogt +9 -0
  444. package/archetypes/topdown/assets/fonts/OFL.txt +93 -0
  445. package/archetypes/topdown/assets/fonts/ui.ttf +0 -0
  446. package/archetypes/topdown/assets/fonts/ui.ttf.ogt +9 -0
  447. package/archetypes/topdown/assets/maps/tomb.tmj +2183 -0
  448. package/archetypes/topdown/assets/sprites/hero.ogt +58 -0
  449. package/archetypes/topdown/assets/sprites/hero.png +0 -0
  450. package/archetypes/topdown/assets/sprites/hero.png.ogt +7 -0
  451. package/archetypes/topdown/assets/sprites/items.ogt +15 -0
  452. package/archetypes/topdown/assets/sprites/items.png +0 -0
  453. package/archetypes/topdown/assets/sprites/items.png.ogt +7 -0
  454. package/archetypes/topdown/assets/sprites/slime.ogt +17 -0
  455. package/archetypes/topdown/assets/sprites/slime.png +0 -0
  456. package/archetypes/topdown/assets/sprites/slime.png.ogt +7 -0
  457. package/archetypes/topdown/assets/tiles/dungeon.ogt +65 -0
  458. package/archetypes/topdown/assets/tiles/dungeon.png +0 -0
  459. package/archetypes/topdown/assets/tiles/dungeon.png.ogt +7 -0
  460. package/archetypes/topdown/gitattributes +22 -0
  461. package/archetypes/topdown/gitignore +8 -0
  462. package/archetypes/topdown/host.d.ts +46 -0
  463. package/archetypes/topdown/package.json +18 -0
  464. package/archetypes/topdown/project.ogt +14 -0
  465. package/archetypes/topdown/references/metal/crit.png +0 -0
  466. package/archetypes/topdown/references/metal/dash.png +0 -0
  467. package/archetypes/topdown/references/metal/east.png +0 -0
  468. package/archetypes/topdown/references/metal/start.png +0 -0
  469. package/archetypes/topdown/src/art.ts +48 -0
  470. package/archetypes/topdown/src/components.ts +128 -0
  471. package/archetypes/topdown/src/main.ts +275 -0
  472. package/archetypes/topdown/src/systems.ts +503 -0
  473. package/archetypes/topdown/tests/ai.og.ts +64 -0
  474. package/archetypes/topdown/tests/combat.og.ts +72 -0
  475. package/archetypes/topdown/tests/door.og.ts +62 -0
  476. package/archetypes/topdown/tests/flee.og.ts +49 -0
  477. package/archetypes/topdown/tests/frames.og.ts +45 -0
  478. package/archetypes/topdown/tests/frames.ts +134 -0
  479. package/archetypes/topdown/tests/lib.ts +71 -0
  480. package/archetypes/topdown/tests/replay.og.ts +40 -0
  481. package/archetypes/topdown/tests/walk.og.ts +46 -0
  482. package/archetypes/topdown/tools/make-assets.py +623 -0
  483. package/archetypes/topdown/tools/oglite.py +285 -0
  484. package/archetypes/topdown/tsconfig.json +17 -0
  485. package/archetypes/tower-defense/.origin/setup +14 -0
  486. package/archetypes/tower-defense/LICENSES.md +15 -0
  487. package/archetypes/tower-defense/README.md +240 -0
  488. package/archetypes/tower-defense/assets/ai/plant.ogt +16 -0
  489. package/archetypes/tower-defense/assets/audio/clear.wav +0 -0
  490. package/archetypes/tower-defense/assets/audio/frost.wav +0 -0
  491. package/archetypes/tower-defense/assets/audio/leak.wav +0 -0
  492. package/archetypes/tower-defense/assets/audio/lost.wav +0 -0
  493. package/archetypes/tower-defense/assets/audio/night.wav +0 -0
  494. package/archetypes/tower-defense/assets/audio/plant.wav +0 -0
  495. package/archetypes/tower-defense/assets/audio/pop.wav +0 -0
  496. package/archetypes/tower-defense/assets/audio/thorn.wav +0 -0
  497. package/archetypes/tower-defense/assets/audio/ui-close.ogt +9 -0
  498. package/archetypes/tower-defense/assets/audio/ui-error.ogt +9 -0
  499. package/archetypes/tower-defense/assets/audio/ui-open.ogt +9 -0
  500. package/archetypes/tower-defense/assets/audio/ui-press.ogt +9 -0
  501. package/archetypes/tower-defense/assets/audio/ui-success.ogt +9 -0
  502. package/archetypes/tower-defense/assets/audio/wave.wav +0 -0
  503. package/archetypes/tower-defense/assets/audio/won.wav +0 -0
  504. package/archetypes/tower-defense/assets/fonts/NotoSansSC-subset.ttf +0 -0
  505. package/archetypes/tower-defense/assets/fonts/NotoSansSC-subset.ttf.ogt +10 -0
  506. package/archetypes/tower-defense/assets/fonts/OFL.txt +93 -0
  507. package/archetypes/tower-defense/assets/fx/fireflies.ogt +21 -0
  508. package/archetypes/tower-defense/assets/fx/pop.ogt +21 -0
  509. package/archetypes/tower-defense/assets/maps/garden.ogt +91 -0
  510. package/archetypes/tower-defense/assets/skins/pathguard/Fredoka-SemiBold.ttf +0 -0
  511. package/archetypes/tower-defense/assets/skins/pathguard/Fredoka-SemiBold.ttf.ogt +9 -0
  512. package/archetypes/tower-defense/assets/skins/pathguard/LICENSES.md +13 -0
  513. package/archetypes/tower-defense/assets/skins/pathguard/LilitaOne-Regular.ttf +0 -0
  514. package/archetypes/tower-defense/assets/skins/pathguard/LilitaOne-Regular.ttf.ogt +9 -0
  515. package/archetypes/tower-defense/assets/skins/pathguard/OFL.txt +94 -0
  516. package/archetypes/tower-defense/assets/skins/pathguard/atlas.png +0 -0
  517. package/archetypes/tower-defense/assets/skins/pathguard/atlas.png.ogt +7 -0
  518. package/archetypes/tower-defense/assets/skins/pathguard/icons.png +0 -0
  519. package/archetypes/tower-defense/assets/skins/pathguard/icons.png.ogt +7 -0
  520. package/archetypes/tower-defense/assets/skins/pathguard/skin.ogt +111 -0
  521. package/archetypes/tower-defense/assets/sprites/garden.ogt +66 -0
  522. package/archetypes/tower-defense/assets/sprites/garden.png +0 -0
  523. package/archetypes/tower-defense/assets/sprites/garden.png.ogt +7 -0
  524. package/archetypes/tower-defense/assets/sprites/glow.png +0 -0
  525. package/archetypes/tower-defense/assets/sprites/glow.png.ogt +7 -0
  526. package/archetypes/tower-defense/assets/sprites/ring.png +0 -0
  527. package/archetypes/tower-defense/assets/sprites/ring.png.ogt +7 -0
  528. package/archetypes/tower-defense/assets/sprites/spark.png +0 -0
  529. package/archetypes/tower-defense/assets/sprites/spark.png.ogt +7 -0
  530. package/archetypes/tower-defense/assets/strings/en.ogt +47 -0
  531. package/archetypes/tower-defense/assets/strings/zh-CN.ogt +47 -0
  532. package/archetypes/tower-defense/assets/tiles/garden.ogt +10 -0
  533. package/archetypes/tower-defense/assets/tiles/garden.png +0 -0
  534. package/archetypes/tower-defense/assets/tiles/garden.png.ogt +7 -0
  535. package/archetypes/tower-defense/gitattributes +22 -0
  536. package/archetypes/tower-defense/gitignore +8 -0
  537. package/archetypes/tower-defense/host.d.ts +46 -0
  538. package/archetypes/tower-defense/package.json +18 -0
  539. package/archetypes/tower-defense/project.ogt +14 -0
  540. package/archetypes/tower-defense/references/metal/end.png +0 -0
  541. package/archetypes/tower-defense/references/metal/title.png +0 -0
  542. package/archetypes/tower-defense/references/metal/wave.png +0 -0
  543. package/archetypes/tower-defense/src/art.ts +24 -0
  544. package/archetypes/tower-defense/src/components.ts +156 -0
  545. package/archetypes/tower-defense/src/main.ts +253 -0
  546. package/archetypes/tower-defense/src/systems.ts +658 -0
  547. package/archetypes/tower-defense/src/ui.ts +382 -0
  548. package/archetypes/tower-defense/tests/flow.og.ts +56 -0
  549. package/archetypes/tower-defense/tests/frames.og.ts +31 -0
  550. package/archetypes/tower-defense/tests/frames.ts +134 -0
  551. package/archetypes/tower-defense/tests/lib.ts +81 -0
  552. package/archetypes/tower-defense/tests/lose.og.ts +40 -0
  553. package/archetypes/tower-defense/tests/maze.og.ts +53 -0
  554. package/archetypes/tower-defense/tests/pad.og.ts +41 -0
  555. package/archetypes/tower-defense/tests/pause.og.ts +59 -0
  556. package/archetypes/tower-defense/tests/phone.og.ts +49 -0
  557. package/archetypes/tower-defense/tests/replay.og.ts +28 -0
  558. package/archetypes/tower-defense/tests/win.og.ts +58 -0
  559. package/archetypes/tower-defense/tools/make-assets.py +640 -0
  560. package/archetypes/tower-defense/tools/oglite.py +285 -0
  561. package/archetypes/tower-defense/tsconfig.json +17 -0
  562. package/bin/create.ts +503 -0
  563. package/looks/catalogue.json +1871 -0
  564. package/package.json +31 -4
  565. package/template/.origin/setup +14 -0
  566. package/template/LICENSES.md +23 -0
  567. package/template/README.md +37 -0
  568. package/template/assets/ai/guard.ogt +48 -0
  569. package/template/assets/audio/blip.wav +0 -0
  570. package/template/assets/audio/click.ogt +9 -0
  571. package/template/assets/fonts/NotoSansSC-Regular-subset.ttf +0 -0
  572. package/template/assets/fonts/NotoSansSC-Regular-subset.ttf.ogt +12 -0
  573. package/template/assets/fonts/OFL.txt +93 -0
  574. package/template/assets/looks/origin-game.ogt +12 -0
  575. package/template/assets/models/dropship.glb +0 -0
  576. package/template/assets/models/walker.glb +0 -0
  577. package/template/assets/nav/yard.ogt +27 -0
  578. package/template/assets/scenes/main.ogt +34 -0
  579. package/template/assets/strings/en.ogt +14 -0
  580. package/template/assets/textures/stone.png +0 -0
  581. package/template/assets/textures/stone_n.png +0 -0
  582. package/template/assets/textures/stone_n.png.ogt +7 -0
  583. package/template/gitattributes +22 -0
  584. package/template/gitignore +8 -0
  585. package/template/package.json +18 -0
  586. package/template/project.ogt +25 -0
  587. package/template/src/main.ts +246 -0
  588. package/template/tests/guard.og.ts +67 -0
  589. package/template/tests/smoke.og.ts +43 -0
  590. package/template/tsconfig.json +17 -0
@@ -0,0 +1,490 @@
1
+ // Three-Lane Beat's systems, in tick order after the screens (src/ui.ts):
2
+ // Clock (the song's og.Music clock follows Game.songStart), Play (presses,
3
+ // judgements, misses, the notes' scheduling by og.MusicBeat, drawing the
4
+ // highway), Band (the song's stems started on their bar lines by
5
+ // og.MusicBeat, the count-in's clicks), Lanes (the receptors' flash,
6
+ // squash and burst, the lanes' glow on the beat) and Voices.
7
+ //
8
+ // Time is the world's: tick / tick rate, the clock og.music and og.audio
9
+ // keep, so a stem started at `songStart + bar × barLength` sounds on its
10
+ // bar line to the sample. A press is judged at the time it happened (its
11
+ // tick's time and its event's `at` within the tick) less the output's
12
+ // latency (og.audio.outputLatency) and the calibrated offset
13
+ // (Prefs.offsetMs) against its note's exact time.
14
+
15
+ import { og, defineSystem } from "@origingame/engine";
16
+ import type { Value, World } from "@origingame/engine";
17
+ import { Game, Judgement, JUDGEMENTS, LANES, Note, Phase, Prefs, Receptor, Sfx, Sound, Stem, Tuning } from "./components.ts";
18
+ import { say } from "./ui.ts";
19
+
20
+ type GameV = Value<typeof Game>;
21
+ type TuneV = Value<typeof Tuning>;
22
+
23
+ /** The song's stems, in the order `start` spawns them. */
24
+ export const PARTS = ["drums", "bass0", "bass1", "bass2", "bass3", "chords0", "chords1", "chords2", "chords3", "leadA", "leadB", "click0", "click1", "click2", "click3"] as const;
25
+
26
+ /** Each lane's colour: cyan, magenta, gold. */
27
+ export const LANE_COLOURS = [
28
+ { r: 0.22, g: 0.88, b: 1 },
29
+ { r: 1, g: 0.3, b: 0.85 },
30
+ { r: 1, g: 0.82, b: 0.25 },
31
+ ] as const;
32
+ const JUDGE_COLOURS = [{ r: 1, g: 0.9, b: 0.35 }, { r: 0.4, g: 0.95, b: 1 }, { r: 0.85, g: 0.9, b: 1 }, { r: 1, g: 0.35, b: 0.4 }] as const;
33
+
34
+ /** The camera feel's scale: 0.3 under reduced motion (og-feel), 1 otherwise. */
35
+ export function feel(world: World): number {
36
+ const p = world.resource(Prefs);
37
+ return p.ok && p.value.reducedMotion ? 0.3 : 1;
38
+ }
39
+
40
+ export function must(r: { ok: true } | { ok: false; reason: string }): void {
41
+ if (!r.ok) throw new Error(r.reason);
42
+ }
43
+
44
+ export function must2<T>(r: { ok: true; value: T } | { ok: false; reason: string }): T {
45
+ if (!r.ok) throw new Error(r.reason);
46
+ return r.value;
47
+ }
48
+
49
+ /** Tuning, read on its first use in this call (a resource read encodes every field). */
50
+ export function lazyTuning(world: World): TuneV {
51
+ let v: TuneV | null = null;
52
+ return new Proxy({} as TuneV, { get: (_, k) => ((v ??= must2(world.resource(Tuning))) as unknown as Record<string | symbol, unknown>)[k] });
53
+ }
54
+
55
+ /** The world's time in seconds: the tick over the tick rate (og.music's and og.audio's clock). */
56
+ export function worldTime(world: World): number {
57
+ return world.tick / 60;
58
+ }
59
+
60
+ /** The song's beat length in seconds (Game.beatLength, set from the chart's Song). */
61
+ export function beatLength(g: GameV): number {
62
+ return 60 / g.bpm;
63
+ }
64
+
65
+ /** The stems that start on a bar (from 1): drums every bar; the bass, chords and lead on odd bars, two bars long. */
66
+ export function partsAt(bar: number, bars: number): string[] {
67
+ const out: string[] = [];
68
+ if (bar < 1 || bar > bars) return out;
69
+ out.push("drums");
70
+ if (bar % 2 === 1) {
71
+ // The two-bar chords Am, F, C, G in turn from bar 5.
72
+ const chord = (((bar - 5) / 2) % 4 + 4) % 4;
73
+ if (bar >= 5 && bar <= 21) out.push(`bass${chord}`);
74
+ if (bar >= 5 && bar <= 23) out.push(`chords${chord}`);
75
+ if (bar >= 9 && bar <= 19) out.push(((bar - 9) / 2) % 2 === 0 ? "leadA" : "leadB");
76
+ }
77
+ return out;
78
+ }
79
+
80
+ /** The song's position in beats at a world time (negative in the count-in). */
81
+ export function beatAt(g: GameV, t: number): number {
82
+ return (t - g.songStart) / beatLength(g);
83
+ }
84
+
85
+ /** Where the play is in world time: frozen while paused. */
86
+ function songNow(world: World, g: GameV): number {
87
+ return g.pausedAt >= 0 ? g.pausedAt : worldTime(world);
88
+ }
89
+
90
+ /** The world point under a CSS pixel, through the orthographic camera. */
91
+ export function screenToWorld(world: World, px: number, py: number): { x: number; y: number } | null {
92
+ const cam = world.resource(og.Camera);
93
+ const vp = og.ui.viewport(world);
94
+ if (!cam.ok || vp.height <= 0) return null;
95
+ const scale = vp.height / cam.value.height;
96
+ const at = cam.value.position;
97
+ return { x: at.x + (px - vp.width / 2) / scale, y: at.y - (py - vp.height / 2) / scale };
98
+ }
99
+
100
+ /** Each lane's keys and pad buttons. */
101
+ const LANE_KEYS: readonly (readonly string[])[] = [["KeyA", "ArrowLeft", "KeyJ"], ["KeyS", "ArrowDown", "KeyK", "Space"], ["KeyD", "ArrowRight", "KeyL"]];
102
+ const LANE_PADS: readonly (readonly string[])[] = [["left", "x"], ["down", "a"], ["right", "b"]];
103
+
104
+ /** The lane a finger at a CSS pixel is on, or -1 off the highway. */
105
+ function laneAt(world: World, g: GameV, x: number, y: number): number {
106
+ const w = screenToWorld(world, x, y);
107
+ if (w === null || w.y > g.hitY + 3.5) return -1;
108
+ const lane = Math.round(w.x / g.laneW) + 1;
109
+ return lane >= 0 && lane < LANES && Math.abs(w.x - (lane - 1) * g.laneW) <= g.laneW * 0.6 ? lane : -1;
110
+ }
111
+
112
+ /**
113
+ * The lanes pressed this tick, as a mask (keys, the pad, fingers on the
114
+ * highway, the HUD's zones), and when within the tick each lane's first
115
+ * press happened (`within[lane]`, in ticks: og.KeyDown's and
116
+ * og.PointerDown's `at`, from the host's event time; 0 for the pad, which
117
+ * the shell polls once a frame, and for the `hit` command).
118
+ */
119
+ function pressedLanes(world: World, g: GameV, inp: Value<typeof og.Input>, gp: Value<typeof og.Gamepad>, ptr: Value<typeof og.Pointers>, within: number[]): number {
120
+ let mask = 0;
121
+ within.fill(0);
122
+ const stamp = (lane: number, at: number) => {
123
+ within[lane] = mask & (1 << lane) ? Math.min(within[lane]!, at) : at;
124
+ mask |= 1 << lane;
125
+ };
126
+ for (const e of world.events(og.KeyDown)) {
127
+ if (e.repeat) continue;
128
+ const lane = LANE_KEYS.findIndex((keys) => keys.includes(e.key));
129
+ if (lane >= 0 && inp.pressed(e.key)) stamp(lane, e.at);
130
+ }
131
+ for (const e of world.events(og.PointerDown)) {
132
+ const lane = ptr.pressed(e.id) ? laneAt(world, g, e.x, e.y) : -1;
133
+ if (lane >= 0) stamp(lane, e.at);
134
+ }
135
+ for (let lane = 0; lane < LANES; lane++) {
136
+ if (mask & (1 << lane)) continue;
137
+ if (LANE_KEYS[lane]!.some((k) => inp.pressed(k)) || LANE_PADS[lane]!.some((b) => gp.pressed(b as never))) stamp(lane, 0);
138
+ }
139
+ for (let id = 0; id < ptr.count(); id++) {
140
+ if (!ptr.pressed(id)) continue;
141
+ const at = ptr.position(id);
142
+ const lane = laneAt(world, g, at.x, at.y);
143
+ if (lane >= 0 && !(mask & (1 << lane))) stamp(lane, 0);
144
+ }
145
+ if (g.padLane >= 0) {
146
+ if (!(mask & (1 << g.padLane))) stamp(g.padLane, 0);
147
+ g.padLane = -1;
148
+ }
149
+ return mask;
150
+ }
151
+
152
+ /** Scratch for pressedLanes: each lane's press time within the tick. */
153
+ const within = [0, 0, 0];
154
+
155
+ /**
156
+ * The play. Each tick: the presses (the count-in's taps and a calibration's
157
+ * are measured, not judged), each pressed lane's nearest unjudged note
158
+ * within the Good window judged by its error, unhit notes past the window
159
+ * missed, the notes og.MusicBeat brings onto the highway, the highway
160
+ * drawn, and the song's end (cleared a beat after its last note, failed
161
+ * when the groove runs out).
162
+ */
163
+ export const Play = defineSystem(
164
+ "Play",
165
+ { reads: [og.Input, og.Gamepad, og.Pointers, og.KeyDown, og.PointerDown, og.Camera, og.Audio, og.MusicBeat, Tuning, Prefs], writes: [Game, Note], after: ["Clock"] },
166
+ (q, _time, world) => {
167
+ const game = world.resource(Game);
168
+ const input = world.resource(og.Input);
169
+ const gamepad = world.resource(og.Gamepad);
170
+ const pointers = world.resource(og.Pointers);
171
+ const prefs = world.resource(Prefs);
172
+ if (!game.ok || !input.ok || !gamepad.ok || !pointers.ok || !prefs.ok) return;
173
+ const g = game.value;
174
+ const t = lazyTuning(world);
175
+ const now = worldTime(world);
176
+ // What the player hears is the world's time less the output's latency (0 headless); the
177
+ // calibrated offset is the rest of the chain (the display, the hand).
178
+ const latency = og.audio.outputLatency(world);
179
+ const offset = prefs.value.offsetMs / 1000;
180
+ const live = g.phase === Phase.Play && !g.held && g.pausedAt < 0;
181
+ const calibrating = g.phase === Phase.Calibrate && !g.settingsOpen;
182
+ const mask = live || calibrating ? pressedLanes(world, g, input.value, gamepad.value, pointers.value, within) : 0;
183
+ const tickLength = 1 / 60;
184
+ if (mask !== g.pressMask) g.pressMask = mask;
185
+ if (mask !== 0) {
186
+ g.taps += 1;
187
+ for (let lane = 0; lane < LANES; lane++) if (mask & (1 << lane)) g.sfx |= Sound.Tap0 << lane;
188
+ }
189
+ // Calibration: each tap's error from the nearest click (every beat of the clock).
190
+ if (calibrating && mask !== 0 && g.calTaps < 8 && now > g.songStart) {
191
+ const len = beatLength(g);
192
+ let first = 0;
193
+ while (!(mask & (1 << first))) first++;
194
+ // The tap when it happened, against the click when it was heard.
195
+ const b = (now + within[first]! * tickLength - latency - g.songStart) / len;
196
+ const err = (b - Math.round(b)) * len * 1000;
197
+ g.calTaps += 1;
198
+ g.calSum += err;
199
+ }
200
+ // The notes og.MusicBeat brings: every note up to scrollBeats past the beat just sent, and one more
201
+ // (a start or a resume asks for the first ones through Game.scheduleUpTo).
202
+ let upTo = g.scheduleUpTo;
203
+ if (g.phase === Phase.Play && g.pausedAt < 0) {
204
+ for (const e of world.events(og.MusicBeat)) upTo = Math.max(upTo, (e.bar - 1) * 4 + (e.beat - 1) + 1 + t.scrollBeats);
205
+ }
206
+ if (g.scheduleUpTo !== -1) g.scheduleUpTo = -1;
207
+ const at = songNow(world, g) - offset - latency;
208
+ const len = beatLength(g);
209
+ const window = t.goodMs / 1000;
210
+ let hitMask = 0;
211
+ let judgedNow = 0;
212
+ for (const a of q.archetypes()) {
213
+ const n = a.column(Note);
214
+ const count = a.count;
215
+ if (g.resetNotes) {
216
+ n.live.fill(0);
217
+ n.errorMs.fill(0);
218
+ let playing = 0;
219
+ for (let i = 0; i < count; i++) {
220
+ const skip = n.beat[i]! < g.fromBeat;
221
+ n.judged[i] = skip ? 5 : 0;
222
+ if (!skip) playing += 1;
223
+ }
224
+ g.notes = playing;
225
+ }
226
+ if (g.phase !== Phase.Play) continue;
227
+ // Scheduling: notes up to `upTo` beats come onto the highway (og.MusicBeat, or a start's first ones).
228
+ if (upTo >= 0) {
229
+ for (let i = 0; i < count; i++) {
230
+ if (!n.live[i] && !n.judged[i] && n.beat[i]! <= upTo) {
231
+ n.live[i] = 1;
232
+ g.scheduled += 1;
233
+ }
234
+ }
235
+ }
236
+ // Judging each pressed lane: its nearest unjudged note within the Good window.
237
+ if (live) {
238
+ for (let lane = 0; lane < LANES; lane++) {
239
+ if (!(mask & (1 << lane))) continue;
240
+ // The press when it happened within the tick, not the tick's start.
241
+ const pressed = at + within[lane]! * tickLength;
242
+ let best = -1;
243
+ let bestErr = Infinity;
244
+ for (let i = 0; i < count; i++) {
245
+ if (!n.live[i] || n.judged[i] || n.lane[i] !== lane) continue;
246
+ const err = pressed - (g.songStart + n.beat[i]! * len);
247
+ if (Math.abs(err) <= window && Math.abs(err) < Math.abs(bestErr)) {
248
+ best = i;
249
+ bestErr = err;
250
+ }
251
+ }
252
+ if (best < 0) continue;
253
+ const ms = bestErr * 1000;
254
+ const j = Math.abs(ms) <= t.perfectMs ? Judgement.Perfect : Math.abs(ms) <= t.greatMs ? Judgement.Great : Judgement.Good;
255
+ n.judged[best] = j + 1;
256
+ n.live[best] = 0;
257
+ n.errorMs[best] = ms;
258
+ judge(world, g, t, j, lane, ms);
259
+ hitMask |= 1 << lane;
260
+ judgedNow += 1;
261
+ }
262
+ // Misses: unjudged notes past the Good window.
263
+ for (let i = 0; i < count; i++) {
264
+ if (!n.live[i] || n.judged[i]) continue;
265
+ if (at - (g.songStart + n.beat[i]! * len) > window) {
266
+ n.judged[i] = Judgement.Miss + 1;
267
+ n.live[i] = 0;
268
+ judge(world, g, t, Judgement.Miss, n.lane[i]!, 0);
269
+ judgedNow += 1;
270
+ }
271
+ }
272
+ }
273
+ // The highway: live notes fall to the hit line, missed ones fall on, dimmed, and fade.
274
+ const speed = (g.topY - g.hitY) / (t.scrollBeats * len);
275
+ for (let i = 0; i < count; i++) {
276
+ const missed = n.judged[i] === Judgement.Miss + 1;
277
+ if (!n.live[i] && !missed) continue;
278
+ const dt = g.songStart + n.beat[i]! * len - at;
279
+ const y = g.hitY + dt * speed;
280
+ if (y > g.topY + 0.4 || y < g.hitY - 3) continue;
281
+ const lane = n.lane[i]!;
282
+ const c = LANE_COLOURS[lane]!;
283
+ must(og.render.sprite(world, { texture: g.noteTexture as unknown as never, position: { x: (lane - 1) * g.laneW, y, z: 0 }, width: g.laneW * 0.86, height: g.laneW * 0.36, color: missed ? { r: 0.45, g: 0.45, b: 0.5 } : c, opacity: missed ? Math.max(0, 0.5 + dt) : 1, layer: 6 }));
284
+ }
285
+ }
286
+ if (g.resetNotes) g.resetNotes = false;
287
+ if (hitMask !== g.hitMask) g.hitMask = hitMask;
288
+ if (g.phase !== Phase.Play || g.pausedAt >= 0) return;
289
+ // The count-in: its numbers over the middle lane.
290
+ if (now < g.countTo) {
291
+ const left = Math.ceil((g.countTo - now) / len - 1e-6);
292
+ if (left !== g.countShown && left >= 1 && left <= 4) {
293
+ g.countShown = left;
294
+ must(og.render.floatingText(world, { text: `${left}`, position: { x: 0, y: g.hitY + 3.2, z: 0 }, size: 0.9, color: { r: 0.85, g: 0.95, b: 1 }, rise: 0.3, lifetime: len * 0.9 }));
295
+ }
296
+ }
297
+ // The end: a beat after the last note is judged, or soon after the groove runs out.
298
+ if (judgedNow > 0 && g.judged >= g.notes && g.endAt === 0 && !g.failed) {
299
+ g.cleared = true;
300
+ g.endAt = now + 1.5;
301
+ g.sfx |= Sound.Clear;
302
+ }
303
+ if (g.endAt > 0 && now >= g.endAt && !g.over) g.over = true;
304
+ },
305
+ );
306
+
307
+ function judge(world: World, g: GameV, t: TuneV, j: number, lane: number, ms: number): void {
308
+ g.judged += 1;
309
+ g.lastJudgement = j;
310
+ g.lastLane = lane;
311
+ const x = (lane - 1) * g.laneW;
312
+ const y = g.hitY + 0.9;
313
+ if (j === Judgement.Miss) {
314
+ g.miss += 1;
315
+ if (g.combo >= 10) g.sfx |= Sound.Break;
316
+ else g.sfx |= Sound.Miss;
317
+ g.combo = 0;
318
+ // (f32 steps: what is left under a thousandth is empty.)
319
+ const left = g.groove - t.grooveLoss;
320
+ g.groove = left < 1e-3 ? 0 : left;
321
+ must(og.render.floatingText(world, { text: say(world, "judge.miss"), position: { x, y, z: 0 }, size: 0.42, color: JUDGE_COLOURS[3]!, rise: 0.6, lifetime: 0.6 }));
322
+ must(og.camera.shake(world, 0.18 * feel(world)));
323
+ if (g.groove <= 0 && !g.failed) {
324
+ g.failed = true;
325
+ g.endAt = worldTime(world) + 1.2;
326
+ g.sfx |= Sound.Fail;
327
+ g.stopBand = true;
328
+ }
329
+ return;
330
+ }
331
+ g.hits += 1;
332
+ g.combo += 1;
333
+ g.maxCombo = Math.max(g.maxCombo, g.combo);
334
+ const multiplier = Math.min(4, 1 + Math.floor(g.combo / t.comboStep));
335
+ const points = j === Judgement.Perfect ? t.perfectPoints : j === Judgement.Great ? t.greatPoints : t.goodPoints;
336
+ g.score += points * multiplier;
337
+ if (j === Judgement.Perfect) g.perfect += 1;
338
+ else if (j === Judgement.Great) g.great += 1;
339
+ else g.good += 1;
340
+ g.groove = Math.min(1, g.groove + t.grooveGain * (j === Judgement.Perfect ? 1 : j === Judgement.Great ? 0.7 : 0.4));
341
+ g.lastOffsetMs = ms;
342
+ const word = say(world, `judge.${JUDGEMENTS[j]}`);
343
+ must(og.render.floatingText(world, { text: word, position: { x, y, z: 0 }, size: j === Judgement.Perfect ? 0.46 : 0.4, color: JUDGE_COLOURS[j]!, rise: 0.7, lifetime: 0.55 }));
344
+ if (j !== Judgement.Perfect) {
345
+ must(og.render.floatingText(world, { text: say(world, ms < 0 ? "judge.early" : "judge.late"), position: { x, y: y - 0.45, z: 0 }, size: 0.26, color: { r: 0.75, g: 0.85, b: 0.95 }, rise: 0.4, lifetime: 0.45 }));
346
+ }
347
+ // A combo of every comboStep raises the multiplier: a punch on the beat.
348
+ const k = feel(world);
349
+ if (g.combo % t.comboStep === 0 && g.combo <= t.comboStep * 3) must(og.camera.punch(world, 0.03 * k));
350
+ must(og.camera.kick(world, { x: 0, y: -1, z: 0 }, 0.04 * k));
351
+ }
352
+
353
+ /** The song's og.Music clock follows Game.songStart and Song's tempo (the Ui and the commands move it). */
354
+ export const Clock = defineSystem("Clock", { reads: [Game], writes: [og.Music], after: ["Ui"] }, (q, _time, world) => {
355
+ const game = world.resource(Game);
356
+ if (!game.ok) return;
357
+ const g = game.value;
358
+ for (const a of q.archetypes()) {
359
+ const m = a.column(og.Music);
360
+ for (let i = 0; i < a.count; i++) {
361
+ if (m.start[i] !== g.songStart) m.start[i] = g.songStart;
362
+ if (m.bpm[i] !== g.bpm) m.bpm[i] = g.bpm;
363
+ }
364
+ }
365
+ });
366
+
367
+ /**
368
+ * The band: on the last beat of each bar og.MusicBeat brings, the stems of
369
+ * the next bar start on its bar line (startAt, to the sample); a start or a
370
+ * resume asks for the count-in's four clicks and the stems sounding at the
371
+ * beat it starts on, each from where it would be (startOffset); a
372
+ * calibration clicks every beat; a pause, a fail or the title stops them.
373
+ */
374
+ export const Band = defineSystem("Band", { reads: [og.MusicBeat, Tuning], writes: [Game, Stem, og.AudioSource], after: ["Play"] }, (q, _time, world) => {
375
+ const game = world.resource(Game);
376
+ if (!game.ok) return;
377
+ const g = game.value;
378
+ const len = beatLength(g);
379
+ // A stop goes first, alone: a start asked for in the same tick waits a tick (a source stopped
380
+ // and started in one tick would not restart).
381
+ if (g.stopBand) {
382
+ g.stopBand = false;
383
+ for (const a of q.archetypes()) a.column(og.AudioSource).playing.fill(0);
384
+ return;
385
+ }
386
+ // Each stem to start: when (world time) and how far into it (seconds).
387
+ const starts = new Map<string, { at: number; offset: number }>();
388
+ if (g.bandFrom > 0) {
389
+ // A start or a resume: the count-in's clicks, then the stems sounding at Game.bandBeat, each
390
+ // from where it would be by then: a bar's own from its bar line, a two-bar one from the
391
+ // odd bar before.
392
+ const clicks = Math.min(4, lazyTuning(world).countInBeats);
393
+ for (let k = 4 - clicks; k < 4; k++) starts.set(`click${k}`, { at: g.countTo - (4 - k) * len, offset: 0 });
394
+ const bar = g.bandFrom;
395
+ if (bar % 2 === 0) {
396
+ for (const p of partsAt(bar - 1, g.bars)) if (p !== "drums") starts.set(p, { at: g.countTo, offset: (g.bandBeat - (bar - 2) * 4) * len });
397
+ }
398
+ for (const p of partsAt(bar, g.bars)) starts.set(p, { at: g.countTo, offset: (g.bandBeat - (bar - 1) * 4) * len });
399
+ g.nextBar = bar + 1;
400
+ g.bandFrom = 0;
401
+ }
402
+ for (const e of world.events(og.MusicBeat)) {
403
+ if (g.phase === Phase.Calibrate) {
404
+ starts.set(`click${e.beat % 4}`, { at: e.time + len, offset: 0 });
405
+ } else if (g.phase === Phase.Play && g.pausedAt < 0 && e.beat === 4 && e.bar + 1 === g.nextBar) {
406
+ for (const p of partsAt(g.nextBar, g.bars)) starts.set(p, { at: e.time + len, offset: 0 });
407
+ g.nextBar += 1;
408
+ }
409
+ }
410
+ if (starts.size === 0) return;
411
+ for (const a of q.archetypes()) {
412
+ const stem = a.column(Stem);
413
+ const src = a.column(og.AudioSource);
414
+ for (let i = 0; i < a.count; i++) {
415
+ const part = PARTS[stem.part[i]!]!;
416
+ const start = starts.get(part);
417
+ if (start === undefined) continue;
418
+ src.startAt[i] = start.at;
419
+ src.startOffset[i] = start.offset;
420
+ src.playing[i] = 1;
421
+ stem.starts[i] = stem.starts[i]! + 1;
422
+ }
423
+ }
424
+ });
425
+
426
+ /** The receptors: a press squashes its lane's, a hit flashes it in the lane's colour and bursts sparks; the lanes glow on each beat. */
427
+ export const Lanes = defineSystem("Lanes", { reads: [Game, og.MusicBeat, Prefs], writes: [Receptor, og.Transform, og.Sprite, og.ParticleSystem], after: ["Band"] }, (q, _time, world) => {
428
+ const game = world.resource(Game);
429
+ if (!game.ok) return;
430
+ const g = game.value;
431
+ let beat = false;
432
+ for (const _ of world.events(og.MusicBeat)) beat = true;
433
+ const calm = (() => {
434
+ const p = world.resource(Prefs);
435
+ return p.ok && p.value.reducedMotion;
436
+ })();
437
+ for (const a of q.archetypes()) {
438
+ const r = a.column(Receptor);
439
+ const p = a.column(og.Transform).position;
440
+ const sprite = a.column(og.Sprite);
441
+ const fx = a.column(og.ParticleSystem);
442
+ for (let i = 0; i < a.count; i++) {
443
+ const lane = r.lane[i]!;
444
+ const me = a.entity(i);
445
+ p[i * 3] = (lane - 1) * g.laneW;
446
+ p[i * 3 + 1] = g.hitY;
447
+ const shown = g.phase === Phase.Play || g.phase === Phase.Calibrate ? 1 : 0;
448
+ if (sprite.visible[i] !== shown) sprite.visible[i] = shown;
449
+ if (g.pressMask & (1 << lane)) {
450
+ r.presses[i] = r.presses[i]! + 1;
451
+ must(og.tween.squash(world, { entity: me, impact: { x: 1.12, y: 0.82 }, duration: 0.12 }));
452
+ }
453
+ if (g.hitMask & (1 << lane)) {
454
+ must(og.tween.flash(world, { entity: me, color: LANE_COLOURS[lane]!, duration: 0.12 }));
455
+ fx.visible[i] = 1;
456
+ fx.startTick[i] = world.tick;
457
+ }
458
+ // The ring breathes with the beat (not with reduced motion).
459
+ const o = sprite.opacity[i]!;
460
+ const target = beat && !calm ? 1 : Math.max(0.55, o * 0.94);
461
+ if (Math.abs(target - o) > 1e-3) sprite.opacity[i] = target;
462
+ }
463
+ }
464
+ });
465
+
466
+ /** Plays each requested sound once: a voice already playing is stopped this tick and restarted the next. */
467
+ export const Voices = defineSystem("Voices", { writes: [Game, Sfx, og.AudioSource], after: ["Lanes"] }, (q, _time, world) => {
468
+ const game = world.resource(Game);
469
+ if (!game.ok) return;
470
+ const g = game.value;
471
+ if (g.sfx === 0) return;
472
+ let left = g.sfx;
473
+ for (const a of q.archetypes()) {
474
+ const sfx = a.column(Sfx);
475
+ const src = a.column(og.AudioSource);
476
+ for (let i = 0; i < a.count; i++) {
477
+ const b = sfx.bit[i]!;
478
+ if ((g.sfx & b) === 0) continue;
479
+ if (src.playing[i]) {
480
+ src.playing[i] = 0;
481
+ } else {
482
+ src.playing[i] = 1;
483
+ src.startAt[i] = 0;
484
+ sfx.plays[i] = sfx.plays[i]! + 1;
485
+ left &= ~b;
486
+ }
487
+ }
488
+ }
489
+ g.sfx = left;
490
+ });