@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.
Files changed (581) 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/host.d.ts +46 -0
  56. package/archetypes/idle/package.json +18 -0
  57. package/archetypes/idle/project.ogt +14 -0
  58. package/archetypes/idle/references/metal/card.png +0 -0
  59. package/archetypes/idle/references/metal/orbit.png +0 -0
  60. package/archetypes/idle/references/metal/title.png +0 -0
  61. package/archetypes/idle/src/components.ts +139 -0
  62. package/archetypes/idle/src/main.ts +247 -0
  63. package/archetypes/idle/src/numbers.ts +126 -0
  64. package/archetypes/idle/src/systems.ts +340 -0
  65. package/archetypes/idle/src/ui.ts +412 -0
  66. package/archetypes/idle/tests/away.og.ts +42 -0
  67. package/archetypes/idle/tests/flow.og.ts +57 -0
  68. package/archetypes/idle/tests/frames.og.ts +33 -0
  69. package/archetypes/idle/tests/frames.ts +134 -0
  70. package/archetypes/idle/tests/lib.ts +74 -0
  71. package/archetypes/idle/tests/milestone.og.ts +32 -0
  72. package/archetypes/idle/tests/nova.og.ts +52 -0
  73. package/archetypes/idle/tests/offline.og.ts +60 -0
  74. package/archetypes/idle/tests/pad.og.ts +55 -0
  75. package/archetypes/idle/tests/pause.og.ts +68 -0
  76. package/archetypes/idle/tests/phone.og.ts +50 -0
  77. package/archetypes/idle/tests/replay.og.ts +28 -0
  78. package/archetypes/idle/tools/make-assets.py +448 -0
  79. package/archetypes/idle/tools/oglite.py +285 -0
  80. package/archetypes/idle/tsconfig.json +17 -0
  81. package/archetypes/match3/.origin/setup +14 -0
  82. package/archetypes/match3/LICENSES.md +7 -0
  83. package/archetypes/match3/README.md +205 -0
  84. package/archetypes/match3/assets/audio/cascade.wav +0 -0
  85. package/archetypes/match3/assets/audio/clear.wav +0 -0
  86. package/archetypes/match3/assets/audio/lost.wav +0 -0
  87. package/archetypes/match3/assets/audio/refused.wav +0 -0
  88. package/archetypes/match3/assets/audio/select.wav +0 -0
  89. package/archetypes/match3/assets/audio/swap.wav +0 -0
  90. package/archetypes/match3/assets/audio/won.wav +0 -0
  91. package/archetypes/match3/assets/fonts/OFL.txt +93 -0
  92. package/archetypes/match3/assets/fonts/ui.ttf +0 -0
  93. package/archetypes/match3/assets/fonts/ui.ttf.ogt +11 -0
  94. package/archetypes/match3/assets/scenes/main.ogt +24 -0
  95. package/archetypes/match3/assets/sprites/backdrop.png +0 -0
  96. package/archetypes/match3/assets/sprites/board.ogt +21 -0
  97. package/archetypes/match3/assets/sprites/cells.ogt +7 -0
  98. package/archetypes/match3/assets/sprites/cells.png +0 -0
  99. package/archetypes/match3/assets/sprites/cells.png.ogt +7 -0
  100. package/archetypes/match3/assets/sprites/gems.ogt +75 -0
  101. package/archetypes/match3/assets/sprites/gems.png +0 -0
  102. package/archetypes/match3/assets/sprites/panel.png +0 -0
  103. package/archetypes/match3/assets/sprites/ring.png +0 -0
  104. package/archetypes/match3/gitattributes +22 -0
  105. package/archetypes/match3/host.d.ts +46 -0
  106. package/archetypes/match3/package.json +18 -0
  107. package/archetypes/match3/project.ogt +18 -0
  108. package/archetypes/match3/references/metal/cascade.png +0 -0
  109. package/archetypes/match3/references/metal/clearing.png +0 -0
  110. package/archetypes/match3/references/metal/dealt.png +0 -0
  111. package/archetypes/match3/src/art.ts +54 -0
  112. package/archetypes/match3/src/board.ts +112 -0
  113. package/archetypes/match3/src/components.ts +95 -0
  114. package/archetypes/match3/src/layout.ts +25 -0
  115. package/archetypes/match3/src/main.ts +199 -0
  116. package/archetypes/match3/src/systems.ts +631 -0
  117. package/archetypes/match3/tests/drag.og.ts +31 -0
  118. package/archetypes/match3/tests/endings.og.ts +40 -0
  119. package/archetypes/match3/tests/frames.og.ts +49 -0
  120. package/archetypes/match3/tests/frames.ts +134 -0
  121. package/archetypes/match3/tests/hidpi.og.ts +41 -0
  122. package/archetypes/match3/tests/lib.ts +64 -0
  123. package/archetypes/match3/tests/replay.og.ts +28 -0
  124. package/archetypes/match3/tests/sounds.og.ts +50 -0
  125. package/archetypes/match3/tests/swap.og.ts +67 -0
  126. package/archetypes/match3/tools/make-assets.py +404 -0
  127. package/archetypes/match3/tools/oglite.py +285 -0
  128. package/archetypes/match3/tsconfig.json +17 -0
  129. package/archetypes/rhythm/.origin/setup +14 -0
  130. package/archetypes/rhythm/LICENSES.md +13 -0
  131. package/archetypes/rhythm/README.md +235 -0
  132. package/archetypes/rhythm/assets/audio/bass0.wav +0 -0
  133. package/archetypes/rhythm/assets/audio/bass1.wav +0 -0
  134. package/archetypes/rhythm/assets/audio/bass2.wav +0 -0
  135. package/archetypes/rhythm/assets/audio/bass3.wav +0 -0
  136. package/archetypes/rhythm/assets/audio/chords0.wav +0 -0
  137. package/archetypes/rhythm/assets/audio/chords1.wav +0 -0
  138. package/archetypes/rhythm/assets/audio/chords2.wav +0 -0
  139. package/archetypes/rhythm/assets/audio/chords3.wav +0 -0
  140. package/archetypes/rhythm/assets/audio/clear.wav +0 -0
  141. package/archetypes/rhythm/assets/audio/click.wav +0 -0
  142. package/archetypes/rhythm/assets/audio/drums.wav +0 -0
  143. package/archetypes/rhythm/assets/audio/fail.wav +0 -0
  144. package/archetypes/rhythm/assets/audio/leadA.wav +0 -0
  145. package/archetypes/rhythm/assets/audio/leadB.wav +0 -0
  146. package/archetypes/rhythm/assets/audio/miss.wav +0 -0
  147. package/archetypes/rhythm/assets/audio/tap0.wav +0 -0
  148. package/archetypes/rhythm/assets/audio/tap1.wav +0 -0
  149. package/archetypes/rhythm/assets/audio/tap2.wav +0 -0
  150. package/archetypes/rhythm/assets/audio/ui-close.ogt +9 -0
  151. package/archetypes/rhythm/assets/audio/ui-error.ogt +9 -0
  152. package/archetypes/rhythm/assets/audio/ui-open.ogt +9 -0
  153. package/archetypes/rhythm/assets/audio/ui-press.ogt +9 -0
  154. package/archetypes/rhythm/assets/audio/ui-success.ogt +9 -0
  155. package/archetypes/rhythm/assets/charts/neon-pulse.ogt +919 -0
  156. package/archetypes/rhythm/assets/fonts/NotoSansSC-subset.ttf +0 -0
  157. package/archetypes/rhythm/assets/fonts/NotoSansSC-subset.ttf.ogt +10 -0
  158. package/archetypes/rhythm/assets/fonts/OFL.txt +93 -0
  159. package/archetypes/rhythm/assets/fx/hit.ogt +22 -0
  160. package/archetypes/rhythm/assets/skins/lanebeat/ChakraPetch-Medium.ttf +0 -0
  161. package/archetypes/rhythm/assets/skins/lanebeat/ChakraPetch-Medium.ttf.ogt +9 -0
  162. package/archetypes/rhythm/assets/skins/lanebeat/JetBrainsMono-Regular.ttf +0 -0
  163. package/archetypes/rhythm/assets/skins/lanebeat/JetBrainsMono-Regular.ttf.ogt +9 -0
  164. package/archetypes/rhythm/assets/skins/lanebeat/LICENSES.md +17 -0
  165. package/archetypes/rhythm/assets/skins/lanebeat/OFL.txt +95 -0
  166. package/archetypes/rhythm/assets/skins/lanebeat/Orbitron-Bold.ttf +0 -0
  167. package/archetypes/rhythm/assets/skins/lanebeat/Orbitron-Bold.ttf.ogt +9 -0
  168. package/archetypes/rhythm/assets/skins/lanebeat/atlas.png +0 -0
  169. package/archetypes/rhythm/assets/skins/lanebeat/atlas.png.ogt +7 -0
  170. package/archetypes/rhythm/assets/skins/lanebeat/icons.png +0 -0
  171. package/archetypes/rhythm/assets/skins/lanebeat/icons.png.ogt +7 -0
  172. package/archetypes/rhythm/assets/skins/lanebeat/skin.ogt +110 -0
  173. package/archetypes/rhythm/assets/sprites/lane.png +0 -0
  174. package/archetypes/rhythm/assets/sprites/lane.png.ogt +7 -0
  175. package/archetypes/rhythm/assets/sprites/note.png +0 -0
  176. package/archetypes/rhythm/assets/sprites/note.png.ogt +7 -0
  177. package/archetypes/rhythm/assets/sprites/ring.png +0 -0
  178. package/archetypes/rhythm/assets/sprites/ring.png.ogt +7 -0
  179. package/archetypes/rhythm/assets/sprites/spark.png +0 -0
  180. package/archetypes/rhythm/assets/sprites/spark.png.ogt +7 -0
  181. package/archetypes/rhythm/assets/strings/en.ogt +61 -0
  182. package/archetypes/rhythm/assets/strings/zh-CN.ogt +61 -0
  183. package/archetypes/rhythm/gitattributes +22 -0
  184. package/archetypes/rhythm/host.d.ts +46 -0
  185. package/archetypes/rhythm/package.json +18 -0
  186. package/archetypes/rhythm/project.ogt +14 -0
  187. package/archetypes/rhythm/references/metal/highway.png +0 -0
  188. package/archetypes/rhythm/references/metal/results.png +0 -0
  189. package/archetypes/rhythm/references/metal/title.png +0 -0
  190. package/archetypes/rhythm/src/components.ts +147 -0
  191. package/archetypes/rhythm/src/main.ts +202 -0
  192. package/archetypes/rhythm/src/systems.ts +490 -0
  193. package/archetypes/rhythm/src/ui.ts +421 -0
  194. package/archetypes/rhythm/tests/band.og.ts +45 -0
  195. package/archetypes/rhythm/tests/calibrate.og.ts +49 -0
  196. package/archetypes/rhythm/tests/clear.og.ts +51 -0
  197. package/archetypes/rhythm/tests/fail.og.ts +40 -0
  198. package/archetypes/rhythm/tests/flow.og.ts +54 -0
  199. package/archetypes/rhythm/tests/frames.og.ts +35 -0
  200. package/archetypes/rhythm/tests/frames.ts +134 -0
  201. package/archetypes/rhythm/tests/lib.ts +123 -0
  202. package/archetypes/rhythm/tests/pad.og.ts +41 -0
  203. package/archetypes/rhythm/tests/pause.og.ts +77 -0
  204. package/archetypes/rhythm/tests/phone.og.ts +44 -0
  205. package/archetypes/rhythm/tests/replay.og.ts +27 -0
  206. package/archetypes/rhythm/tests/timing.og.ts +37 -0
  207. package/archetypes/rhythm/tools/make-assets.py +383 -0
  208. package/archetypes/rhythm/tools/oglite.py +285 -0
  209. package/archetypes/rhythm/tsconfig.json +17 -0
  210. package/archetypes/roguelike/.origin/setup +14 -0
  211. package/archetypes/roguelike/LICENSES.md +14 -0
  212. package/archetypes/roguelike/README.md +256 -0
  213. package/archetypes/roguelike/assets/ai/foe.ogt +28 -0
  214. package/archetypes/roguelike/assets/ai/guardian.ogt +26 -0
  215. package/archetypes/roguelike/assets/audio/bump.wav +0 -0
  216. package/archetypes/roguelike/assets/audio/drink.wav +0 -0
  217. package/archetypes/roguelike/assets/audio/fall.wav +0 -0
  218. package/archetypes/roguelike/assets/audio/hit.wav +0 -0
  219. package/archetypes/roguelike/assets/audio/hurt.wav +0 -0
  220. package/archetypes/roguelike/assets/audio/item.wav +0 -0
  221. package/archetypes/roguelike/assets/audio/kill.wav +0 -0
  222. package/archetypes/roguelike/assets/audio/pickup.wav +0 -0
  223. package/archetypes/roguelike/assets/audio/roar.wav +0 -0
  224. package/archetypes/roguelike/assets/audio/stairs.wav +0 -0
  225. package/archetypes/roguelike/assets/audio/step.ogt +9 -0
  226. package/archetypes/roguelike/assets/audio/telegraph.wav +0 -0
  227. package/archetypes/roguelike/assets/audio/tomb.wav +0 -0
  228. package/archetypes/roguelike/assets/audio/ui-close.ogt +9 -0
  229. package/archetypes/roguelike/assets/audio/ui-error.ogt +9 -0
  230. package/archetypes/roguelike/assets/audio/ui-open.ogt +9 -0
  231. package/archetypes/roguelike/assets/audio/ui-press.ogt +9 -0
  232. package/archetypes/roguelike/assets/audio/ui-success.ogt +9 -0
  233. package/archetypes/roguelike/assets/audio/won.wav +0 -0
  234. package/archetypes/roguelike/assets/fonts/NotoSansSC-subset.ttf +0 -0
  235. package/archetypes/roguelike/assets/fonts/NotoSansSC-subset.ttf.ogt +10 -0
  236. package/archetypes/roguelike/assets/fonts/OFL.txt +93 -0
  237. package/archetypes/roguelike/assets/maps/dive.ogt +106 -0
  238. package/archetypes/roguelike/assets/skins/lampdive/DotGothic16-Regular.ttf +0 -0
  239. package/archetypes/roguelike/assets/skins/lampdive/DotGothic16-Regular.ttf.ogt +9 -0
  240. package/archetypes/roguelike/assets/skins/lampdive/LICENSES.md +16 -0
  241. package/archetypes/roguelike/assets/skins/lampdive/OFL.txt +93 -0
  242. package/archetypes/roguelike/assets/skins/lampdive/atlas.png +0 -0
  243. package/archetypes/roguelike/assets/skins/lampdive/atlas.png.ogt +7 -0
  244. package/archetypes/roguelike/assets/skins/lampdive/icons.png +0 -0
  245. package/archetypes/roguelike/assets/skins/lampdive/icons.png.ogt +7 -0
  246. package/archetypes/roguelike/assets/skins/lampdive/skin.ogt +115 -0
  247. package/archetypes/roguelike/assets/sprites/dive.ogt +50 -0
  248. package/archetypes/roguelike/assets/sprites/dive.png +0 -0
  249. package/archetypes/roguelike/assets/sprites/dive.png.ogt +7 -0
  250. package/archetypes/roguelike/assets/sprites/glow.png +0 -0
  251. package/archetypes/roguelike/assets/sprites/glow.png.ogt +7 -0
  252. package/archetypes/roguelike/assets/strings/en.ogt +57 -0
  253. package/archetypes/roguelike/assets/strings/zh-CN.ogt +57 -0
  254. package/archetypes/roguelike/assets/tiles/tomb.ogt +31 -0
  255. package/archetypes/roguelike/assets/tiles/tomb.png +0 -0
  256. package/archetypes/roguelike/assets/tiles/tomb.png.ogt +7 -0
  257. package/archetypes/roguelike/gitattributes +22 -0
  258. package/archetypes/roguelike/host.d.ts +46 -0
  259. package/archetypes/roguelike/package.json +18 -0
  260. package/archetypes/roguelike/project.ogt +14 -0
  261. package/archetypes/roguelike/references/metal/dive.png +0 -0
  262. package/archetypes/roguelike/references/metal/over.png +0 -0
  263. package/archetypes/roguelike/references/metal/title.png +0 -0
  264. package/archetypes/roguelike/src/art.ts +23 -0
  265. package/archetypes/roguelike/src/components.ts +169 -0
  266. package/archetypes/roguelike/src/dive.ts +144 -0
  267. package/archetypes/roguelike/src/foes.ts +174 -0
  268. package/archetypes/roguelike/src/main.ts +258 -0
  269. package/archetypes/roguelike/src/systems.ts +620 -0
  270. package/archetypes/roguelike/src/ui.ts +350 -0
  271. package/archetypes/roguelike/tests/flow.og.ts +54 -0
  272. package/archetypes/roguelike/tests/foes.og.ts +45 -0
  273. package/archetypes/roguelike/tests/frames.og.ts +32 -0
  274. package/archetypes/roguelike/tests/frames.ts +134 -0
  275. package/archetypes/roguelike/tests/lib.ts +83 -0
  276. package/archetypes/roguelike/tests/lose.og.ts +44 -0
  277. package/archetypes/roguelike/tests/pad.og.ts +54 -0
  278. package/archetypes/roguelike/tests/pause.og.ts +59 -0
  279. package/archetypes/roguelike/tests/phone.og.ts +54 -0
  280. package/archetypes/roguelike/tests/replay.og.ts +24 -0
  281. package/archetypes/roguelike/tests/win.og.ts +60 -0
  282. package/archetypes/roguelike/tools/make-assets.py +518 -0
  283. package/archetypes/roguelike/tools/oglite.py +285 -0
  284. package/archetypes/roguelike/tsconfig.json +17 -0
  285. package/archetypes/runner/.origin/setup +14 -0
  286. package/archetypes/runner/LICENSES.md +10 -0
  287. package/archetypes/runner/README.md +225 -0
  288. package/archetypes/runner/assets/audio/coin.wav +0 -0
  289. package/archetypes/runner/assets/audio/crash.wav +0 -0
  290. package/archetypes/runner/assets/audio/hold.ogt +9 -0
  291. package/archetypes/runner/assets/audio/jump.wav +0 -0
  292. package/archetypes/runner/assets/audio/start.wav +0 -0
  293. package/archetypes/runner/assets/fonts/OFL.txt +93 -0
  294. package/archetypes/runner/assets/fonts/ui.ttf +0 -0
  295. package/archetypes/runner/assets/fonts/ui.ttf.ogt +11 -0
  296. package/archetypes/runner/assets/maps/far.ogt +25 -0
  297. package/archetypes/runner/assets/maps/near.ogt +25 -0
  298. package/archetypes/runner/assets/maps/roofs.ogt +19 -0
  299. package/archetypes/runner/assets/scenes/main.ogt +35 -0
  300. package/archetypes/runner/assets/sprites/coin.ogt +11 -0
  301. package/archetypes/runner/assets/sprites/coin.png +0 -0
  302. package/archetypes/runner/assets/sprites/coin.png.ogt +7 -0
  303. package/archetypes/runner/assets/sprites/courier.ogt +32 -0
  304. package/archetypes/runner/assets/sprites/courier.png +0 -0
  305. package/archetypes/runner/assets/sprites/courier.png.ogt +7 -0
  306. package/archetypes/runner/assets/sprites/props.ogt +21 -0
  307. package/archetypes/runner/assets/sprites/props.png +0 -0
  308. package/archetypes/runner/assets/sprites/props.png.ogt +7 -0
  309. package/archetypes/runner/assets/sprites/sky.png +0 -0
  310. package/archetypes/runner/assets/sprites/sky.png.ogt +7 -0
  311. package/archetypes/runner/assets/tiles/city.ogt +18 -0
  312. package/archetypes/runner/assets/tiles/city.png +0 -0
  313. package/archetypes/runner/assets/tiles/city.png.ogt +7 -0
  314. package/archetypes/runner/gitattributes +22 -0
  315. package/archetypes/runner/host.d.ts +46 -0
  316. package/archetypes/runner/package.json +18 -0
  317. package/archetypes/runner/project.ogt +18 -0
  318. package/archetypes/runner/references/metal/frames-coin.png +0 -0
  319. package/archetypes/runner/references/metal/frames-crash.png +0 -0
  320. package/archetypes/runner/references/metal/frames-title.png +0 -0
  321. package/archetypes/runner/src/art.ts +57 -0
  322. package/archetypes/runner/src/components.ts +94 -0
  323. package/archetypes/runner/src/main.ts +241 -0
  324. package/archetypes/runner/src/systems.ts +553 -0
  325. package/archetypes/runner/tests/coins.og.ts +30 -0
  326. package/archetypes/runner/tests/flow.og.ts +72 -0
  327. package/archetypes/runner/tests/frames.og.ts +37 -0
  328. package/archetypes/runner/tests/frames.ts +134 -0
  329. package/archetypes/runner/tests/jump.og.ts +44 -0
  330. package/archetypes/runner/tests/lib.ts +42 -0
  331. package/archetypes/runner/tests/records.og.ts +43 -0
  332. package/archetypes/runner/tests/replay.og.ts +36 -0
  333. package/archetypes/runner/tests/sounds.og.ts +43 -0
  334. package/archetypes/runner/tests/tune.og.ts +36 -0
  335. package/archetypes/runner/tools/make-assets.py +603 -0
  336. package/archetypes/runner/tools/oglite.py +285 -0
  337. package/archetypes/runner/tsconfig.json +17 -0
  338. package/archetypes/third-person/.origin/setup +14 -0
  339. package/archetypes/third-person/LICENSES.md +23 -0
  340. package/archetypes/third-person/README.md +249 -0
  341. package/archetypes/third-person/assets/ai/sentinel-east.ogt +69 -0
  342. package/archetypes/third-person/assets/ai/sentinel-north.ogt +69 -0
  343. package/archetypes/third-person/assets/ai/sentinel-west.ogt +69 -0
  344. package/archetypes/third-person/assets/anims/humanoid-clips.glb +0 -0
  345. package/archetypes/third-person/assets/audio/alarm.wav +0 -0
  346. package/archetypes/third-person/assets/audio/dawn.wav +0 -0
  347. package/archetypes/third-person/assets/audio/grab.wav +0 -0
  348. package/archetypes/third-person/assets/audio/ignite.wav +0 -0
  349. package/archetypes/third-person/assets/audio/jump.wav +0 -0
  350. package/archetypes/third-person/assets/audio/night.wav +0 -0
  351. package/archetypes/third-person/assets/audio/splash.wav +0 -0
  352. package/archetypes/third-person/assets/audio/step.ogt +9 -0
  353. package/archetypes/third-person/assets/audio/ui-close.ogt +9 -0
  354. package/archetypes/third-person/assets/audio/ui-error.ogt +9 -0
  355. package/archetypes/third-person/assets/audio/ui-open.ogt +9 -0
  356. package/archetypes/third-person/assets/audio/ui-press.ogt +9 -0
  357. package/archetypes/third-person/assets/audio/ui-success.ogt +9 -0
  358. package/archetypes/third-person/assets/audio/vale.wav +0 -0
  359. package/archetypes/third-person/assets/fonts/NotoSansSC-subset.ttf +0 -0
  360. package/archetypes/third-person/assets/fonts/NotoSansSC-subset.ttf.ogt +10 -0
  361. package/archetypes/third-person/assets/fonts/OFL.txt +93 -0
  362. package/archetypes/third-person/assets/fx/burst.ogt +25 -0
  363. package/archetypes/third-person/assets/fx/fire.ogt +24 -0
  364. package/archetypes/third-person/assets/fx/smoke.ogt +24 -0
  365. package/archetypes/third-person/assets/fx/splash.ogt +24 -0
  366. package/archetypes/third-person/assets/luts/teal-orange.cube +4917 -0
  367. package/archetypes/third-person/assets/models/stout.glb +0 -0
  368. package/archetypes/third-person/assets/models/strider.glb +0 -0
  369. package/archetypes/third-person/assets/models/strider.glb.ogt +9 -0
  370. package/archetypes/third-person/assets/nav/vale.ogt +43 -0
  371. package/archetypes/third-person/assets/rigs/strider.ogt +6 -0
  372. package/archetypes/third-person/assets/skins/ember/Cinzel-Bold.ttf +0 -0
  373. package/archetypes/third-person/assets/skins/ember/Cinzel-Bold.ttf.ogt +9 -0
  374. package/archetypes/third-person/assets/skins/ember/LICENSES.md +13 -0
  375. package/archetypes/third-person/assets/skins/ember/Newsreader-Medium.ttf +0 -0
  376. package/archetypes/third-person/assets/skins/ember/Newsreader-Medium.ttf.ogt +9 -0
  377. package/archetypes/third-person/assets/skins/ember/OFL.txt +94 -0
  378. package/archetypes/third-person/assets/skins/ember/atlas.png +0 -0
  379. package/archetypes/third-person/assets/skins/ember/atlas.png.ogt +7 -0
  380. package/archetypes/third-person/assets/skins/ember/icons.png +0 -0
  381. package/archetypes/third-person/assets/skins/ember/icons.png.ogt +7 -0
  382. package/archetypes/third-person/assets/skins/ember/skin.ogt +109 -0
  383. package/archetypes/third-person/assets/strings/en.ogt +47 -0
  384. package/archetypes/third-person/assets/strings/zh-CN.ogt +47 -0
  385. package/archetypes/third-person/assets/terrain/vale-control.png +0 -0
  386. package/archetypes/third-person/assets/terrain/vale.ogt +42 -0
  387. package/archetypes/third-person/assets/terrain/vale.png +0 -0
  388. package/archetypes/third-person/assets/textures/decals.png +0 -0
  389. package/archetypes/third-person/assets/textures/flame.png +0 -0
  390. package/archetypes/third-person/assets/textures/smoke.png +0 -0
  391. package/archetypes/third-person/assets/textures/spark.png +0 -0
  392. package/archetypes/third-person/assets/textures/terrain-grass.png +0 -0
  393. package/archetypes/third-person/assets/textures/terrain-path.png +0 -0
  394. package/archetypes/third-person/assets/textures/terrain-rock.png +0 -0
  395. package/archetypes/third-person/assets/textures/terrain-sand.png +0 -0
  396. package/archetypes/third-person/gitattributes +22 -0
  397. package/archetypes/third-person/host.d.ts +46 -0
  398. package/archetypes/third-person/package.json +18 -0
  399. package/archetypes/third-person/project.ogt +14 -0
  400. package/archetypes/third-person/references/metal/beacon.png +0 -0
  401. package/archetypes/third-person/references/metal/dawn.png +0 -0
  402. package/archetypes/third-person/references/metal/title.png +0 -0
  403. package/archetypes/third-person/references/webgl2/beacon.png +0 -0
  404. package/archetypes/third-person/src/anim.ts +87 -0
  405. package/archetypes/third-person/src/beacons.ts +80 -0
  406. package/archetypes/third-person/src/components.ts +148 -0
  407. package/archetypes/third-person/src/hero.ts +293 -0
  408. package/archetypes/third-person/src/main.ts +164 -0
  409. package/archetypes/third-person/src/sentinels.ts +159 -0
  410. package/archetypes/third-person/src/sound.ts +66 -0
  411. package/archetypes/third-person/src/ui.ts +451 -0
  412. package/archetypes/third-person/src/world.ts +212 -0
  413. package/archetypes/third-person/tests/flow.og.ts +70 -0
  414. package/archetypes/third-person/tests/frames.og.ts +35 -0
  415. package/archetypes/third-person/tests/frames.ts +134 -0
  416. package/archetypes/third-person/tests/hitstop.og.ts +26 -0
  417. package/archetypes/third-person/tests/lib.ts +87 -0
  418. package/archetypes/third-person/tests/lose.og.ts +44 -0
  419. package/archetypes/third-person/tests/pause.og.ts +64 -0
  420. package/archetypes/third-person/tests/phone.og.ts +65 -0
  421. package/archetypes/third-person/tests/replay.og.ts +32 -0
  422. package/archetypes/third-person/tests/restart.og.ts +28 -0
  423. package/archetypes/third-person/tests/sentinels.og.ts +48 -0
  424. package/archetypes/third-person/tests/win.og.ts +62 -0
  425. package/archetypes/third-person/tools/make-assets.py +353 -0
  426. package/archetypes/third-person/tools/oglite.py +285 -0
  427. package/archetypes/third-person/tsconfig.json +17 -0
  428. package/archetypes/topdown/.origin/setup +14 -0
  429. package/archetypes/topdown/LICENSES.md +10 -0
  430. package/archetypes/topdown/README.md +235 -0
  431. package/archetypes/topdown/assets/ai/slime.ogt +49 -0
  432. package/archetypes/topdown/assets/audio/coin.wav +0 -0
  433. package/archetypes/topdown/assets/audio/door.wav +0 -0
  434. package/archetypes/topdown/assets/audio/hit.wav +0 -0
  435. package/archetypes/topdown/assets/audio/hurt.wav +0 -0
  436. package/archetypes/topdown/assets/audio/key.wav +0 -0
  437. package/archetypes/topdown/assets/audio/step.ogt +9 -0
  438. package/archetypes/topdown/assets/fonts/OFL.txt +93 -0
  439. package/archetypes/topdown/assets/fonts/ui.ttf +0 -0
  440. package/archetypes/topdown/assets/fonts/ui.ttf.ogt +9 -0
  441. package/archetypes/topdown/assets/maps/tomb.tmj +2183 -0
  442. package/archetypes/topdown/assets/sprites/hero.ogt +58 -0
  443. package/archetypes/topdown/assets/sprites/hero.png +0 -0
  444. package/archetypes/topdown/assets/sprites/hero.png.ogt +7 -0
  445. package/archetypes/topdown/assets/sprites/items.ogt +15 -0
  446. package/archetypes/topdown/assets/sprites/items.png +0 -0
  447. package/archetypes/topdown/assets/sprites/items.png.ogt +7 -0
  448. package/archetypes/topdown/assets/sprites/slime.ogt +17 -0
  449. package/archetypes/topdown/assets/sprites/slime.png +0 -0
  450. package/archetypes/topdown/assets/sprites/slime.png.ogt +7 -0
  451. package/archetypes/topdown/assets/tiles/dungeon.ogt +65 -0
  452. package/archetypes/topdown/assets/tiles/dungeon.png +0 -0
  453. package/archetypes/topdown/assets/tiles/dungeon.png.ogt +7 -0
  454. package/archetypes/topdown/gitattributes +22 -0
  455. package/archetypes/topdown/host.d.ts +46 -0
  456. package/archetypes/topdown/package.json +18 -0
  457. package/archetypes/topdown/project.ogt +14 -0
  458. package/archetypes/topdown/references/metal/crit.png +0 -0
  459. package/archetypes/topdown/references/metal/dash.png +0 -0
  460. package/archetypes/topdown/references/metal/east.png +0 -0
  461. package/archetypes/topdown/references/metal/start.png +0 -0
  462. package/archetypes/topdown/src/art.ts +48 -0
  463. package/archetypes/topdown/src/components.ts +128 -0
  464. package/archetypes/topdown/src/main.ts +275 -0
  465. package/archetypes/topdown/src/systems.ts +503 -0
  466. package/archetypes/topdown/tests/ai.og.ts +64 -0
  467. package/archetypes/topdown/tests/combat.og.ts +72 -0
  468. package/archetypes/topdown/tests/door.og.ts +62 -0
  469. package/archetypes/topdown/tests/flee.og.ts +49 -0
  470. package/archetypes/topdown/tests/frames.og.ts +45 -0
  471. package/archetypes/topdown/tests/frames.ts +134 -0
  472. package/archetypes/topdown/tests/lib.ts +71 -0
  473. package/archetypes/topdown/tests/replay.og.ts +40 -0
  474. package/archetypes/topdown/tests/walk.og.ts +46 -0
  475. package/archetypes/topdown/tools/make-assets.py +623 -0
  476. package/archetypes/topdown/tools/oglite.py +285 -0
  477. package/archetypes/topdown/tsconfig.json +17 -0
  478. package/archetypes/tower-defense/.origin/setup +14 -0
  479. package/archetypes/tower-defense/LICENSES.md +15 -0
  480. package/archetypes/tower-defense/README.md +240 -0
  481. package/archetypes/tower-defense/assets/ai/plant.ogt +16 -0
  482. package/archetypes/tower-defense/assets/audio/clear.wav +0 -0
  483. package/archetypes/tower-defense/assets/audio/frost.wav +0 -0
  484. package/archetypes/tower-defense/assets/audio/leak.wav +0 -0
  485. package/archetypes/tower-defense/assets/audio/lost.wav +0 -0
  486. package/archetypes/tower-defense/assets/audio/night.wav +0 -0
  487. package/archetypes/tower-defense/assets/audio/plant.wav +0 -0
  488. package/archetypes/tower-defense/assets/audio/pop.wav +0 -0
  489. package/archetypes/tower-defense/assets/audio/thorn.wav +0 -0
  490. package/archetypes/tower-defense/assets/audio/ui-close.ogt +9 -0
  491. package/archetypes/tower-defense/assets/audio/ui-error.ogt +9 -0
  492. package/archetypes/tower-defense/assets/audio/ui-open.ogt +9 -0
  493. package/archetypes/tower-defense/assets/audio/ui-press.ogt +9 -0
  494. package/archetypes/tower-defense/assets/audio/ui-success.ogt +9 -0
  495. package/archetypes/tower-defense/assets/audio/wave.wav +0 -0
  496. package/archetypes/tower-defense/assets/audio/won.wav +0 -0
  497. package/archetypes/tower-defense/assets/fonts/NotoSansSC-subset.ttf +0 -0
  498. package/archetypes/tower-defense/assets/fonts/NotoSansSC-subset.ttf.ogt +10 -0
  499. package/archetypes/tower-defense/assets/fonts/OFL.txt +93 -0
  500. package/archetypes/tower-defense/assets/fx/fireflies.ogt +21 -0
  501. package/archetypes/tower-defense/assets/fx/pop.ogt +21 -0
  502. package/archetypes/tower-defense/assets/maps/garden.ogt +91 -0
  503. package/archetypes/tower-defense/assets/skins/pathguard/Fredoka-SemiBold.ttf +0 -0
  504. package/archetypes/tower-defense/assets/skins/pathguard/Fredoka-SemiBold.ttf.ogt +9 -0
  505. package/archetypes/tower-defense/assets/skins/pathguard/LICENSES.md +13 -0
  506. package/archetypes/tower-defense/assets/skins/pathguard/LilitaOne-Regular.ttf +0 -0
  507. package/archetypes/tower-defense/assets/skins/pathguard/LilitaOne-Regular.ttf.ogt +9 -0
  508. package/archetypes/tower-defense/assets/skins/pathguard/OFL.txt +94 -0
  509. package/archetypes/tower-defense/assets/skins/pathguard/atlas.png +0 -0
  510. package/archetypes/tower-defense/assets/skins/pathguard/atlas.png.ogt +7 -0
  511. package/archetypes/tower-defense/assets/skins/pathguard/icons.png +0 -0
  512. package/archetypes/tower-defense/assets/skins/pathguard/icons.png.ogt +7 -0
  513. package/archetypes/tower-defense/assets/skins/pathguard/skin.ogt +111 -0
  514. package/archetypes/tower-defense/assets/sprites/garden.ogt +66 -0
  515. package/archetypes/tower-defense/assets/sprites/garden.png +0 -0
  516. package/archetypes/tower-defense/assets/sprites/garden.png.ogt +7 -0
  517. package/archetypes/tower-defense/assets/sprites/glow.png +0 -0
  518. package/archetypes/tower-defense/assets/sprites/glow.png.ogt +7 -0
  519. package/archetypes/tower-defense/assets/sprites/ring.png +0 -0
  520. package/archetypes/tower-defense/assets/sprites/ring.png.ogt +7 -0
  521. package/archetypes/tower-defense/assets/sprites/spark.png +0 -0
  522. package/archetypes/tower-defense/assets/sprites/spark.png.ogt +7 -0
  523. package/archetypes/tower-defense/assets/strings/en.ogt +47 -0
  524. package/archetypes/tower-defense/assets/strings/zh-CN.ogt +47 -0
  525. package/archetypes/tower-defense/assets/tiles/garden.ogt +10 -0
  526. package/archetypes/tower-defense/assets/tiles/garden.png +0 -0
  527. package/archetypes/tower-defense/assets/tiles/garden.png.ogt +7 -0
  528. package/archetypes/tower-defense/gitattributes +22 -0
  529. package/archetypes/tower-defense/host.d.ts +46 -0
  530. package/archetypes/tower-defense/package.json +18 -0
  531. package/archetypes/tower-defense/project.ogt +14 -0
  532. package/archetypes/tower-defense/references/metal/end.png +0 -0
  533. package/archetypes/tower-defense/references/metal/title.png +0 -0
  534. package/archetypes/tower-defense/references/metal/wave.png +0 -0
  535. package/archetypes/tower-defense/src/art.ts +24 -0
  536. package/archetypes/tower-defense/src/components.ts +156 -0
  537. package/archetypes/tower-defense/src/main.ts +253 -0
  538. package/archetypes/tower-defense/src/systems.ts +658 -0
  539. package/archetypes/tower-defense/src/ui.ts +382 -0
  540. package/archetypes/tower-defense/tests/flow.og.ts +56 -0
  541. package/archetypes/tower-defense/tests/frames.og.ts +31 -0
  542. package/archetypes/tower-defense/tests/frames.ts +134 -0
  543. package/archetypes/tower-defense/tests/lib.ts +81 -0
  544. package/archetypes/tower-defense/tests/lose.og.ts +40 -0
  545. package/archetypes/tower-defense/tests/maze.og.ts +53 -0
  546. package/archetypes/tower-defense/tests/pad.og.ts +41 -0
  547. package/archetypes/tower-defense/tests/pause.og.ts +59 -0
  548. package/archetypes/tower-defense/tests/phone.og.ts +49 -0
  549. package/archetypes/tower-defense/tests/replay.og.ts +28 -0
  550. package/archetypes/tower-defense/tests/win.og.ts +58 -0
  551. package/archetypes/tower-defense/tools/make-assets.py +640 -0
  552. package/archetypes/tower-defense/tools/oglite.py +285 -0
  553. package/archetypes/tower-defense/tsconfig.json +17 -0
  554. package/bin/create.ts +496 -0
  555. package/looks/catalogue.json +1871 -0
  556. package/package.json +31 -4
  557. package/template/.origin/setup +14 -0
  558. package/template/LICENSES.md +23 -0
  559. package/template/README.md +37 -0
  560. package/template/assets/ai/guard.ogt +48 -0
  561. package/template/assets/audio/blip.wav +0 -0
  562. package/template/assets/audio/click.ogt +9 -0
  563. package/template/assets/fonts/NotoSansSC-Regular-subset.ttf +0 -0
  564. package/template/assets/fonts/NotoSansSC-Regular-subset.ttf.ogt +12 -0
  565. package/template/assets/fonts/OFL.txt +93 -0
  566. package/template/assets/looks/origin-game.ogt +12 -0
  567. package/template/assets/models/dropship.glb +0 -0
  568. package/template/assets/models/walker.glb +0 -0
  569. package/template/assets/nav/yard.ogt +27 -0
  570. package/template/assets/scenes/main.ogt +34 -0
  571. package/template/assets/strings/en.ogt +14 -0
  572. package/template/assets/textures/stone.png +0 -0
  573. package/template/assets/textures/stone_n.png +0 -0
  574. package/template/assets/textures/stone_n.png.ogt +7 -0
  575. package/template/gitattributes +22 -0
  576. package/template/package.json +18 -0
  577. package/template/project.ogt +25 -0
  578. package/template/src/main.ts +246 -0
  579. package/template/tests/guard.og.ts +67 -0
  580. package/template/tests/smoke.og.ts +43 -0
  581. package/template/tsconfig.json +17 -0
@@ -0,0 +1,421 @@
1
+ // Three-Lane Beat's screens on og.ui and the skin in assets/skins/lanebeat
2
+ // (the engine's sci-fi pack): the title, the HUD (the score and the groove
3
+ // top left, Pause top right, the combo and its multiplier beside the
4
+ // highway), the pause menu, the settings with the offset, the calibration
5
+ // and the results. Screens change through a wipe (a fade with reduced
6
+ // motion). Every string is a key of assets/strings/*.ogt.
7
+ //
8
+ // The Ui system also starts a play (the count-in, then bar 1), pauses it
9
+ // (the band stops, the clock freezes) and resumes it on the beat it paused
10
+ // on after a new count-in (the stems continue part-way), ends it with the results, and
11
+ // keeps the settings and the best score in og.platform.
12
+
13
+ import { og, defineSystem } from "@origingame/engine";
14
+ import type { Value, World } from "@origingame/engine";
15
+ import { Game, Phase, Prefs, Tuning } from "./components.ts";
16
+ import { beatAt, beatLength, lazyTuning, must, worldTime } from "./systems.ts";
17
+
18
+ export const LANGUAGES = [
19
+ { code: "en", key: "lang.en" },
20
+ { code: "zh-CN", key: "lang.zh" },
21
+ ] as const;
22
+
23
+ /** The tokens' spacing scale in CSS px (og.ui.frameTheme answers it too, but builds the whole theme each call). */
24
+ const S = { xxs: 2, xs: 4, sm: 8, md: 12, lg: 16, xl: 24 } as const;
25
+
26
+ type GameV = Value<typeof Game>;
27
+ type PrefsV = Value<typeof Prefs>;
28
+
29
+ export function say(world: World, key: string, args?: Record<string, string | number>): string {
30
+ return og.i18n.t(world, key, args);
31
+ }
32
+
33
+ const grow = { kind: "grow" } as const;
34
+ const px = (n: number) => ({ kind: "fixed", px: n }) as const;
35
+
36
+ /** A new play: the counts cleared, the count-in from the next beat, then bar 1 (or `fromBar`). */
37
+ export function begin(world: World, g: GameV, fromBar = 1): void {
38
+ const t = lazyTuning(world);
39
+ const len = beatLength(g);
40
+ const now = worldTime(world);
41
+ g.phase = Phase.Play;
42
+ g.paused = false;
43
+ g.pausedAt = -1;
44
+ g.score = 0;
45
+ g.combo = 0;
46
+ g.maxCombo = 0;
47
+ g.perfect = 0;
48
+ g.great = 0;
49
+ g.good = 0;
50
+ g.miss = 0;
51
+ g.hits = 0;
52
+ g.judged = 0;
53
+ g.taps = 0;
54
+ g.scheduled = 0;
55
+ g.groove = t.grooveStart;
56
+ g.failed = false;
57
+ g.cleared = false;
58
+ g.over = false;
59
+ g.endAt = 0;
60
+ g.newBest = false;
61
+ g.lastJudgement = -1;
62
+ g.countShown = -1;
63
+ g.resetNotes = true;
64
+ g.stopBand = true;
65
+ // The first bar starts countInBeats after the next whole tick: the clicks lead in.
66
+ const from = (Math.max(1, Math.min(g.bars, fromBar)) - 1) * 4;
67
+ g.fromBeat = from;
68
+ g.countTo = Math.ceil((now + 0.25) * 60) / 60 + t.countInBeats * len;
69
+ g.songStart = g.countTo - from * len;
70
+ g.bandFrom = from / 4 + 1;
71
+ g.bandBeat = from;
72
+ g.scheduleUpTo = from + t.scrollBeats + 1;
73
+ }
74
+
75
+ /** Pause: the clock freezes where it is, the band stops. */
76
+ export function pause(world: World, g: GameV): void {
77
+ if (g.phase !== Phase.Play || g.paused || g.over) return;
78
+ g.paused = true;
79
+ g.pausedAt = worldTime(world);
80
+ g.stopBand = true;
81
+ }
82
+
83
+ /** Resume on the beat it was paused on, after a new count-in: the stems sounding then continue from where they were (AudioSource.startOffset). */
84
+ export function resume(world: World, g: GameV): void {
85
+ if (!g.paused) return;
86
+ const t = lazyTuning(world);
87
+ const len = beatLength(g);
88
+ const from = Math.max(0, beatAt(g, g.pausedAt));
89
+ const now = worldTime(world);
90
+ const countTo = Math.ceil((now + 0.25) * 60) / 60 + t.countInBeats * len;
91
+ g.songStart = countTo - from * len;
92
+ g.countTo = countTo;
93
+ g.bandFrom = Math.floor(from / 4) + 1;
94
+ g.bandBeat = from;
95
+ g.scheduleUpTo = Math.ceil(from) + t.scrollBeats + 1;
96
+ g.countShown = -1;
97
+ g.paused = false;
98
+ g.pausedAt = -1;
99
+ }
100
+
101
+ /** Calibration: the clock clicks every beat from the next one; taps measure the offset. */
102
+ export function calibrate(world: World, g: GameV): void {
103
+ g.phase = Phase.Calibrate;
104
+ g.calTaps = 0;
105
+ g.calSum = 0;
106
+ g.stopBand = true;
107
+ g.songStart = Math.ceil((worldTime(world) + 0.5) * 60) / 60;
108
+ }
109
+
110
+ function applyPrefs(world: World, p: PrefsV): void {
111
+ const audio = world.resource(og.Audio);
112
+ if (audio.ok) {
113
+ audio.value.master = p.master;
114
+ audio.value.music = p.music;
115
+ audio.value.sfx = p.effects;
116
+ audio.value.ui = p.effects;
117
+ }
118
+ }
119
+
120
+ function setLanguage(world: World, p: PrefsV, index: number): void {
121
+ p.language = Math.max(0, Math.min(LANGUAGES.length - 1, index));
122
+ og.i18n.setLocale(world, LANGUAGES[p.language]!.code);
123
+ }
124
+
125
+ function prefsValue(p: PrefsV) {
126
+ return { masterVolume: p.master, musicVolume: p.music, sfxVolume: p.effects, language: LANGUAGES[p.language]!.code, reducedMotion: p.reducedMotion, offsetMs: p.offsetMs };
127
+ }
128
+
129
+ function saveSettings(world: World, p: PrefsV): void {
130
+ must(og.platform.saveSettings(world, prefsValue(p)));
131
+ p.saves += 1;
132
+ }
133
+
134
+ /** og.platform: the settings and the best score asked for on tick 0; the best written at the revision read. */
135
+ function platform(world: World, g: GameV, p: PrefsV): void {
136
+ if (world.tick === 0) {
137
+ p.loadRequest = og.platform.loadSettings(world);
138
+ const r = og.platform.storeGet(world, "best");
139
+ g.bestRequest = r.ok ? r.value : 0;
140
+ return;
141
+ }
142
+ if (p.loadRequest !== 0) {
143
+ const r = og.platform.result(world, p.loadRequest);
144
+ if (r !== null) {
145
+ p.loadRequest = 0;
146
+ const s = ((r.ok ? r.data : null) as { value?: Record<string, unknown> } | null)?.value ?? null;
147
+ if (s && typeof s === "object") {
148
+ if (typeof s.masterVolume === "number") p.master = s.masterVolume;
149
+ if (typeof s.musicVolume === "number") p.music = s.musicVolume;
150
+ if (typeof s.sfxVolume === "number") p.effects = s.sfxVolume;
151
+ if (typeof s.reducedMotion === "boolean") p.reducedMotion = s.reducedMotion;
152
+ if (typeof s.offsetMs === "number") p.offsetMs = s.offsetMs;
153
+ const at = LANGUAGES.findIndex((l) => l.code === s.language);
154
+ if (at >= 0) setLanguage(world, p, at);
155
+ applyPrefs(world, p);
156
+ }
157
+ }
158
+ }
159
+ if (g.bestRequest !== 0) {
160
+ const r = og.platform.result(world, g.bestRequest);
161
+ if (r !== null) {
162
+ g.bestRequest = 0;
163
+ const d = (r.ok ? r.data : null) as { value?: number | null; revision?: number } | null;
164
+ if (typeof d?.value === "number") g.best = Math.max(g.best, d.value);
165
+ if (typeof d?.revision === "number") g.bestRevision = d.revision;
166
+ }
167
+ }
168
+ if (g.bestWrite !== 0) {
169
+ const r = og.platform.result(world, g.bestWrite);
170
+ if (r !== null) {
171
+ g.bestWrite = 0;
172
+ if (r.ok) g.bestRevision = (r.data as { revision: number }).revision;
173
+ }
174
+ }
175
+ }
176
+
177
+ /** The play is over: the results, the best kept, the score on the board, the telemetry. */
178
+ function finish(world: World, g: GameV): void {
179
+ g.phase = Phase.Results;
180
+ g.stopBand = true;
181
+ if (g.cleared && g.score > g.best) {
182
+ g.best = g.score;
183
+ g.newBest = true;
184
+ const w = og.platform.storeSet(world, { key: "best", value: g.score, revision: g.bestRevision });
185
+ if (w.ok) g.bestWrite = w.value;
186
+ }
187
+ if (g.cleared) must2(og.platform.leaderboardSubmit(world, { board: "neon-pulse", score: g.score }));
188
+ must(og.platform.telemetry(world, "song.over", { cleared: g.cleared, score: g.score, accuracy: accuracy(g), maxCombo: g.maxCombo, miss: g.miss }));
189
+ }
190
+
191
+ function must2(r: { ok: true } | { ok: false; reason: string }): void {
192
+ if (!r.ok) throw new Error(r.reason);
193
+ }
194
+
195
+ /** Accuracy, 0 to 100: a Perfect counts whole, a Great 70 %, a Good 40 %, a Miss nothing. */
196
+ export function accuracy(g: GameV): number {
197
+ if (g.judged === 0) return 100;
198
+ return Math.round((1000 * (g.perfect + 0.7 * g.great + 0.4 * g.good)) / g.judged) / 10;
199
+ }
200
+
201
+ /** The grade of a cleared song by its accuracy. */
202
+ export function grade(acc: number): string {
203
+ return acc >= 95 ? "S" : acc >= 85 ? "A" : acc >= 70 ? "B" : acc >= 50 ? "C" : "D";
204
+ }
205
+
206
+ function capsule(id: string, build: () => void): void {
207
+ og.ui.row(id, { gap: S.sm, cross: "center", padding: { left: S.sm, top: S.xs, right: S.md, bottom: S.xs }, frame: "capsule", background: { token: "surface" } }, build);
208
+ }
209
+
210
+ function hud(world: World, g: GameV): void {
211
+ const t = lazyTuning(world);
212
+ const vp = og.ui.frameViewport();
213
+ const phone = vp.width < vp.height;
214
+ // The pad and the arrows play the lanes; they move the focus only on the pause menu.
215
+ og.ui.setNavigation(g.paused || g.settingsOpen);
216
+ og.ui.anchor("Status", { anchor: "topLeft", direction: "column", gap: S.sm }, () => {
217
+ capsule("Score", () => {
218
+ og.ui.label("Label", say(world, "hud.score"), { step: "caption", color: { token: "fgMuted" }, nowrap: true });
219
+ og.ui.counter("Value", g.score, { step: "xl", font: "display", durationMs: 300, width: px(phone ? 104 : 130) });
220
+ });
221
+ capsule("Groove", () => {
222
+ og.ui.label("Label", say(world, "hud.groove"), { step: "caption", color: { token: "fgMuted" }, nowrap: true });
223
+ og.ui.meter("Bar", g.groove, 1, { kind: "health", width: px(phone ? 90 : 130) });
224
+ });
225
+ });
226
+ let paused = false;
227
+ og.ui.anchor("Corner", { anchor: "topRight" }, () => {
228
+ if (og.ui.actionButton("Pause", say(world, "hud.pause"), { icon: "pause", size: 48 }).clicked) paused = true;
229
+ });
230
+ if (paused) pause(world, g);
231
+ // The combo beside the highway (above it on a phone): the count and its multiplier's progress.
232
+ const multiplier = Math.min(4, 1 + Math.floor(g.combo / t.comboStep));
233
+ og.ui.anchor("Combo", { anchor: phone ? "top" : "right", offsetY: phone ? 64 : 40, offsetX: phone ? 0 : -48, direction: "column", cross: "center", gap: S.xxs }, () => {
234
+ og.ui.counter("Count", g.combo, { step: "displaySm", font: "display", durationMs: 120, align: "center", width: px(96) });
235
+ og.ui.row("Head", { gap: S.xs, cross: "center" }, () => {
236
+ og.ui.label("Label", say(world, "hud.combo"), { step: "caption", color: { token: "fgMuted" }, nowrap: true });
237
+ og.ui.label("Multiplier", say(world, "hud.multiplier", { n: multiplier }), { step: "caption", color: { token: "accent" }, nowrap: true });
238
+ });
239
+ og.ui.meter("Next", multiplier >= 4 ? 1 : (g.combo % t.comboStep) / t.comboStep, 1, { width: px(96) });
240
+ });
241
+ }
242
+
243
+ function settings(world: World, g: GameV, p: PrefsV): void {
244
+ let done = false;
245
+ let cal = false;
246
+ const before = JSON.stringify(prefsValue(p));
247
+ const m = og.ui.modal("Settings", g.settingsOpen, { title: say(world, "settings.title"), width: px(Math.min(440, og.ui.frameViewport().width - 32)) }, () => {
248
+ const slider = (id: string, key: string, value: number, min = 0, max = 1, step = 0.05, shown = (v: number) => `${Math.round(v * 100)}`): number => {
249
+ let out = value;
250
+ og.ui.row(id, { width: grow, gap: S.md, cross: "center" }, () => {
251
+ og.ui.label("Label", say(world, key), { width: px(110), nowrap: true });
252
+ out = og.ui.slider("Slider", value, { min, max, step }).value;
253
+ og.ui.label("Value", shown(out), { width: px(64), align: "end", font: "mono", nowrap: true });
254
+ });
255
+ return out;
256
+ };
257
+ p.master = slider("Master", "settings.master", p.master);
258
+ p.music = slider("Music", "settings.music", p.music);
259
+ p.effects = slider("Effects", "settings.effects", p.effects);
260
+ p.offsetMs = slider("Offset", "settings.offset", p.offsetMs, -200, 200, 5, (v) => say(world, "settings.ms", { n: Math.round(v) }));
261
+ og.ui.label("LanguageLabel", say(world, "settings.language"), { color: { token: "fgMuted" } });
262
+ const r = og.ui.radio("Language", LANGUAGES.map((l) => say(world, l.key)), p.language, { horizontal: true });
263
+ if (r.selected !== p.language) setLanguage(world, p, r.selected);
264
+ p.reducedMotion = og.ui.toggle("Motion", p.reducedMotion, say(world, "settings.motion")).on;
265
+ og.ui.row("Footer", { width: grow, gap: S.sm, align: "end" }, () => {
266
+ if (g.phase === Phase.Title && og.ui.button("Calibrate", say(world, "settings.calibrate")).clicked) cal = true;
267
+ if (og.ui.button("Done", say(world, "settings.done"), { variant: "primary" }).clicked) done = true;
268
+ });
269
+ });
270
+ if (JSON.stringify(prefsValue(p)) !== before) applyPrefs(world, p);
271
+ if (g.settingsOpen && (done || cal || m.dismissed)) {
272
+ g.settingsOpen = false;
273
+ saveSettings(world, p);
274
+ if (cal) calibrate(world, g);
275
+ }
276
+ }
277
+
278
+ /** The calibration: tap on the clicks; the mean error of eight taps is the offset. */
279
+ function calibration(world: World, g: GameV, p: PrefsV): void {
280
+ let done = false;
281
+ let again = false;
282
+ const measured = g.calTaps > 0 ? g.calSum / g.calTaps : p.offsetMs;
283
+ const m = og.ui.modal("Calibration", true, { title: say(world, "cal.title"), width: px(Math.min(420, og.ui.frameViewport().width - 32)) }, () => {
284
+ og.ui.label("Body", say(world, "cal.body"), { width: grow });
285
+ og.ui.row("Taps", { width: grow, gap: S.md, cross: "center" }, () => {
286
+ og.ui.label("Count", say(world, "cal.taps", { n: g.calTaps }), { nowrap: true, width: grow });
287
+ og.ui.label("Offset", say(world, "cal.offset", { n: Math.round(measured) }), { font: "mono", nowrap: true, color: { token: "accent" } });
288
+ });
289
+ og.ui.meter("Progress", g.calTaps, 8, { width: grow });
290
+ og.ui.row("Actions", { width: grow, gap: S.sm, align: "end" }, () => {
291
+ if (og.ui.button("Again", say(world, "cal.reset")).clicked) again = true;
292
+ if (og.ui.button("Done", say(world, "cal.done"), { variant: "primary" }).clicked) done = true;
293
+ });
294
+ });
295
+ if (again) {
296
+ g.calTaps = 0;
297
+ g.calSum = 0;
298
+ }
299
+ if (done || m.dismissed) {
300
+ if (done && g.calTaps >= 4) {
301
+ p.offsetMs = Math.round(measured);
302
+ saveSettings(world, p);
303
+ }
304
+ g.phase = Phase.Title;
305
+ g.stopBand = true;
306
+ }
307
+ }
308
+
309
+ /** The results: cleared (with a grade) or failed, the counts, the best. */
310
+ function results(world: World, g: GameV): "again" | "title" | null {
311
+ let chose: "again" | "title" | null = null;
312
+ const acc = accuracy(g);
313
+ og.ui.modal("Results", true, { title: say(world, g.cleared ? "results.cleared" : "results.failed"), locked: true, width: px(Math.min(420, og.ui.frameViewport().width - 32)) }, () => {
314
+ og.ui.row("Mark", { width: grow, align: "center", gap: S.md, cross: "center" }, () => {
315
+ og.ui.transition("Grade", true, { kind: "pop" }, () => og.ui.label("Letter", g.cleared ? grade(acc) : "–", { step: "displayMd", font: "display", color: { token: g.cleared ? "accent" : "fgMuted" } }));
316
+ if (g.newBest) og.ui.label("NewBest", say(world, "results.newBest"), { color: { token: "accent" }, nowrap: true });
317
+ });
318
+ og.ui.column("Stats", { width: grow, gap: 0 }, () => {
319
+ og.ui.keyValue("Score", say(world, "results.score"), `${g.score}`, true);
320
+ og.ui.keyValue("Accuracy", say(world, "results.accuracy"), say(world, "results.percent", { n: acc }), true);
321
+ og.ui.keyValue("Combo", say(world, "results.combo"), `${g.maxCombo}`, true);
322
+ og.ui.keyValue("Perfect", say(world, "results.perfect"), `${g.perfect}`, true);
323
+ og.ui.keyValue("Great", say(world, "results.great"), `${g.great}`, true);
324
+ og.ui.keyValue("Good", say(world, "results.good"), `${g.good}`, true);
325
+ og.ui.keyValue("Miss", say(world, "results.miss"), `${g.miss}`, true);
326
+ });
327
+ og.ui.label("Best", say(world, "results.best", { n: g.best }), { color: { token: "fgMuted" }, align: "center", width: grow });
328
+ og.ui.row("Actions", { width: grow, gap: S.sm }, () => {
329
+ if (og.ui.button("Again", say(world, "results.again"), { variant: "primary", width: grow }).clicked) chose = "again";
330
+ if (og.ui.button("Title", say(world, "results.title"), { width: grow }).clicked) chose = "title";
331
+ });
332
+ });
333
+ return chose;
334
+ }
335
+
336
+ /** The screens, the layout for the surface, the buses, the platform's answers, the play's start, pause and end. */
337
+ export const Ui = defineSystem("Ui", { reads: [Tuning, og.Input, og.Gamepad], writes: [Game, Prefs, og.Camera, og.Audio] }, (_q, time, world) => {
338
+ const game = world.resource(Game);
339
+ const prefs = world.resource(Prefs);
340
+ if (!game.ok || !prefs.ok) return;
341
+ const g = game.value;
342
+ const p = prefs.value;
343
+ platform(world, g, p);
344
+ if (time.tick === 0) applyPrefs(world, p);
345
+ // The layout: 10 m tall and three 1.5 m lanes on a wide screen; 7.2 m across a portrait one with 2 m lanes.
346
+ const vp = og.ui.frameViewport();
347
+ if (vp.width > 0 && (vp.width !== g.viewW || vp.height !== g.viewH)) {
348
+ g.viewW = vp.width;
349
+ g.viewH = vp.height;
350
+ const portrait = vp.width < vp.height;
351
+ const height = portrait ? (7.2 * vp.height) / vp.width : 10;
352
+ const cam = world.resource(og.Camera);
353
+ if (cam.ok) cam.value.height = height;
354
+ g.laneW = portrait ? 2 : 1.5;
355
+ g.hitY = -height / 2 + (portrait ? 2.6 : 1.8);
356
+ g.topY = height / 2 - (portrait ? 2.4 : 0.2);
357
+ }
358
+ const hold = g.phase === Phase.Play && (g.paused || g.settingsOpen);
359
+ if (hold !== g.held) {
360
+ must(og.time.setScale(world, hold ? 0 : 1));
361
+ g.held = hold;
362
+ }
363
+ const input = world.resource(og.Input);
364
+ const pad = world.resource(og.Gamepad);
365
+ if (g.phase === Phase.Play && !g.paused && input.ok && pad.ok && (input.value.pressed("Escape") || input.value.pressed("KeyP") || pad.value.pressed("start"))) pause(world, g);
366
+ if (g.phase === Phase.Play && g.over) finish(world, g);
367
+
368
+ const screen = g.phase === Phase.Title ? "title" : g.phase === Phase.Play ? "play" : g.phase === Phase.Results ? "results" : "calibrate";
369
+ const shown = og.ui.screenTransition("Screens", screen, { kind: p.reducedMotion ? "fade" : "wipe", durationMs: 500 }).shown;
370
+ if (shown !== "title") g.leftTitle = true;
371
+ if (shown === "title") {
372
+ og.ui.setNavigation(true);
373
+ const r = og.ui.mainMenu("Title", {
374
+ title: say(world, "title.name"),
375
+ subtitle: say(world, "title.tagline"),
376
+ items: [
377
+ { id: "play", label: say(world, "title.play"), primary: true },
378
+ { id: "calibrate", label: say(world, "title.calibrate") },
379
+ { id: "settings", label: say(world, "title.settings") },
380
+ ],
381
+ footer: say(world, "title.footer"),
382
+ // The title the game opens on is built settled: the web draws it behind the play gate, where
383
+ // the skin's entrance would stand part-way until the tap (og-platform-sdk §3). Later titles enter.
384
+ instant: !g.leftTitle,
385
+ });
386
+ if (!g.settingsOpen && r.selected === "play") begin(world, g);
387
+ if (!g.settingsOpen && r.selected === "calibrate") calibrate(world, g);
388
+ if (r.selected === "settings") g.settingsOpen = true;
389
+ } else if (shown === "play") {
390
+ hud(world, g);
391
+ const m = og.ui.pauseMenu("Pause", {
392
+ open: g.paused && !g.settingsOpen,
393
+ title: say(world, "pause.title"),
394
+ items: [
395
+ { id: "resume", label: say(world, "pause.resume"), primary: true },
396
+ { id: "restart", label: say(world, "pause.restart") },
397
+ { id: "settings", label: say(world, "pause.settings") },
398
+ { id: "quit", label: say(world, "pause.quit") },
399
+ ],
400
+ });
401
+ if (m.selected === "resume") resume(world, g);
402
+ if (m.selected === "restart") begin(world, g);
403
+ if (m.selected === "settings") g.settingsOpen = true;
404
+ if (m.selected === "quit") {
405
+ g.paused = false;
406
+ g.pausedAt = -1;
407
+ g.phase = Phase.Title;
408
+ g.stopBand = true;
409
+ }
410
+ } else if (shown === "results") {
411
+ og.ui.setNavigation(true);
412
+ const c = results(world, g);
413
+ if (c === "again") begin(world, g);
414
+ if (c === "title") g.phase = Phase.Title;
415
+ } else {
416
+ og.ui.setNavigation(true);
417
+ calibration(world, g, p);
418
+ }
419
+ settings(world, g, p);
420
+ if (g.language !== p.language) g.language = p.language;
421
+ });
@@ -0,0 +1,45 @@
1
+ // The song on og.Music's clock: the count-in's four clicks are started at
2
+ // the four beats before bar 1, the drums on bar 1's line, and every stem
3
+ // after that on its own bar line from og.MusicBeat (the bass and the chords
4
+ // at bar 5, the lead at bar 9), each to the sample (AudioSource.startAt
5
+ // is the bar's exact world time); the notes come onto the highway beats
6
+ // ahead of their time.
7
+ import { playtest } from "@origingame/engine/playtest";
8
+ import { game, songStart, sorted } from "./lib.ts";
9
+
10
+ const t0 = songStart(1.0);
11
+ const bar = (n: number) => t0 + (n - 1) * 2;
12
+
13
+ interface Src { components: { "og.AudioSource": { startAt: number; playing: boolean }; Stem: { starts: number } } }
14
+
15
+ export default playtest({
16
+ name: "the clicks, the drums and every stem start on their beats and bar lines",
17
+ commands: sorted([
18
+ // Nothing is pressed here, so the groove must not run out.
19
+ "0.9:set:Tuning.grooveLoss=0",
20
+ "1.0:play",
21
+ "1.15:dump_entity:stem-click0:click0.json",
22
+ "1.15:dump_entity:stem-click3:click3.json",
23
+ "1.15:dump_entity:stem-drums:drums1.json",
24
+ `${(bar(5) + 0.1).toFixed(3)}:dump_entity:stem-bass0:bass.json`,
25
+ `${(bar(5) + 0.1).toFixed(3)}:dump_entity:stem-chords0:chords.json`,
26
+ `${(bar(5) + 0.1).toFixed(3)}:dump_entity:stem-drums:drums5.json`,
27
+ `${(bar(9) + 0.1).toFixed(3)}:dump_entity:stem-leadA:lead.json`,
28
+ `${(bar(9) + 0.1).toFixed(3)}:get:Game:bar9.json`,
29
+ `${(bar(9) + 0.2).toFixed(3)}:quit`,
30
+ ]),
31
+ check(run, t) {
32
+ t.equal(run.warnings.join("; "), "", "the script ran without warnings");
33
+ const src = (f: string) => run.json<Src>(f).components["og.AudioSource"];
34
+ const near = (a: number, b: number) => Math.abs(a - b) < 1e-6;
35
+ t.ok(near(src("click0.json").startAt, t0 - 2), `the first click at ${(t0 - 2).toFixed(3)} s, four beats before bar 1`);
36
+ t.ok(near(src("click3.json").startAt, t0 - 0.5), "the fourth a beat before it");
37
+ t.ok(near(src("drums1.json").startAt, t0), `the drums on bar 1's line (${t0.toFixed(3)} s)`);
38
+ t.ok(near(src("bass.json").startAt, bar(5)) && src("bass.json").playing, `the bass on bar 5's line (${bar(5).toFixed(3)} s)`);
39
+ t.ok(near(src("chords.json").startAt, bar(5)), "the chords with it");
40
+ t.ok(near(src("drums5.json").startAt, bar(5)), "the drums restarted on bar 5's line too");
41
+ t.equal(run.json<Src>("drums5.json").components.Stem.starts, 5, "five bars, five starts of the one-bar drums");
42
+ t.ok(near(src("lead.json").startAt, bar(9)), `the lead on bar 9's line (${bar(9).toFixed(3)} s)`);
43
+ t.equal(game(run, "bar9.json").miss, game(run, "bar9.json").judged, "(nothing pressed: every note judged so far a Miss)");
44
+ },
45
+ });
@@ -0,0 +1,49 @@
1
+ // Latency calibration: on the calibration screen the clock clicks every
2
+ // beat; eight taps, each four ticks (67 ms) after its click, measure an
3
+ // offset of 67 ms; Done saves it. Then a play whose every press is 67 ms
4
+ // late is judged Perfect throughout, where without the offset each would
5
+ // be a Great.
6
+ import { playtest } from "@origingame/engine/playtest";
7
+ import { BEAT, chart, game, type PlatformDump, play, press, songStart, sorted, tap, TITLE } from "./lib.ts";
8
+
9
+ const notes = chart();
10
+ /** The `calibrate` command at 1.0 s: clicks from the next whole tick half a second on, every beat. */
11
+ const c0 = Math.ceil((1.0 + 0.5) * 60) / 60;
12
+ const late = 4 / 60;
13
+ const t0 = songStart(7.0);
14
+
15
+ interface Src { components: { "og.AudioSource": { startAt: number } } }
16
+
17
+ export default playtest({
18
+ name: "eight taps 67 ms late calibrate a 67 ms offset, and a late play is judged Perfect",
19
+ commands: sorted([
20
+ "1.0:calibrate",
21
+ ...Array.from({ length: 8 }, (_, k) => press("KeyS", c0 + (k + 1) * BEAT + late)),
22
+ `${(c0 + 2.1 * BEAT).toFixed(3)}:dump_entity:stem-click3:click.json`,
23
+ `${(c0 + 8.6 * BEAT).toFixed(3)}:get:Game:measured.json`,
24
+ `${(c0 + 8.6 * BEAT).toFixed(3)}:screenshot:calibrate.png`,
25
+ tap("Done", 5.9),
26
+ "6.5:get:Game:done.json",
27
+ "6.5:get:Prefs:prefs.json",
28
+ "6.5:dump_platform:platform.json",
29
+ "7.0:play",
30
+ ...play(notes, t0, 0, 8, late),
31
+ `${(t0 + 7.9 * BEAT).toFixed(3)}:get:Game:played.json`,
32
+ `${(t0 + 8 * BEAT).toFixed(3)}:quit`,
33
+ ]),
34
+ check(run, t) {
35
+ t.equal(run.warnings.join("; "), "", "the script ran without warnings");
36
+ const click = run.json<Src>("click.json").components["og.AudioSource"].startAt;
37
+ t.ok(Math.abs((click - c0) / BEAT - Math.round((click - c0) / BEAT)) < 1e-6, `the clicks are started on the beats (${click.toFixed(3)} s)`);
38
+ const m = game(run, "measured.json");
39
+ t.equal(m.calTaps, 8, "eight taps measured");
40
+ t.ok(Math.abs(m.calSum / 8 - late * 1000) < 0.5, `each ${(late * 1000).toFixed(1)} ms after its click (${(m.calSum / 8).toFixed(1)})`);
41
+ t.equal(game(run, "done.json").phase, TITLE, "Done went back to the title");
42
+ const prefs = run.json<{ value: { offsetMs: number } }>("prefs.json").value;
43
+ t.equal(prefs.offsetMs, 67, "the offset is 67 ms");
44
+ const pd = run.json<PlatformDump>("platform.json");
45
+ t.ok(pd.calls.some((c) => c.method === "store.set" && (c.args["value"] as { offsetMs?: number } | undefined)?.offsetMs === 67), "and was saved with the settings");
46
+ const p = game(run, "played.json");
47
+ t.equal(p.perfect, 8, "eight presses 67 ms late were all Perfect");
48
+ },
49
+ });
@@ -0,0 +1,51 @@
1
+ // The song's end and its results: from bar 21 (`play:21`, the earlier
2
+ // notes skipped) every note is hit on time, the last chord on all three
3
+ // lanes; a beat and a half later the results: cleared, grade S, 100 %
4
+ // accuracy, the score, the best kept at the revision read and submitted to
5
+ // the board, the play reported; Play again starts over from bar 1.
6
+ import { playtest } from "@origingame/engine/playtest";
7
+ import { chart, game, PLAY, type PlatformDump, play, RESULTS, songStart, sorted, tap, text } from "./lib.ts";
8
+
9
+ const notes = chart();
10
+ const t0 = songStart(1.0, 21);
11
+ const last = notes[notes.length - 1]!.beat;
12
+ const end = t0 + last * 0.5;
13
+
14
+ export default playtest({
15
+ name: "bar 21 to the end hit on time: cleared, grade S, the best kept and submitted, Play again",
16
+ commands: sorted([
17
+ "1.0:play:21",
18
+ ...play(notes, t0, 80, last + 1),
19
+ `${(end + 0.2).toFixed(3)}:get:Game:last.json`,
20
+ `${(end + 2.4).toFixed(3)}:get:Game:results.json`,
21
+ `${(end + 2.4).toFixed(3)}:dump_ui:results-ui.json`,
22
+ `${(end + 2.4).toFixed(3)}:dump_platform:platform.json`,
23
+ `${(end + 2.45).toFixed(3)}:screenshot:results.png`,
24
+ tap("Again", +(end + 2.6).toFixed(3)),
25
+ `${(end + 3.2).toFixed(3)}:get:Game:again.json`,
26
+ `${(end + 3.3).toFixed(3)}:quit`,
27
+ ]),
28
+ check(run, t) {
29
+ t.equal(run.warnings.join("; "), "", "the script ran without warnings");
30
+ const expected = notes.filter((n) => n.beat >= 80).length;
31
+ const l = game(run, "last.json");
32
+ t.equal(l.notes, expected, `bar 21 on holds ${expected} notes`);
33
+ t.equal(l.perfect, expected, "every one Perfect");
34
+ t.equal(l.cleared, true, "the song is cleared");
35
+ t.equal(l.phase, PLAY, "the results wait a beat and a half");
36
+ const r = game(run, "results.json");
37
+ t.equal(r.phase, RESULTS, "then the results");
38
+ t.equal(text(run, "results-ui.json", "Letter"), "S", "grade S");
39
+ t.equal(text(run, "results-ui.json", "Value", "Accuracy"), "100%", "100 % accuracy");
40
+ t.equal(text(run, "results-ui.json", "Value", "Score"), `${r.score}`, "the score");
41
+ t.equal(r.newBest, true, "a new best");
42
+ const p = run.json<PlatformDump>("platform.json");
43
+ const best = p.calls.find((c) => c.method === "store.set" && c.args["key"] === "best");
44
+ t.equal(best?.args["value"], r.score, "the best was written");
45
+ t.equal(best?.result?.ok, true, "at the revision read");
46
+ t.ok(p.calls.some((c) => c.method === "leaderboard.submit" && c.args["score"] === r.score), "and submitted to the board");
47
+ t.ok(p.calls.some((c) => c.method === "telemetry" && c.args["name"] === "song.over"), "the play was reported");
48
+ const a = game(run, "again.json");
49
+ t.ok(a.phase === PLAY && a.score === 0 && a.judged === 0 && a.notes === notes.length, "Play again started over from bar 1");
50
+ },
51
+ });
@@ -0,0 +1,40 @@
1
+ // The failure path: nothing is pressed; every note let past drains the
2
+ // groove a tenth; the fifth Miss empties it from its half: the song fails
3
+ // (a falling tone, the band stops) and the results say so, without a
4
+ // grade or a best.
5
+ import { playtest } from "@origingame/engine/playtest";
6
+ import { chart, game, PLAY, RESULTS, songStart, sorted, text } from "./lib.ts";
7
+
8
+ const notes = chart();
9
+ const t0 = songStart(1.0);
10
+ const fifth = notes[4]!.beat;
11
+
12
+ export default playtest({
13
+ name: "five notes let pass empty the groove: the song fails and the results say so",
14
+ commands: sorted([
15
+ "1.0:play",
16
+ `${(t0 + notes[2]!.beat * 0.5 + 0.2).toFixed(3)}:get:Game:three.json`,
17
+ `${(t0 + fifth * 0.5 + 0.2).toFixed(3)}:get:Game:failed.json`,
18
+ `${(t0 + fifth * 0.5 + 0.25).toFixed(3)}:dump_entity:stem-drums:drums.json`,
19
+ `${(t0 + fifth * 0.5 + 2.2).toFixed(3)}:get:Game:results.json`,
20
+ `${(t0 + fifth * 0.5 + 2.2).toFixed(3)}:dump_ui:results-ui.json`,
21
+ `${(t0 + fifth * 0.5 + 2.25).toFixed(3)}:screenshot:failed.png`,
22
+ `${(t0 + fifth * 0.5 + 2.3).toFixed(3)}:quit`,
23
+ ]),
24
+ check(run, t) {
25
+ t.equal(run.warnings.join("; "), "", "the script ran without warnings");
26
+ const three = game(run, "three.json");
27
+ t.equal(three.miss, 3, "three notes passed: three Misses");
28
+ t.ok(Math.abs(three.groove - 0.2) < 1e-4, `the groove fell from 0.5 to 0.2 (${three.groove.toFixed(3)})`);
29
+ t.equal(three.phase, PLAY, "still playing");
30
+ const f = game(run, "failed.json");
31
+ t.equal(f.failed, true, "the fifth Miss emptied the groove: failed");
32
+ t.equal(f.groove, 0, "the groove is empty");
33
+ t.equal(run.json<{ components: { "og.AudioSource": { playing: boolean } } }>("drums.json").components["og.AudioSource"].playing, false, "the band stopped");
34
+ const r = game(run, "results.json");
35
+ t.equal(r.phase, RESULTS, "the results came up");
36
+ t.equal(text(run, "results-ui.json", "Title", "Panel"), "The groove slipped away", "they say the groove slipped away");
37
+ t.equal(text(run, "results-ui.json", "Letter"), "–", "with no grade");
38
+ t.equal(r.newBest, false, "and no best");
39
+ },
40
+ });
@@ -0,0 +1,54 @@
1
+ // The core loop through real input: Play on the title starts the count-in
2
+ // (four clicks, 4 3 2 1), then bar 1. The first two bars' eight notes are
3
+ // hit with A S D on their times: eight Perfects, a combo of 8, 2,400
4
+ // points, the groove rising. Bar 3's first note is hit 80 ms late (Great,
5
+ // late), its second 120 ms early (Good, early), its third and fourth let
6
+ // pass (two Misses, the combo broken); a press with no note near is only a
7
+ // sound.
8
+ import { playtest } from "@origingame/engine/playtest";
9
+ import { BEAT, chart, game, KEYS, PLAY, play, press, songStart, sorted, tap, TITLE } from "./lib.ts";
10
+
11
+ const notes = chart();
12
+ const t0 = songStart(1.05);
13
+ const bar3 = notes.filter((n) => n.beat >= 8 && n.beat < 12);
14
+
15
+ export default playtest({
16
+ name: "Play, the count-in, perfect hits, a late Great, an early Good, misses and an empty press",
17
+ commands: sorted([
18
+ "0.3:get:Game:title.json",
19
+ tap("play", 1.0),
20
+ `${(t0 - 1.0).toFixed(3)}:get:Game:count.json`,
21
+ ...play(notes, t0, 0, 8),
22
+ `${(t0 + 7.8 * BEAT).toFixed(3)}:get:Game:perfect.json`,
23
+ `${(t0 + 7.8 * BEAT).toFixed(3)}:screenshot:play.png`,
24
+ press(KEYS[bar3[0]!.lane]!, t0 + bar3[0]!.beat * BEAT + 0.08),
25
+ press(KEYS[bar3[1]!.lane]!, t0 + bar3[1]!.beat * BEAT - 0.12),
26
+ `${(t0 + 9.6 * BEAT).toFixed(3)}:get:Game:early.json`,
27
+ press("KeyS", t0 + 10.5 * BEAT),
28
+ `${(t0 + 11.6 * BEAT).toFixed(3)}:get:Game:missed.json`,
29
+ `${(t0 + 11.7 * BEAT).toFixed(3)}:quit`,
30
+ ]),
31
+ check(run, t) {
32
+ t.equal(run.warnings.join("; "), "", "the script ran without warnings");
33
+ t.ok(run.quit, "the script reached quit");
34
+ t.equal(game(run, "title.json").phase, TITLE, "the game opens on the title");
35
+ const count = game(run, "count.json");
36
+ t.equal(count.phase, PLAY, "Play started the count-in");
37
+ t.ok(Math.abs(count.songStart - t0) < 1e-6, `bar 1 starts at ${t0.toFixed(3)} s, four beats after the next tick`);
38
+ const p = game(run, "perfect.json");
39
+ t.equal(p.perfect, 8, "the first two bars' eight notes were Perfect");
40
+ t.equal(p.combo, 8, "a combo of 8");
41
+ t.equal(p.score, 8 * 300, "300 each at ×1");
42
+ t.ok(p.groove > 0.5, `the groove rose (${p.groove.toFixed(2)})`);
43
+ const e = game(run, "early.json");
44
+ t.equal(e.great, 1, "80 ms late was Great");
45
+ t.equal(e.good, 1, "120 ms early was Good");
46
+ t.equal(e.combo, 10, "the combo went on: 10");
47
+ const m = game(run, "missed.json");
48
+ t.equal(m.miss, 2, "the two notes let pass were Misses");
49
+ t.equal(m.combo, 0, "the combo broke");
50
+ t.equal(m.judged, 12, "twelve notes judged; the empty press judged nothing");
51
+ t.equal(m.taps, 11, "eleven presses heard");
52
+ t.frame("play.png", () => t.equal(run.png("play.png").width, 1280, "play.png captured"));
53
+ },
54
+ });