@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,404 @@
1
+ #!/usr/bin/env python3
2
+ """Regenerates the match3 archetype's self-made assets (CC0), byte for byte:
3
+
4
+ python3 tools/make-assets.py # from the archetype directory
5
+
6
+ - assets/sprites/gems.png + gems.ogt: the gem flipbook, one row per colour
7
+ (idle with a glint after a long hold, a clear burst), lossless,
8
+ - assets/sprites/panel.png (the board's nine-slice backing), backdrop.png
9
+ and ring.png (the selection frame),
10
+ - assets/sprites/cells.png + cells.ogt + board.ogt: the checker tileset and
11
+ the 7 x 7 tilemap under the gems,
12
+ - assets/audio/*.wav: select, swap, refused, clear, cascade, won and lost,
13
+ - assets/fonts/ui.ttf (+ ui.ttf.ogt): Noto Sans SC subset to Latin-1 and the
14
+ HUD's characters (needs fontTools and the project template's font; skipped
15
+ with a note when either is missing, since the committed subset is there).
16
+
17
+ Standard library only except the font subset; deterministic.
18
+ """
19
+ import math, os, sys
20
+
21
+ here = os.path.dirname(os.path.abspath(__file__))
22
+ sys.path.insert(0, here)
23
+ from oglite import Canvas, hex_rgb, png_bytes, write_wav, tone, noise, mix, concat, subset_font # noqa: E402
24
+
25
+ root = os.path.dirname(here)
26
+ assets = os.path.join(root, "assets")
27
+
28
+
29
+ INK = "#14161b" # the brand ink: the backdrop, the panel's shadow and the gems' outlines
30
+
31
+
32
+ def blank(w, h):
33
+ return Canvas(w, h)
34
+
35
+
36
+ def mixc(a, b, t):
37
+ """Mix two #rrggbb colours."""
38
+ ra, ga, ba = hex_rgb(a)
39
+ rb, gb, bb = hex_rgb(b)
40
+ return "#%02x%02x%02x" % tuple(round(x + (y - x) * t) for x, y in ((ra, rb), (ga, gb), (ba, bb)))
41
+
42
+
43
+ def inside_poly(pts):
44
+ def inside(px, py):
45
+ c = False
46
+ j = len(pts) - 1
47
+ for i in range(len(pts)):
48
+ xi, yi = pts[i]; xj, yj = pts[j]
49
+ if (yi > py) != (yj > py) and px < (xj - xi) * (py - yi) / (yj - yi) + xi:
50
+ c = not c
51
+ j = i
52
+ return c
53
+ return inside
54
+
55
+
56
+ def paint_where(c, inside, colour, alpha=1.0):
57
+ c._paint(inside, (0, 0, c.w, c.h), colour, alpha)
58
+
59
+
60
+ # ── the gems: six colours, six cuts, so colour is never the only cue ─────
61
+
62
+ GEMS = [
63
+ # name, body, dark, light, cut
64
+ ("ruby", "#ff3048", "#a3122a", "#ff9aa6", "round"),
65
+ ("sky", "#2c8bff", "#1449a8", "#9fd0ff", "emerald"),
66
+ ("leaf", "#25d36a", "#0f7a3a", "#a4f5c2", "trillion"),
67
+ ("sun", "#ffc414", "#b57800", "#fff0a0", "kite"),
68
+ ("plum", "#b057ff", "#5f22a8", "#e2bcff", "hex"),
69
+ ("coral", "#ff7424", "#ad3b00", "#ffc49a", "star"),
70
+ ]
71
+
72
+ FRAME = 80 # px per frame (the gem sits in it with a margin)
73
+ FRAMES = 8 # per colour: 0 idle, 1-3 the glint, 4-7 the clear burst
74
+ GLINT = (1, 2, 3)
75
+ BURST = (4, 5, 6, 7)
76
+
77
+
78
+ def cut(name, cx, cy, r):
79
+ """The outline of a cut, clockwise from the top (pixels, y down)."""
80
+ def ring(n, rot, rad=r):
81
+ return [(cx + rad * math.cos(rot + i * 2 * math.pi / n), cy + rad * math.sin(rot + i * 2 * math.pi / n)) for i in range(n)]
82
+ if name == "round":
83
+ return ring(12, -math.pi / 2)
84
+ if name == "emerald": # a square with clipped corners
85
+ k = r * 0.82; s = r * 0.38
86
+ return [(cx - k + s, cy - k), (cx + k - s, cy - k), (cx + k, cy - k + s), (cx + k, cy + k - s),
87
+ (cx + k - s, cy + k), (cx - k + s, cy + k), (cx - k, cy + k - s), (cx - k, cy - k + s)]
88
+ if name == "trillion":
89
+ return ring(3, -math.pi / 2, r * 1.12)
90
+ if name == "kite":
91
+ return [(cx, cy - r * 1.05), (cx + r * 0.78, cy - r * 0.1), (cx, cy + r * 1.05), (cx - r * 0.78, cy - r * 0.1)]
92
+ if name == "hex":
93
+ return ring(6, -math.pi / 2)
94
+ pts = [] # star
95
+ for i in range(10):
96
+ rad = r * (1.08 if i % 2 == 0 else 0.5)
97
+ a = -math.pi / 2 + i * math.pi / 5
98
+ pts.append((cx + rad * math.cos(a), cy + rad * math.sin(a)))
99
+ return pts
100
+
101
+
102
+ def scaled(pts, cx, cy, k, dy=0.0):
103
+ return [(cx + (x - cx) * k, cy + (y - cy) * k + dy) for x, y in pts]
104
+
105
+
106
+ def gem(c, spec, cx, cy, r, bright=0.0):
107
+ """A faceted gem: an ink rim, facets lit from the top left, a table, a highlight."""
108
+ _, body, dark, light, name = spec
109
+ if bright:
110
+ body, dark, light = mixc(body, "#ffffff", bright), mixc(dark, "#ffffff", bright), mixc(light, "#ffffff", bright)
111
+ outer = cut(name, cx, cy, r)
112
+ c.poly(scaled(outer, cx, cy, 1.0, 3.0), INK, 0.55) # its shadow on the cell
113
+ c.poly(scaled(outer, cx, cy, 1.09), INK) # the rim
114
+ c.poly(outer, body)
115
+ table = scaled(outer, cx, cy - r * 0.06, 0.56)
116
+ lx, ly = -0.62, -0.78 # towards the light
117
+ n = len(outer)
118
+ for i in range(n):
119
+ a, b = outer[i], outer[(i + 1) % n]
120
+ ta, tb = table[i], table[(i + 1) % n]
121
+ mx, my = (a[0] + b[0]) / 2 - cx, (a[1] + b[1]) / 2 - cy
122
+ ln = math.hypot(mx, my) or 1.0
123
+ lit = (mx * lx + my * ly) / ln # -1 away from the light, 1 facing it
124
+ col = mixc(body, light, lit * 0.75) if lit > 0 else mixc(body, dark, -lit * 0.7)
125
+ c.poly([a, b, tb, ta], col)
126
+ c.poly(table, mixc(body, light, 0.35))
127
+ c.poly(scaled(table, cx, cy, 0.55, -r * 0.08), mixc(body, light, 0.6), 0.7)
128
+ c.ellipse(cx - r * 0.3, cy - r * 0.42, r * 0.2, r * 0.12, "#ffffff", 0.75)
129
+ return outer
130
+
131
+
132
+ def sparkle(c, x, y, s, alpha=1.0):
133
+ c.poly([(x, y - s), (x + s * 0.22, y - s * 0.22), (x + s, y), (x + s * 0.22, y + s * 0.22),
134
+ (x, y + s), (x - s * 0.22, y + s * 0.22), (x - s, y), (x - s * 0.22, y - s * 0.22)], "#ffffff", alpha)
135
+
136
+
137
+ def gem_frame(spec, f):
138
+ c = blank(FRAME, FRAME)
139
+ cx = cy = FRAME / 2
140
+ r = FRAME * 0.36
141
+ if f == 0 or f in GLINT:
142
+ outer = gem(c, spec, cx, cy, r)
143
+ if f in GLINT:
144
+ # A diagonal band of light sweeping across the gem, kept inside its outline.
145
+ t = (f - GLINT[0] + 0.5) / len(GLINT)
146
+ inside = inside_poly(outer)
147
+ u0 = -0.6 + 1.2 * t
148
+ band = lambda px, py: inside(px, py) and abs(((px - cx) + (py - cy)) / (2 * r) - u0) < 0.16
149
+ paint_where(c, band, "#ffffff", 0.7)
150
+ if f == GLINT[1]:
151
+ sparkle(c, cx + r * 0.45, cy - r * 0.55, r * 0.42)
152
+ return c
153
+ k = f - BURST[0] # 0..3: a white-hot gem, then it breaks into a ring and shards
154
+ if k == 0:
155
+ gem(c, spec, cx, cy, r * 1.06, bright=0.55)
156
+ sparkle(c, cx, cy, r * 0.9, 0.9)
157
+ return c
158
+ _, body, _, light, name = spec
159
+ spread = (0.0, 0.55, 0.85, 1.05)[k]
160
+ fade = (1.0, 0.95, 0.7, 0.35)[k]
161
+ rr = r * (0.55 + 0.22 * k)
162
+ c.ring(cx, cy, rr, max(2.0, 7 - 2 * k), light, fade)
163
+ for i in range(6):
164
+ a = -math.pi / 2 + i * math.pi / 3 + 0.3
165
+ d = r * spread
166
+ x, y = cx + d * math.cos(a), cy + d * math.sin(a)
167
+ s = r * (0.36 - 0.07 * k)
168
+ shard = cut(name, x, y, s)
169
+ c.poly(scaled(shard, x, y, 1.15), INK, fade)
170
+ c.poly(shard, body if i % 2 == 0 else light, fade)
171
+ if k < 3:
172
+ sparkle(c, cx, cy, r * (0.5 - 0.12 * k), fade)
173
+ return c
174
+
175
+
176
+ def gem_sheet():
177
+ """gems.png: one row per colour, FRAMES frames across."""
178
+ w, h = FRAME * FRAMES, FRAME * len(GEMS)
179
+ rows = [bytearray(w * 4) for _ in range(h)]
180
+ for gi, spec in enumerate(GEMS):
181
+ for f in range(FRAMES):
182
+ fr = gem_frame(spec, f).rgba()
183
+ for y in range(FRAME):
184
+ rows[gi * FRAME + y][f * FRAME * 4:(f + 1) * FRAME * 4] = fr[y]
185
+ return png_bytes(w, h, rows)
186
+
187
+
188
+ def gem_flipbook():
189
+ """gems.ogt: idle_<colour> loops the glint after a long hold, clear_<colour> bursts once."""
190
+ lines = [
191
+ "type flipbook",
192
+ "version 1",
193
+ "---",
194
+ "# Written by tools/make-assets.py. Clip 2c is colour c's idle loop, 2c + 1 its clear",
195
+ "# burst (src/art.ts relies on that order).",
196
+ 'texture "gems.png"',
197
+ "filter linear",
198
+ "pivot 0.5 0.5",
199
+ f"grid {FRAME} {FRAME} {FRAMES} {len(GEMS)}",
200
+ ]
201
+ for gi, (name, *_rest) in enumerate(GEMS):
202
+ base = gi * FRAMES
203
+ idle = " ".join(str(base + f) for f in (0,) + GLINT)
204
+ burst = " ".join(str(base + f) for f in BURST)
205
+ lines += [
206
+ f"clip idle_{name} {{",
207
+ f" frames {idle}",
208
+ " durations 2.4 0.05 0.06 0.05",
209
+ " mode loop",
210
+ "}",
211
+ f"clip clear_{name} {{",
212
+ f" frames {burst}",
213
+ " fps 24",
214
+ " mode once",
215
+ ' event 1 "burst"',
216
+ "}",
217
+ ]
218
+ return "\n".join(lines) + "\n"
219
+
220
+
221
+ # ── the board and the frame ───────────────────────────────────────────────
222
+
223
+ PANEL = 96
224
+ PANEL_INSET = 32 # nine-slice insets in px, every side
225
+
226
+
227
+ def panel():
228
+ """The board's backing, drawn nine-sliced: a soft ink shadow, a rim catching the light, a dark well."""
229
+ c = blank(PANEL, PANEL)
230
+ c.rect(2, 6, 92, 88, "#08090c", radius=26, alpha=0.8)
231
+ c.rect(2, 2, 92, 90, "#2a2f3c", radius=26)
232
+ c.rect(4, 5, 88, 86, "#0e1015", radius=24)
233
+ c.rect(7, 8, 82, 80, "#111318", radius=21)
234
+ return c
235
+
236
+
237
+ def backdrop():
238
+ """A quiet lift of the light behind the board, fading to nothing at its edge (the ink
239
+ around it is the camera's background): a tiny smooth image the sampler stretches."""
240
+ n = 16
241
+ rows = []
242
+ lift = hex_rgb("#262b3b")
243
+ for y in range(n):
244
+ row = bytearray()
245
+ for x in range(n):
246
+ d = min(1.0, math.hypot((x + 0.5) / n - 0.5, (y + 0.5) / n - 0.5) / 0.5)
247
+ t = 1 - d * d * (3 - 2 * d)
248
+ row += bytes(lift) + bytes([round(255 * 0.55 * t)])
249
+ rows.append(bytes(row))
250
+ return png_bytes(n, n, rows)
251
+
252
+
253
+ def ring():
254
+ """The selection frame: a warm rounded square outline with a faint inner glow."""
255
+ n = 96
256
+ c = blank(n, n)
257
+ c.rect(3, 3, 90, 90, "#ffd76a", radius=22, alpha=0.25)
258
+ c.rect(4, 4, 88, 88, "#fff1c2", radius=21)
259
+ lo, hi, rad = 11, 85, 15
260
+ for i, p in enumerate(c.px):
261
+ x, y = i % n + 0.5, i // n + 0.5
262
+ if lo <= x < hi and lo <= y < hi:
263
+ qx = min(max(x, lo + rad), hi - rad)
264
+ qy = min(max(y, lo + rad), hi - rad)
265
+ d = math.hypot(x - qx, y - qy)
266
+ if d <= rad:
267
+ keep = 0.18 * max(0.0, 1 - (min(x - lo, hi - x, y - lo, hi - y)) / 10)
268
+ for j in range(4):
269
+ p[j] *= keep
270
+ return c
271
+
272
+
273
+ TILE = 64 # px per checker cell
274
+
275
+
276
+ def cells():
277
+ """cells.png: two checker cells (a tileset of 2 x 1)."""
278
+ c = blank(TILE * 2, TILE)
279
+ c.rect(2, 2, TILE - 4, TILE - 4, "#1c1f28", radius=9)
280
+ c.rect(2, 2, TILE - 4, 6, "#232733", radius=9, alpha=0.6)
281
+ c.rect(TILE + 2, 2, TILE - 4, TILE - 4, "#171a21", radius=9)
282
+ c.rect(TILE + 2, 2, TILE - 4, 6, "#1d2029", radius=9, alpha=0.6)
283
+ return c
284
+
285
+
286
+ def cells_tileset():
287
+ return "\n".join([
288
+ "type tileset",
289
+ "version 1",
290
+ "---",
291
+ "# Written by tools/make-assets.py: the board's two checker cells.",
292
+ 'texture "sprites/cells.png"',
293
+ f"grid {TILE} {TILE} 2 1",
294
+ "filter nearest",
295
+ ]) + "\n"
296
+
297
+
298
+ def board_map(size=7):
299
+ rows = []
300
+ for y in range(size):
301
+ rows.append(' row "' + "".join("ab"[(x + y) % 2] for x in range(size)) + '"')
302
+ return "\n".join([
303
+ "type tilemap",
304
+ "version 1",
305
+ "---",
306
+ "# Written by tools/make-assets.py: the 7 x 7 checker under the gems, one world unit a cell;",
307
+ "# src/main.ts places its top-left corner at the board's.",
308
+ f"size {size} {size}",
309
+ f"tile {TILE} {TILE}",
310
+ "unit 1",
311
+ 'tileset "sprites/cells.ogt"',
312
+ "layer cells {",
313
+ " z 0",
314
+ ' legend "a" 0',
315
+ ' legend "b" 1',
316
+ *rows,
317
+ "}",
318
+ ]) + "\n"
319
+
320
+
321
+ PIXEL_IMPORT = """type import
322
+ version 1
323
+ ---
324
+ # Written by tools/make-assets.py: lossless RGBA8 ({why}).
325
+ texture {{
326
+ kind pixel
327
+ }}
328
+ """
329
+
330
+
331
+ CHARS = "三消开始游戏点击或拖动交换相邻方块连成同色分数步数目标胜利失败再来一次剩余最高"
332
+
333
+ FONT_IMPORT = """type import
334
+ version 1
335
+ ---
336
+ # Written by tools/make-assets.py: the atlas holds Latin-1 and the HUD's own
337
+ # CJK characters (CHARS there); add a character to CHARS before showing it.
338
+ font {{
339
+ charset latin
340
+ chars "{chars}"
341
+ em_px 48
342
+ px_range 6
343
+ }}
344
+ """
345
+
346
+
347
+ def main():
348
+ sprites = os.path.join(assets, "sprites")
349
+ os.makedirs(sprites, exist_ok=True)
350
+ preview = os.environ.get("OG_SPRITE_PREVIEW")
351
+
352
+ def png(name, data, why=None):
353
+ open(os.path.join(sprites, name), "wb").write(data)
354
+ if why:
355
+ with open(os.path.join(sprites, name + ".ogt"), "w") as f:
356
+ f.write(PIXEL_IMPORT.format(why=why))
357
+ if preview:
358
+ os.makedirs(preview, exist_ok=True)
359
+ open(os.path.join(preview, name), "wb").write(data)
360
+
361
+ def canvas_png(name, canvas, why=None):
362
+ png(name, png_bytes(canvas.w, canvas.h, canvas.rgba()), why)
363
+
364
+ # The gem sheet is a colour texture (filtered, with mips), not `kind pixel`: the runtime
365
+ # samples a pixel-kind texture nearest even when its flipbook says `filter linear`.
366
+ png("gems.png", gem_sheet())
367
+ with open(os.path.join(sprites, "gems.ogt"), "w") as f:
368
+ f.write(gem_flipbook())
369
+ canvas_png("panel.png", panel())
370
+ png("backdrop.png", backdrop())
371
+ canvas_png("ring.png", ring())
372
+ canvas_png("cells.png", cells(), "a tileset, drawn one texel to a pixel")
373
+ with open(os.path.join(sprites, "cells.ogt"), "w") as f:
374
+ f.write(cells_tileset())
375
+ with open(os.path.join(sprites, "board.ogt"), "w") as f:
376
+ f.write(board_map())
377
+
378
+ a = os.path.join(assets, "audio")
379
+ os.makedirs(a, exist_ok=True)
380
+ write_wav(os.path.join(a, "select.wav"), tone(0.08, 880, shape="tri", decay=0.04, gain=0.35))
381
+ write_wav(os.path.join(a, "swap.wav"), tone(0.14, 440, 660, shape="tri", decay=0.07, gain=0.35))
382
+ write_wav(os.path.join(a, "refused.wav"), concat(tone(0.08, 220, shape="square", decay=0.05, gain=0.25),
383
+ tone(0.12, 185, shape="square", decay=0.06, gain=0.25)))
384
+ write_wav(os.path.join(a, "clear.wav"), mix(tone(0.3, 660, 1320, shape="sine", decay=0.12, gain=0.4),
385
+ noise(0.12, decay=0.03, gain=0.15, seed=3)))
386
+ write_wav(os.path.join(a, "cascade.wav"), concat(tone(0.08, 784, shape="tri", decay=0.05, gain=0.35),
387
+ tone(0.08, 988, shape="tri", decay=0.05, gain=0.35),
388
+ tone(0.16, 1175, shape="tri", decay=0.08, gain=0.35)))
389
+ write_wav(os.path.join(a, "won.wav"), concat(*[tone(0.12, f, shape="tri", decay=0.1, gain=0.4) for f in (523, 659, 784, 1047)]))
390
+ write_wav(os.path.join(a, "lost.wav"), concat(*[tone(0.18, f, shape="tri", decay=0.12, gain=0.4) for f in (392, 330, 262)]))
391
+
392
+ fonts = os.path.join(assets, "fonts")
393
+ os.makedirs(fonts, exist_ok=True)
394
+ font_src = os.path.join(root, "..", "..", "game", "assets", "fonts", "NotoSansSC-Regular-subset.ttf")
395
+ try:
396
+ subset_font(font_src, os.path.join(fonts, "ui.ttf"), CHARS)
397
+ except Exception as e: # noqa: BLE001
398
+ print(f"font subset skipped ({e}); the committed assets/fonts/ui.ttf stays")
399
+ with open(os.path.join(fonts, "ui.ttf.ogt"), "w") as f:
400
+ f.write(FONT_IMPORT.format(chars=CHARS))
401
+
402
+
403
+ if __name__ == "__main__":
404
+ main()
@@ -0,0 +1,285 @@
1
+ """A tiny, standard-library-only sprite kit for Origin Engine archetypes.
2
+
3
+ It draws antialiased vector shapes into RGBA images (4x4 supersampling),
4
+ writes PNGs, packs sprites into one glTF binary (.glb) of unit quads, one
5
+ mesh and one emissive, alpha-masked material per sprite, and writes 16-bit
6
+ WAV sounds. Everything is a pure function of its inputs, so the assets it
7
+ makes are byte-for-byte reproducible.
8
+
9
+ A sprite quad lies in the xy plane facing +z, 1 x 1 units, centred on the
10
+ origin, with uv (0,0) at the image's top left. Its material is black base
11
+ colour (alpha from the image, for the mask), roughness 1, and the image as
12
+ the emissive texture: with no light, no environment and tone mapping off,
13
+ the frame shows the image's colours exactly.
14
+ """
15
+ import json, math, struct, wave, zlib
16
+
17
+ SS = 4 # supersamples per axis
18
+
19
+
20
+ def hex_rgb(h):
21
+ h = h.lstrip("#")
22
+ return tuple(int(h[i:i + 2], 16) for i in (0, 2, 4))
23
+
24
+
25
+ class Canvas:
26
+ """An RGBA canvas; shapes are painted in order with coverage antialiasing.
27
+ Coordinates are in pixels, origin top left, y down."""
28
+
29
+ def __init__(self, w, h):
30
+ self.w, self.h = w, h
31
+ self.px = [[0.0, 0.0, 0.0, 0.0] for _ in range(w * h)] # premultiplied
32
+
33
+ def _paint(self, inside, bbox, colour, alpha=1.0):
34
+ r, g, b = (c / 255.0 for c in hex_rgb(colour))
35
+ x0, y0, x1, y1 = bbox
36
+ x0 = max(0, int(math.floor(x0))); y0 = max(0, int(math.floor(y0)))
37
+ x1 = min(self.w, int(math.ceil(x1))); y1 = min(self.h, int(math.ceil(y1)))
38
+ n = SS * SS
39
+ for y in range(y0, y1):
40
+ for x in range(x0, x1):
41
+ hits = 0
42
+ for sy in range(SS):
43
+ py = y + (sy + 0.5) / SS
44
+ for sx in range(SS):
45
+ if inside(x + (sx + 0.5) / SS, py):
46
+ hits += 1
47
+ if hits == 0:
48
+ continue
49
+ a = alpha * hits / n
50
+ p = self.px[y * self.w + x]
51
+ p[0] = r * a + p[0] * (1 - a)
52
+ p[1] = g * a + p[1] * (1 - a)
53
+ p[2] = b * a + p[2] * (1 - a)
54
+ p[3] = a + p[3] * (1 - a)
55
+
56
+ def rect(self, x, y, w, h, colour, radius=0.0, alpha=1.0):
57
+ rad = min(radius, w / 2, h / 2)
58
+
59
+ def inside(px, py):
60
+ if px < x or px > x + w or py < y or py > y + h:
61
+ return False
62
+ if rad <= 0:
63
+ return True
64
+ cx = min(max(px, x + rad), x + w - rad)
65
+ cy = min(max(py, y + rad), y + h - rad)
66
+ return (px - cx) ** 2 + (py - cy) ** 2 <= rad * rad
67
+
68
+ self._paint(inside, (x, y, x + w, y + h), colour, alpha)
69
+
70
+ def circle(self, cx, cy, r, colour, alpha=1.0):
71
+ self.ellipse(cx, cy, r, r, colour, alpha)
72
+
73
+ def ellipse(self, cx, cy, rx, ry, colour, alpha=1.0):
74
+ def inside(px, py):
75
+ return ((px - cx) / rx) ** 2 + ((py - cy) / ry) ** 2 <= 1.0
76
+
77
+ self._paint(inside, (cx - rx, cy - ry, cx + rx, cy + ry), colour, alpha)
78
+
79
+ def ring(self, cx, cy, r, width, colour, alpha=1.0):
80
+ def inside(px, py):
81
+ d = math.hypot(px - cx, py - cy)
82
+ return r - width <= d <= r
83
+
84
+ self._paint(inside, (cx - r, cy - r, cx + r, cy + r), colour, alpha)
85
+
86
+ def poly(self, pts, colour, alpha=1.0):
87
+ xs = [p[0] for p in pts]; ys = [p[1] for p in pts]
88
+
89
+ def inside(px, py):
90
+ c = False
91
+ j = len(pts) - 1
92
+ for i in range(len(pts)):
93
+ xi, yi = pts[i]; xj, yj = pts[j]
94
+ if (yi > py) != (yj > py) and px < (xj - xi) * (py - yi) / (yj - yi) + xi:
95
+ c = not c
96
+ j = i
97
+ return c
98
+
99
+ self._paint(inside, (min(xs), min(ys), max(xs), max(ys)), colour, alpha)
100
+
101
+ def line(self, x0, y0, x1, y1, width, colour, alpha=1.0):
102
+ dx, dy = x1 - x0, y1 - y0
103
+ ln = math.hypot(dx, dy) or 1.0
104
+ nx, ny = -dy / ln * width / 2, dx / ln * width / 2
105
+ self.poly([(x0 + nx, y0 + ny), (x1 + nx, y1 + ny), (x1 - nx, y1 - ny), (x0 - nx, y0 - ny)], colour, alpha)
106
+ self.circle(x0, y0, width / 2, colour, alpha)
107
+ self.circle(x1, y1, width / 2, colour, alpha)
108
+
109
+ def rgba(self):
110
+ """Straight-alpha RGBA8 rows. Transparent pixels take the colour of
111
+ the nearest painted pixel (a few dilation passes), so filtering and
112
+ mips never pull a dark fringe into the edge."""
113
+ w, h = self.w, self.h
114
+ col = [None] * (w * h)
115
+ for i, p in enumerate(self.px):
116
+ if p[3] > 0:
117
+ col[i] = (p[0] / p[3], p[1] / p[3], p[2] / p[3])
118
+ for _ in range(8):
119
+ nxt = list(col)
120
+ changed = False
121
+ for y in range(h):
122
+ for x in range(w):
123
+ i = y * w + x
124
+ if col[i] is not None:
125
+ continue
126
+ for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)):
127
+ xx, yy = x + dx, y + dy
128
+ if 0 <= xx < w and 0 <= yy < h and col[yy * w + xx] is not None:
129
+ nxt[i] = col[yy * w + xx]
130
+ changed = True
131
+ break
132
+ col = nxt
133
+ if not changed:
134
+ break
135
+ rows = []
136
+ for y in range(h):
137
+ row = bytearray()
138
+ for x in range(w):
139
+ i = y * w + x
140
+ c = col[i] or (0.0, 0.0, 0.0)
141
+ a = self.px[i][3]
142
+ row += bytes([round(min(1, max(0, c[0])) * 255), round(min(1, max(0, c[1])) * 255),
143
+ round(min(1, max(0, c[2])) * 255), round(min(1, max(0, a)) * 255)])
144
+ rows.append(bytes(row))
145
+ return rows
146
+
147
+
148
+ def png_bytes(w, h, rows):
149
+ raw = b"".join(b"\x00" + r for r in rows)
150
+
151
+ def chunk(t, d):
152
+ return struct.pack(">I", len(d)) + t + d + struct.pack(">I", zlib.crc32(t + d) & 0xFFFFFFFF)
153
+
154
+ return (b"\x89PNG\r\n\x1a\n" + chunk(b"IHDR", struct.pack(">IIBBBBB", w, h, 8, 6, 0, 0, 0))
155
+ + chunk(b"IDAT", zlib.compress(raw, 9)) + chunk(b"IEND", b""))
156
+
157
+
158
+ def write_glb(path, sprites):
159
+ """sprites: list of (name, png bytes, masked). One quad mesh per sprite,
160
+ in list order: GltfInfo.geometries[i] and materials[i] are sprite i."""
161
+ bin_ = bytearray()
162
+
163
+ def add(data, align=4):
164
+ while len(bin_) % align:
165
+ bin_.append(0)
166
+ off = len(bin_)
167
+ bin_.extend(data)
168
+ return off, len(data)
169
+
170
+ pos = struct.pack("<12f", -0.5, -0.5, 0, 0.5, -0.5, 0, 0.5, 0.5, 0, -0.5, 0.5, 0)
171
+ nrm = struct.pack("<12f", *([0, 0, 1] * 4))
172
+ uv = struct.pack("<8f", 0, 1, 1, 1, 1, 0, 0, 0)
173
+ idx = struct.pack("<6H", 0, 1, 2, 0, 2, 3)
174
+ views, accessors = [], []
175
+ for data, target in ((pos, 34962), (nrm, 34962), (uv, 34962), (idx, 34963)):
176
+ o, n = add(data)
177
+ views.append({"buffer": 0, "byteOffset": o, "byteLength": n, "target": target})
178
+ accessors = [
179
+ {"bufferView": 0, "componentType": 5126, "count": 4, "type": "VEC3", "min": [-0.5, -0.5, 0], "max": [0.5, 0.5, 0]},
180
+ {"bufferView": 1, "componentType": 5126, "count": 4, "type": "VEC3"},
181
+ {"bufferView": 2, "componentType": 5126, "count": 4, "type": "VEC2"},
182
+ {"bufferView": 3, "componentType": 5123, "count": 6, "type": "SCALAR"},
183
+ ]
184
+ images, textures, materials, meshes, nodes = [], [], [], [], []
185
+ for i, (name, data, masked) in enumerate(sprites):
186
+ o, n = add(data)
187
+ views.append({"buffer": 0, "byteOffset": o, "byteLength": n})
188
+ images.append({"bufferView": len(views) - 1, "mimeType": "image/png", "name": name})
189
+ textures.append({"source": i, "sampler": 0})
190
+ m = {
191
+ "name": name,
192
+ "pbrMetallicRoughness": {"baseColorFactor": [0, 0, 0, 1], "baseColorTexture": {"index": i},
193
+ "metallicFactor": 0, "roughnessFactor": 1},
194
+ "emissiveTexture": {"index": i},
195
+ "emissiveFactor": [1, 1, 1],
196
+ }
197
+ if masked:
198
+ m["alphaMode"] = "MASK"
199
+ m["alphaCutoff"] = 0.5
200
+ materials.append(m)
201
+ meshes.append({"name": name, "primitives": [{"attributes": {"POSITION": 0, "NORMAL": 1, "TEXCOORD_0": 2},
202
+ "indices": 3, "material": i}]})
203
+ nodes.append({"name": name, "mesh": i, "translation": [i * 1.2, 0, 0]})
204
+ while len(bin_) % 4:
205
+ bin_.append(0)
206
+ doc = {
207
+ "asset": {"version": "2.0", "generator": "oglite.py"},
208
+ "scene": 0, "scenes": [{"nodes": list(range(len(nodes)))}], "nodes": nodes, "meshes": meshes,
209
+ "materials": materials, "textures": textures, "images": images,
210
+ "samplers": [{"magFilter": 9729, "minFilter": 9987, "wrapS": 33071, "wrapT": 33071}],
211
+ "accessors": accessors, "bufferViews": views, "buffers": [{"byteLength": len(bin_)}],
212
+ }
213
+ js = json.dumps(doc, separators=(",", ":")).encode()
214
+ while len(js) % 4:
215
+ js += b" "
216
+ out = struct.pack("<III", 0x46546C67, 2, 12 + 8 + len(js) + 8 + len(bin_))
217
+ out += struct.pack("<II", len(js), 0x4E4F534A) + js + struct.pack("<II", len(bin_), 0x004E4942) + bytes(bin_)
218
+ with open(path, "wb") as f:
219
+ f.write(out)
220
+
221
+
222
+ def write_wav(path, samples, rate=22050):
223
+ """samples: floats in [-1, 1], mono."""
224
+ with wave.open(path, "wb") as w:
225
+ w.setnchannels(1)
226
+ w.setsampwidth(2)
227
+ w.setframerate(rate)
228
+ w.writeframes(b"".join(struct.pack("<h", int(max(-1, min(1, s)) * 32000)) for s in samples))
229
+
230
+
231
+ def tone(seconds, f0, f1=None, rate=22050, shape="sine", attack=0.005, decay=None, gain=0.6):
232
+ """A sweep from f0 to f1 Hz with a short attack and an exponential decay."""
233
+ f1 = f0 if f1 is None else f1
234
+ n = int(seconds * rate)
235
+ out, phase = [], 0.0
236
+ decay = decay or seconds / 4
237
+ for i in range(n):
238
+ t = i / rate
239
+ f = f0 + (f1 - f0) * (i / max(1, n - 1))
240
+ phase += 2 * math.pi * f / rate
241
+ if shape == "square":
242
+ s = 1.0 if math.sin(phase) >= 0 else -1.0
243
+ s *= 0.5
244
+ elif shape == "tri":
245
+ s = 2 / math.pi * math.asin(math.sin(phase))
246
+ else:
247
+ s = math.sin(phase)
248
+ env = min(1.0, t / attack) * math.exp(-t / decay)
249
+ out.append(s * env * gain)
250
+ return out
251
+
252
+
253
+ def noise(seconds, rate=22050, decay=0.08, gain=0.5, seed=1):
254
+ x = seed & 0xFFFFFFFF
255
+ out = []
256
+ for i in range(int(seconds * rate)):
257
+ x ^= (x << 13) & 0xFFFFFFFF; x ^= x >> 17; x ^= (x << 5) & 0xFFFFFFFF
258
+ out.append(((x / 0xFFFFFFFF) * 2 - 1) * math.exp(-(i / rate) / decay) * gain)
259
+ return out
260
+
261
+
262
+ def mix(*parts):
263
+ n = max(len(p) for p in parts)
264
+ return [sum(p[i] for p in parts if i < len(p)) for i in range(n)]
265
+
266
+
267
+ def concat(*parts):
268
+ out = []
269
+ for p in parts:
270
+ out.extend(p)
271
+ return out
272
+
273
+
274
+ def subset_font(src, dst, text):
275
+ """Subset a TTF to Latin-1 plus `text` (needs fontTools)."""
276
+ from fontTools import subset
277
+ opts = subset.Options()
278
+ opts.name_IDs = ["*"]
279
+ opts.notdef_outline = True
280
+ opts.layout_features = []
281
+ font = subset.load_font(src, opts)
282
+ s = subset.Subsetter(opts)
283
+ s.populate(text="".join(chr(c) for c in range(0x20, 0x7F)) + "".join(chr(c) for c in range(0xA0, 0x100)) + text)
284
+ s.subset(font)
285
+ subset.save_font(font, dst, opts)