@zylem/game-lib 0.3.16 → 0.4.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 (294) hide show
  1. package/README.md +39 -14
  2. package/dist/.vite/manifest.json +140 -64
  3. package/dist/api/actions.d.ts +5 -0
  4. package/dist/api/actions.d.ts.map +1 -0
  5. package/dist/api/behaviors.d.ts +4 -0
  6. package/dist/api/behaviors.d.ts.map +1 -0
  7. package/dist/api/camera.d.ts +4 -0
  8. package/dist/api/camera.d.ts.map +1 -0
  9. package/dist/api/core.d.ts +6 -0
  10. package/dist/api/core.d.ts.map +1 -0
  11. package/dist/api/entities.d.ts +9 -0
  12. package/dist/api/entities.d.ts.map +1 -0
  13. package/dist/api/main.d.ts +32 -0
  14. package/dist/api/main.d.ts.map +1 -0
  15. package/dist/api/stage.d.ts +7 -0
  16. package/dist/api/stage.d.ts.map +1 -0
  17. package/dist/core.js +4 -4
  18. package/dist/lib/actions/behaviors/actions.d.ts +1 -0
  19. package/dist/lib/actions/behaviors/actions.d.ts.map +1 -0
  20. package/dist/lib/actions/behaviors/behavior.d.ts +1 -0
  21. package/dist/lib/actions/behaviors/behavior.d.ts.map +1 -0
  22. package/dist/lib/actions/behaviors/boundaries/boundary.d.ts +1 -0
  23. package/dist/lib/actions/behaviors/boundaries/boundary.d.ts.map +1 -0
  24. package/dist/lib/actions/behaviors/character-controller.d.ts +1 -0
  25. package/dist/lib/actions/behaviors/character-controller.d.ts.map +1 -0
  26. package/dist/lib/actions/behaviors/debug/debug-collision.d.ts +1 -0
  27. package/dist/lib/actions/behaviors/debug/debug-collision.d.ts.map +1 -0
  28. package/dist/lib/actions/behaviors/debug/debug-update.d.ts +1 -0
  29. package/dist/lib/actions/behaviors/debug/debug-update.d.ts.map +1 -0
  30. package/dist/lib/actions/behaviors/debug/debug.d.ts +1 -0
  31. package/dist/lib/actions/behaviors/debug/debug.d.ts.map +1 -0
  32. package/dist/lib/actions/behaviors/movement/movement-sequence-2d.d.ts +1 -0
  33. package/dist/lib/actions/behaviors/movement/movement-sequence-2d.d.ts.map +1 -0
  34. package/dist/lib/actions/behaviors/ricochet/ricochet-2d-collision.d.ts +1 -0
  35. package/dist/lib/actions/behaviors/ricochet/ricochet-2d-collision.d.ts.map +1 -0
  36. package/dist/lib/actions/behaviors/ricochet/ricochet-2d-in-bounds.d.ts +1 -0
  37. package/dist/lib/actions/behaviors/ricochet/ricochet-2d-in-bounds.d.ts.map +1 -0
  38. package/dist/lib/actions/behaviors/ricochet/ricochet.d.ts +1 -0
  39. package/dist/lib/actions/behaviors/ricochet/ricochet.d.ts.map +1 -0
  40. package/dist/lib/actions/behaviors/zylem-behavior.d.ts +1 -0
  41. package/dist/lib/actions/behaviors/zylem-behavior.d.ts.map +1 -0
  42. package/dist/lib/actions/capabilities/moveable.d.ts +1 -0
  43. package/dist/lib/actions/capabilities/moveable.d.ts.map +1 -0
  44. package/dist/lib/actions/capabilities/rotatable.d.ts +1 -0
  45. package/dist/lib/actions/capabilities/rotatable.d.ts.map +1 -0
  46. package/dist/lib/actions/capabilities/transformable.d.ts +1 -0
  47. package/dist/lib/actions/capabilities/transformable.d.ts.map +1 -0
  48. package/dist/lib/actions/global-change.d.ts +1 -0
  49. package/dist/lib/actions/global-change.d.ts.map +1 -0
  50. package/dist/lib/camera/camera.d.ts +1 -0
  51. package/dist/lib/camera/camera.d.ts.map +1 -0
  52. package/dist/lib/camera/fixed-2d.d.ts +1 -0
  53. package/dist/lib/camera/fixed-2d.d.ts.map +1 -0
  54. package/dist/lib/camera/perspective.d.ts +1 -0
  55. package/dist/lib/camera/perspective.d.ts.map +1 -0
  56. package/dist/lib/camera/third-person.d.ts +1 -0
  57. package/dist/lib/camera/third-person.d.ts.map +1 -0
  58. package/dist/lib/camera/zylem-camera.d.ts +27 -0
  59. package/dist/lib/camera/zylem-camera.d.ts.map +1 -0
  60. package/dist/lib/camera/zylem-camera.js +100 -37
  61. package/dist/lib/collision/collision-builder.d.ts +1 -0
  62. package/dist/lib/collision/collision-builder.d.ts.map +1 -0
  63. package/dist/lib/collision/collision-delegate.d.ts +1 -0
  64. package/dist/lib/collision/collision-delegate.d.ts.map +1 -0
  65. package/dist/lib/collision/collision-group.d.ts +1 -0
  66. package/dist/lib/collision/collision-group.d.ts.map +1 -0
  67. package/dist/lib/collision/collision-mask.d.ts +1 -0
  68. package/dist/lib/collision/collision-mask.d.ts.map +1 -0
  69. package/dist/lib/collision/collision.d.ts +1 -0
  70. package/dist/lib/collision/collision.d.ts.map +1 -0
  71. package/dist/lib/collision/utils.d.ts +1 -0
  72. package/dist/lib/collision/utils.d.ts.map +1 -0
  73. package/dist/lib/collision/world.d.ts +1 -0
  74. package/dist/lib/collision/world.d.ts.map +1 -0
  75. package/dist/lib/core/asset-manager.d.ts +1 -0
  76. package/dist/lib/core/asset-manager.d.ts.map +1 -0
  77. package/dist/lib/core/base-node-life-cycle.d.ts +15 -0
  78. package/dist/lib/core/base-node-life-cycle.d.ts.map +1 -0
  79. package/dist/lib/core/base-node.d.ts +7 -2
  80. package/dist/lib/core/base-node.d.ts.map +1 -0
  81. package/dist/lib/core/base-node.js +7 -3
  82. package/dist/lib/core/entity-asset-loader.d.ts +1 -0
  83. package/dist/lib/core/entity-asset-loader.d.ts.map +1 -0
  84. package/dist/lib/core/errors.d.ts +1 -0
  85. package/dist/lib/core/errors.d.ts.map +1 -0
  86. package/dist/lib/core/flags.d.ts +1 -0
  87. package/dist/lib/core/flags.d.ts.map +1 -0
  88. package/dist/lib/core/index.d.ts +1 -0
  89. package/dist/lib/core/index.d.ts.map +1 -0
  90. package/dist/lib/core/lazy-loader.d.ts +3 -2
  91. package/dist/lib/core/lazy-loader.d.ts.map +1 -0
  92. package/dist/lib/core/lifecycle-base.d.ts +1 -0
  93. package/dist/lib/core/lifecycle-base.d.ts.map +1 -0
  94. package/dist/lib/core/preset-shader.d.ts +1 -0
  95. package/dist/lib/core/preset-shader.d.ts.map +1 -0
  96. package/dist/lib/core/three-addons/Timer.d.ts +1 -0
  97. package/dist/lib/core/three-addons/Timer.d.ts.map +1 -0
  98. package/dist/lib/core/utility/nodes.d.ts +13 -0
  99. package/dist/lib/core/utility/nodes.d.ts.map +1 -0
  100. package/dist/lib/core/utility/nodes.js +31 -0
  101. package/dist/lib/core/utility/strings.d.ts +3 -0
  102. package/dist/lib/core/utility/strings.d.ts.map +1 -0
  103. package/dist/lib/core/utility/strings.js +14 -0
  104. package/dist/lib/core/{utility.d.ts → utility/vector.d.ts} +1 -2
  105. package/dist/lib/core/utility/vector.d.ts.map +1 -0
  106. package/dist/lib/core/utility/vector.js +8 -0
  107. package/dist/lib/core/vector.d.ts +1 -0
  108. package/dist/lib/core/vector.d.ts.map +1 -0
  109. package/dist/lib/core/vessel.d.ts +4 -1
  110. package/dist/lib/core/vessel.d.ts.map +1 -0
  111. package/dist/lib/core/vessel.js +13 -9
  112. package/dist/lib/debug/console/console-state.d.ts +1 -0
  113. package/dist/lib/debug/console/console-state.d.ts.map +1 -0
  114. package/dist/lib/debug/console/console-store.d.ts +1 -0
  115. package/dist/lib/debug/console/console-store.d.ts.map +1 -0
  116. package/dist/lib/debug/debug-state.d.ts +1 -0
  117. package/dist/lib/debug/debug-state.d.ts.map +1 -0
  118. package/dist/lib/debug/debug-store.d.ts +1 -0
  119. package/dist/lib/debug/debug-store.d.ts.map +1 -0
  120. package/dist/lib/debug/state-based-debug-loader.d.ts +1 -0
  121. package/dist/lib/debug/state-based-debug-loader.d.ts.map +1 -0
  122. package/dist/lib/device/aspect-ratio.d.ts +38 -0
  123. package/dist/lib/device/aspect-ratio.d.ts.map +1 -0
  124. package/dist/lib/device/aspect-ratio.js +44 -0
  125. package/dist/lib/device/desktop.d.ts +1 -0
  126. package/dist/lib/device/desktop.d.ts.map +1 -0
  127. package/dist/lib/device/mobile.d.ts +1 -0
  128. package/dist/lib/device/mobile.d.ts.map +1 -0
  129. package/dist/lib/device/tablet.d.ts +1 -0
  130. package/dist/lib/device/tablet.d.ts.map +1 -0
  131. package/dist/lib/entities/actor.d.ts +1 -0
  132. package/dist/lib/entities/actor.d.ts.map +1 -0
  133. package/dist/lib/entities/box.d.ts +1 -0
  134. package/dist/lib/entities/box.d.ts.map +1 -0
  135. package/dist/lib/entities/builder.d.ts +1 -0
  136. package/dist/lib/entities/builder.d.ts.map +1 -0
  137. package/dist/lib/entities/create.d.ts +1 -0
  138. package/dist/lib/entities/create.d.ts.map +1 -0
  139. package/dist/lib/entities/delegates/animation.d.ts +1 -0
  140. package/dist/lib/entities/delegates/animation.d.ts.map +1 -0
  141. package/dist/lib/entities/delegates/debug.d.ts +1 -0
  142. package/dist/lib/entities/delegates/debug.d.ts.map +1 -0
  143. package/dist/lib/entities/delegates/loader.d.ts +1 -0
  144. package/dist/lib/entities/delegates/loader.d.ts.map +1 -0
  145. package/dist/lib/entities/destroy.d.ts +1 -0
  146. package/dist/lib/entities/destroy.d.ts.map +1 -0
  147. package/dist/lib/entities/entity.d.ts +4 -1
  148. package/dist/lib/entities/entity.d.ts.map +1 -0
  149. package/dist/lib/entities/entity.js +9 -5
  150. package/dist/lib/entities/index.d.ts +1 -0
  151. package/dist/lib/entities/index.d.ts.map +1 -0
  152. package/dist/lib/entities/plane.d.ts +1 -0
  153. package/dist/lib/entities/plane.d.ts.map +1 -0
  154. package/dist/lib/entities/rect.d.ts +1 -0
  155. package/dist/lib/entities/rect.d.ts.map +1 -0
  156. package/dist/lib/entities/sphere.d.ts +1 -0
  157. package/dist/lib/entities/sphere.d.ts.map +1 -0
  158. package/dist/lib/entities/sprite.d.ts +1 -0
  159. package/dist/lib/entities/sprite.d.ts.map +1 -0
  160. package/dist/lib/entities/text.d.ts +8 -0
  161. package/dist/lib/entities/text.d.ts.map +1 -0
  162. package/dist/lib/entities/text.js +77 -48
  163. package/dist/lib/entities/zone.d.ts +1 -0
  164. package/dist/lib/entities/zone.d.ts.map +1 -0
  165. package/dist/lib/game/game-blueprint.d.ts +38 -0
  166. package/dist/lib/game/game-blueprint.d.ts.map +1 -0
  167. package/dist/lib/game/game-canvas.d.ts +35 -0
  168. package/dist/lib/game/game-canvas.d.ts.map +1 -0
  169. package/dist/lib/game/game-canvas.js +57 -0
  170. package/dist/lib/game/game-config.d.ts +63 -0
  171. package/dist/lib/game/game-config.d.ts.map +1 -0
  172. package/dist/lib/game/game-config.js +79 -0
  173. package/dist/lib/game/game-default.d.ts +19 -0
  174. package/dist/lib/game/game-default.d.ts.map +1 -0
  175. package/dist/lib/game/game-default.js +24 -0
  176. package/dist/lib/game/game-interfaces.d.ts +3 -2
  177. package/dist/lib/game/game-interfaces.d.ts.map +1 -0
  178. package/dist/lib/game/game-retro-resolutions.d.ts +24 -0
  179. package/dist/lib/game/game-retro-resolutions.d.ts.map +1 -0
  180. package/dist/lib/game/game-retro-resolutions.js +81 -0
  181. package/dist/lib/game/game-state.d.ts +6 -5
  182. package/dist/lib/game/game-state.d.ts.map +1 -0
  183. package/dist/lib/game/game.d.ts +8 -12
  184. package/dist/lib/game/game.d.ts.map +1 -0
  185. package/dist/lib/game/game.js +44 -92
  186. package/dist/lib/game/zylem-game.d.ts +15 -3
  187. package/dist/lib/game/zylem-game.d.ts.map +1 -0
  188. package/dist/lib/game/zylem-game.js +67 -33
  189. package/dist/lib/graphics/geometries/XZPlaneGeometry.d.ts +1 -0
  190. package/dist/lib/graphics/geometries/XZPlaneGeometry.d.ts.map +1 -0
  191. package/dist/lib/graphics/material.d.ts +2 -1
  192. package/dist/lib/graphics/material.d.ts.map +1 -0
  193. package/dist/lib/graphics/material.js +1 -1
  194. package/dist/lib/graphics/mesh.d.ts +1 -0
  195. package/dist/lib/graphics/mesh.d.ts.map +1 -0
  196. package/dist/lib/graphics/render-pass.d.ts +1 -0
  197. package/dist/lib/graphics/render-pass.d.ts.map +1 -0
  198. package/dist/lib/graphics/zylem-scene.d.ts +8 -7
  199. package/dist/lib/graphics/zylem-scene.d.ts.map +1 -0
  200. package/dist/lib/graphics/zylem-scene.js +26 -40
  201. package/dist/lib/input/gamepad-provider.d.ts +1 -0
  202. package/dist/lib/input/gamepad-provider.d.ts.map +1 -0
  203. package/dist/lib/input/input-manager.d.ts +1 -0
  204. package/dist/lib/input/input-manager.d.ts.map +1 -0
  205. package/dist/lib/input/input-provider.d.ts +1 -0
  206. package/dist/lib/input/input-provider.d.ts.map +1 -0
  207. package/dist/lib/input/input.d.ts +1 -0
  208. package/dist/lib/input/input.d.ts.map +1 -0
  209. package/dist/lib/input/keyboard-provider.d.ts +1 -0
  210. package/dist/lib/input/keyboard-provider.d.ts.map +1 -0
  211. package/dist/lib/interfaces/entity.d.ts +1 -0
  212. package/dist/lib/interfaces/entity.d.ts.map +1 -0
  213. package/dist/lib/sounds/index.d.ts +1 -0
  214. package/dist/lib/sounds/index.d.ts.map +1 -0
  215. package/dist/lib/sounds/ping-pong-sound.d.ts +1 -0
  216. package/dist/lib/sounds/ping-pong-sound.d.ts.map +1 -0
  217. package/dist/lib/sounds/ricochet-sound.d.ts +1 -0
  218. package/dist/lib/sounds/ricochet-sound.d.ts.map +1 -0
  219. package/dist/lib/stage/debug-entity-cursor.d.ts +1 -0
  220. package/dist/lib/stage/debug-entity-cursor.d.ts.map +1 -0
  221. package/dist/lib/stage/entity-spawner.d.ts +1 -0
  222. package/dist/lib/stage/entity-spawner.d.ts.map +1 -0
  223. package/dist/lib/stage/stage-blueprint.d.ts +45 -0
  224. package/dist/lib/stage/stage-blueprint.d.ts.map +1 -0
  225. package/dist/lib/stage/stage-blueprint.js +56 -0
  226. package/dist/lib/stage/stage-camera-debug-delegate.d.ts +14 -0
  227. package/dist/lib/stage/stage-camera-debug-delegate.d.ts.map +1 -0
  228. package/dist/lib/stage/stage-debug-delegate.d.ts +1 -0
  229. package/dist/lib/stage/stage-debug-delegate.d.ts.map +1 -0
  230. package/dist/lib/stage/stage-default.d.ts +10 -0
  231. package/dist/lib/stage/stage-default.d.ts.map +1 -0
  232. package/dist/lib/stage/stage-default.js +42 -0
  233. package/dist/lib/stage/stage-state.d.ts +1 -0
  234. package/dist/lib/stage/stage-state.d.ts.map +1 -0
  235. package/dist/lib/stage/stage.d.ts +4 -3
  236. package/dist/lib/stage/stage.d.ts.map +1 -0
  237. package/dist/lib/stage/stage.js +27 -25
  238. package/dist/lib/stage/zylem-stage.d.ts +8 -4
  239. package/dist/lib/stage/zylem-stage.d.ts.map +1 -0
  240. package/dist/lib/stage/zylem-stage.js +36 -46
  241. package/dist/lib/systems/test-system.d.ts +1 -0
  242. package/dist/lib/systems/test-system.d.ts.map +1 -0
  243. package/dist/lib/systems/transformable.system.d.ts +1 -0
  244. package/dist/lib/systems/transformable.system.d.ts.map +1 -0
  245. package/dist/lib/types/entity-types.d.ts +1 -0
  246. package/dist/lib/types/entity-types.d.ts.map +1 -0
  247. package/dist/lib/types/index.d.ts +1 -0
  248. package/dist/lib/types/index.d.ts.map +1 -0
  249. package/dist/lib/types/stage-types.d.ts +1 -0
  250. package/dist/lib/types/stage-types.d.ts.map +1 -0
  251. package/dist/lib/ui/Debug.d.ts +1 -0
  252. package/dist/lib/ui/Debug.d.ts.map +1 -0
  253. package/dist/lib/ui/console/Console.d.ts +1 -0
  254. package/dist/lib/ui/console/Console.d.ts.map +1 -0
  255. package/dist/lib/ui/debug-panel/AccordionMenu.d.ts +1 -0
  256. package/dist/lib/ui/debug-panel/AccordionMenu.d.ts.map +1 -0
  257. package/dist/lib/ui/debug-panel/Menu.d.ts +1 -0
  258. package/dist/lib/ui/debug-panel/Menu.d.ts.map +1 -0
  259. package/dist/lib/ui/debug-panel/sections/EntitiesSection.d.ts +1 -0
  260. package/dist/lib/ui/debug-panel/sections/EntitiesSection.d.ts.map +1 -0
  261. package/dist/lib/ui/debug-panel/sections/GameSection.d.ts +1 -0
  262. package/dist/lib/ui/debug-panel/sections/GameSection.d.ts.map +1 -0
  263. package/dist/lib/ui/debug-panel/sections/StagesSection.d.ts +1 -0
  264. package/dist/lib/ui/debug-panel/sections/StagesSection.d.ts.map +1 -0
  265. package/dist/lib/ui/debug-panel/sections/all.d.ts +1 -0
  266. package/dist/lib/ui/debug-panel/sections/all.d.ts.map +1 -0
  267. package/dist/lib/ui/toolbar/Toolbar.d.ts +1 -0
  268. package/dist/lib/ui/toolbar/Toolbar.d.ts.map +1 -0
  269. package/dist/main.js +52 -50
  270. package/dist/stage.js +20 -4
  271. package/dist/tests/unit/collision/collision.spec.d.ts +2 -0
  272. package/dist/tests/unit/collision/collision.spec.d.ts.map +1 -0
  273. package/dist/tests/unit/core/game.spec.d.ts +2 -0
  274. package/dist/tests/unit/core/game.spec.d.ts.map +1 -0
  275. package/dist/tests/unit/core/stage.spec.d.ts +2 -0
  276. package/dist/tests/unit/core/stage.spec.d.ts.map +1 -0
  277. package/dist/tests/unit/core/vessel.spec.d.ts +2 -0
  278. package/dist/tests/unit/core/vessel.spec.d.ts.map +1 -0
  279. package/dist/tests/unit/stage/stage-blueprint.spec.d.ts +2 -0
  280. package/dist/tests/unit/stage/stage-blueprint.spec.d.ts.map +1 -0
  281. package/package.json +11 -9
  282. package/dist/actions.d.ts +0 -4
  283. package/dist/behaviors.d.ts +0 -3
  284. package/dist/camera.d.ts +0 -3
  285. package/dist/core.d.ts +0 -5
  286. package/dist/entities.d.ts +0 -8
  287. package/dist/lib/core/game-canvas.d.ts +0 -4
  288. package/dist/lib/core/utility.js +0 -20
  289. package/dist/main.d.ts +0 -30
  290. package/dist/stage.d.ts +0 -3
  291. package/dist/tests/collision/collision.spec.d.ts +0 -1
  292. package/dist/tests/core/game.spec.d.ts +0 -1
  293. package/dist/tests/core/stage.spec.d.ts +0 -1
  294. package/dist/tests/core/vessel.spec.d.ts +0 -1
@@ -60,3 +60,4 @@ export declare class ZylemRect extends GameEntity<ZylemRectOptions> {
60
60
  type RectOptions = BaseNode | Partial<ZylemRectOptions>;
61
61
  export declare function rect(...args: Array<RectOptions>): Promise<ZylemRect>;
62
62
  export {};
63
+ //# sourceMappingURL=rect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rect.d.ts","source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function sphere(...args: Array<SphereOptions>): Promise<ZylemSphere>;
28
28
  export {};
29
+ //# sourceMappingURL=sphere.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sphere.d.ts","sourceRoot":"","sources":["../../../src/lib/entities/sphere.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAS,cAAc,EAAE,MAAM,OAAO,CAAC;AAE9C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAI9C,KAAK,kBAAkB,GAAG,iBAAiB,GAAG;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAcF,qBAAa,sBAAuB,SAAQ,sBAAsB;IACjE,QAAQ,CAAC,OAAO,EAAE,kBAAkB,GAAG,YAAY;CAKnD;AAED,qBAAa,iBAAkB,SAAQ,iBAAiB;IACvD,KAAK,CAAC,OAAO,EAAE,kBAAkB,GAAG,cAAc;CAIlD;AAED,qBAAa,aAAc,SAAQ,aAAa,CAAC,WAAW,EAAE,kBAAkB,CAAC;IAChF,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,kBAAkB,CAAC,GAAG,WAAW;CAGzE;AAED,eAAO,MAAM,WAAW,eAAmB,CAAC;AAE5C,qBAAa,WAAY,SAAQ,UAAU,CAAC,kBAAkB,CAAC;IAC9D,MAAM,CAAC,IAAI,SAAe;gBAEd,OAAO,CAAC,EAAE,kBAAkB;IAKxC,SAAS,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAUhC;AAED,KAAK,aAAa,GAAG,QAAQ,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAE5D,wBAAsB,MAAM,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAUhF"}
@@ -50,3 +50,4 @@ export declare class ZylemSprite extends GameEntity<ZylemSpriteOptions> {
50
50
  type SpriteOptions = BaseNode | Partial<ZylemSpriteOptions>;
51
51
  export declare function sprite(...args: Array<SpriteOptions>): Promise<ZylemSprite>;
52
52
  export {};
53
+ //# sourceMappingURL=sprite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sprite.d.ts","sourceRoot":"","sources":["../../../src/lib/entities/sprite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAmC,OAAO,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAGN,MAAM,IAAI,WAAW,EACrB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAmB,aAAa,EAAkB,MAAM,8BAA8B,CAAC;AAE9G,MAAM,MAAM,WAAW,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AACzD,MAAM,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,IAAI,EAAE,OAAO,CAAC;CACd,CAAC;AAEF,KAAK,kBAAkB,GAAG,iBAAiB,GAAG;IAC7C,MAAM,CAAC,EAAE,WA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kB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IActE,aAAa,CAAC,MAAM,EAAE,cAAc,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAO9E;AAED,KAAK,aAAa,GAAG,QAAQ,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAE5D,wBAAsB,MAAM,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAShF"}
@@ -28,10 +28,17 @@ export declare class ZylemText extends GameEntity<ZylemTextOptions> {
28
28
  private _lastCanvasH;
29
29
  constructor(options?: ZylemTextOptions);
30
30
  private createSprite;
31
+ private measureAndResizeCanvas;
32
+ private drawCenteredText;
33
+ private updateTexture;
31
34
  private redrawText;
32
35
  private toCssColor;
33
36
  private textSetup;
34
37
  private textUpdate;
38
+ private getResolution;
39
+ private getScreenPixels;
40
+ private computeWorldExtents;
41
+ private updateSpriteScale;
35
42
  private updateStickyTransform;
36
43
  updateText(_text: string): void;
37
44
  buildInfo(): Record<string, any>;
@@ -39,3 +46,4 @@ export declare class ZylemText extends GameEntity<ZylemTextOptions> {
39
46
  type TextOptions = BaseNode | Partial<ZylemTextOptions>;
40
47
  export declare function text(...args: Array<TextOptions>): Promise<ZylemText>;
41
48
  export {};
49
+ //# sourceMappingURL=text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/lib/entities/text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAA6E,OAAO,EAA8D,MAAM,OAAO,CAAC;AAC9K,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAM1C,KAAK,gBAAgB,GAAG,iBAAiB,GAAG;IAC3C,IAAI,CAAC,EAAE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,UAAU,CAAC,KAAK,EAAE,MAAM;IAQxB,SAAS,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAWhC;AAED,KAAK,WAAW,GAAG,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAExD,wBAAsB,IAAI,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAQ1E"}
@@ -1,9 +1,9 @@
1
- import { Vector2 as u, Group as H, CanvasTexture as w, LinearFilter as l, SpriteMaterial as k, Sprite as M, ClampToEdgeWrapping as C, Color as v } from "three";
2
- import { GameEntity as R } from "./entity.js";
3
- import { EntityBuilder as W } from "./builder.js";
4
- import { createEntity as E } from "./create.js";
5
- import { DebugDelegate as D } from "./delegates/debug.js";
6
- const x = {
1
+ import { Vector2 as m, Group as v, CanvasTexture as d, LinearFilter as l, SpriteMaterial as y, Sprite as T, ClampToEdgeWrapping as _, Color as f } from "three";
2
+ import { GameEntity as S } from "./entity.js";
3
+ import { EntityBuilder as F } from "./builder.js";
4
+ import { createEntity as R } from "./create.js";
5
+ import { DebugDelegate as H } from "./delegates/debug.js";
6
+ const u = {
7
7
  position: void 0,
8
8
  text: "",
9
9
  fontFamily: 'Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',
@@ -12,17 +12,17 @@ const x = {
12
12
  backgroundColor: null,
13
13
  padding: 4,
14
14
  stickToViewport: !0,
15
- screenPosition: new u(24, 24),
15
+ screenPosition: new m(24, 24),
16
16
  zDistance: 1
17
17
  };
18
- class P extends W {
18
+ class k extends F {
19
19
  createEntity(t) {
20
- return new o(t);
20
+ return new c(t);
21
21
  }
22
22
  }
23
- const z = Symbol("Text");
24
- class o extends R {
25
- static type = z;
23
+ const b = Symbol("Text");
24
+ class c extends S {
25
+ static type = b;
26
26
  _sprite = null;
27
27
  _texture = null;
28
28
  _canvas = null;
@@ -31,81 +31,110 @@ class o extends R {
31
31
  _lastCanvasW = 0;
32
32
  _lastCanvasH = 0;
33
33
  constructor(t) {
34
- super(), this.options = { ...x, ...t }, this.group = new H(), this.createSprite(), this.lifeCycleDelegate = {
34
+ super(), this.options = { ...u, ...t }, this.group = new v(), this.createSprite(), this.lifeCycleDelegate = {
35
35
  setup: [this.textSetup.bind(this)],
36
36
  update: [this.textUpdate.bind(this)]
37
37
  };
38
38
  }
39
39
  createSprite() {
40
- this._canvas = document.createElement("canvas"), this._ctx = this._canvas.getContext("2d"), this._texture = new w(this._canvas), this._texture.minFilter = l, this._texture.magFilter = l;
41
- const t = new k({
40
+ this._canvas = document.createElement("canvas"), this._ctx = this._canvas.getContext("2d"), this._texture = new d(this._canvas), this._texture.minFilter = l, this._texture.magFilter = l;
41
+ const t = new y({
42
42
  map: this._texture,
43
43
  transparent: !0,
44
44
  depthTest: !1,
45
45
  depthWrite: !1,
46
46
  alphaTest: 0.5
47
47
  });
48
- this._sprite = new M(t), this.group?.add(this._sprite), this.redrawText(this.options.text ?? "");
48
+ this._sprite = new T(t), this.group?.add(this._sprite), this.redrawText(this.options.text ?? "");
49
+ }
50
+ measureAndResizeCanvas(t, e, s, a) {
51
+ if (!this._canvas || !this._ctx)
52
+ return { sizeChanged: !1 };
53
+ this._ctx.font = `${e}px ${s}`;
54
+ const i = this._ctx.measureText(t), n = Math.ceil(i.width), r = Math.ceil(e * 1.4), o = Math.max(2, n + a * 2), h = Math.max(2, r + a * 2), p = o !== this._lastCanvasW || h !== this._lastCanvasH;
55
+ return this._canvas.width = o, this._canvas.height = h, this._lastCanvasW = o, this._lastCanvasH = h, { sizeChanged: p };
56
+ }
57
+ drawCenteredText(t, e, s) {
58
+ !this._canvas || !this._ctx || (this._ctx.font = `${e}px ${s}`, this._ctx.textAlign = "center", this._ctx.textBaseline = "middle", this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height), this.options.backgroundColor && (this._ctx.fillStyle = this.toCssColor(this.options.backgroundColor), this._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height)), this._ctx.fillStyle = this.toCssColor(this.options.fontColor ?? "#FFFFFF"), this._ctx.fillText(t, this._canvas.width / 2, this._canvas.height / 2));
59
+ }
60
+ updateTexture(t) {
61
+ !this._texture || !this._canvas || (t && (this._texture.dispose(), this._texture = new d(this._canvas), this._texture.minFilter = l, this._texture.magFilter = l, this._texture.wrapS = _, this._texture.wrapT = _), this._texture.image = this._canvas, this._texture.needsUpdate = !0, this._sprite && this._sprite.material && (this._sprite.material.map = this._texture, this._sprite.material.needsUpdate = !0));
49
62
  }
50
63
  redrawText(t) {
51
64
  if (!this._canvas || !this._ctx)
52
65
  return;
53
- const e = this.options.fontSize ?? 18, r = this.options.fontFamily ?? x.fontFamily, a = this.options.padding ?? 4;
54
- this._ctx.font = `${e}px ${r}`;
55
- const p = this._ctx.measureText(t), _ = Math.ceil(p.width), h = Math.ceil(e * 1.4), n = Math.max(2, _ + a * 2), s = Math.max(2, h + a * 2), f = n !== this._lastCanvasW || s !== this._lastCanvasH;
56
- this._canvas.width = n, this._canvas.height = s, this._lastCanvasW = n, this._lastCanvasH = s, this._ctx.font = `${e}px ${r}`, this._ctx.textBaseline = "top", this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height), this.options.backgroundColor && (this._ctx.fillStyle = this.toCssColor(this.options.backgroundColor), this._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height)), this._ctx.fillStyle = this.toCssColor(this.options.fontColor ?? "#FFFFFF"), this._ctx.fillText(t, a, a), this._texture && (f && (this._texture.dispose(), this._texture = new w(this._canvas), this._texture.minFilter = l, this._texture.magFilter = l, this._texture.wrapS = C, this._texture.wrapT = C), this._texture.image = this._canvas, this._texture.needsUpdate = !0, this._sprite && this._sprite.material && (this._sprite.material.map = this._texture, this._sprite.material.needsUpdate = !0));
66
+ const e = this.options.fontSize ?? 18, s = this.options.fontFamily ?? u.fontFamily, a = this.options.padding ?? 4, { sizeChanged: i } = this.measureAndResizeCanvas(t, e, s, a);
67
+ this.drawCenteredText(t, e, s), this.updateTexture(!!i), this.options.stickToViewport && this._cameraRef && this.updateStickyTransform();
57
68
  }
58
69
  toCssColor(t) {
59
- return typeof t == "string" ? t : `#${(t instanceof v ? t : new v(t)).getHexString()}`;
70
+ return typeof t == "string" ? t : `#${(t instanceof f ? t : new f(t)).getHexString()}`;
60
71
  }
61
72
  textSetup(t) {
62
- this._cameraRef = t.camera, this.options.stickToViewport && this._cameraRef && this._cameraRef.camera.add(this.group);
73
+ this._cameraRef = t.camera, this.options.stickToViewport && this._cameraRef && (this._cameraRef.camera.add(this.group), this.updateStickyTransform());
63
74
  }
64
75
  textUpdate(t) {
65
76
  this._sprite && this.options.stickToViewport && this._cameraRef && this.updateStickyTransform();
66
77
  }
67
- updateStickyTransform() {
68
- if (!this._sprite || !this._cameraRef)
69
- return;
70
- const t = this._cameraRef.camera, e = this._cameraRef.renderer.domElement, r = e.clientWidth, a = e.clientHeight, p = (this.options.screenPosition ?? new u(24, 24)).x, _ = (this.options.screenPosition ?? new u(24, 24)).y, h = Math.max(1e-3, this.options.zDistance ?? 1);
71
- let n = 1, s = 1;
78
+ getResolution() {
79
+ return {
80
+ width: this._cameraRef?.screenResolution.x ?? 1,
81
+ height: this._cameraRef?.screenResolution.y ?? 1
82
+ };
83
+ }
84
+ getScreenPixels(t, e, s) {
85
+ const a = t.x >= 0 && t.x <= 1, i = t.y >= 0 && t.y <= 1;
86
+ return {
87
+ px: a ? t.x * e : t.x,
88
+ py: i ? t.y * s : t.y
89
+ };
90
+ }
91
+ computeWorldExtents(t, e) {
92
+ let s = 1, a = 1;
72
93
  if (t.isPerspectiveCamera) {
73
- const i = t, c = Math.tan(i.fov * Math.PI / 180 / 2) * h;
74
- n = c * i.aspect, s = c;
94
+ const i = t, n = Math.tan(i.fov * Math.PI / 180 / 2) * e;
95
+ s = n * i.aspect, a = n;
75
96
  } else if (t.isOrthographicCamera) {
76
97
  const i = t;
77
- n = (i.right - i.left) / 2, s = (i.top - i.bottom) / 2;
78
- }
79
- const f = p / r * 2 - 1, y = 1 - _ / a * 2, T = f * n, F = y * s;
80
- if (this.group?.position.set(T, F, -h), this._canvas) {
81
- const c = s * 2 / a, m = this._canvas.height, g = Math.max(1e-4, m * c), S = this._canvas.width / this._canvas.height, b = g * S;
82
- this._sprite.scale.set(b, g, 1);
98
+ s = (i.right - i.left) / 2, a = (i.top - i.bottom) / 2;
83
99
  }
100
+ return { worldHalfW: s, worldHalfH: a };
101
+ }
102
+ updateSpriteScale(t, e) {
103
+ if (!this._canvas || !this._sprite)
104
+ return;
105
+ const a = t * 2 / e, i = this._canvas.height, n = Math.max(1e-4, i * a), r = this._canvas.width / this._canvas.height, o = n * r;
106
+ this._sprite.scale.set(o, n, 1);
107
+ }
108
+ updateStickyTransform() {
109
+ if (!this._sprite || !this._cameraRef)
110
+ return;
111
+ const t = this._cameraRef.camera, { width: e, height: s } = this.getResolution(), a = this.options.screenPosition ?? new m(24, 24), { px: i, py: n } = this.getScreenPixels(a, e, s), r = Math.max(1e-3, this.options.zDistance ?? 1), { worldHalfW: o, worldHalfH: h } = this.computeWorldExtents(t, r), p = i / e * 2 - 1, g = 1 - n / s * 2, w = p * o, C = g * h;
112
+ this.group?.position.set(w, C, -r), this.updateSpriteScale(h, s);
84
113
  }
85
114
  updateText(t) {
86
115
  this.options.text = t, this.redrawText(t), this.options.stickToViewport && this._cameraRef && this.updateStickyTransform();
87
116
  }
88
117
  buildInfo() {
89
118
  return {
90
- ...new D(this).buildDebugInfo(),
91
- type: String(o.type),
119
+ ...new H(this).buildDebugInfo(),
120
+ type: String(c.type),
92
121
  text: this.options.text ?? "",
93
122
  sticky: this.options.stickToViewport
94
123
  };
95
124
  }
96
125
  }
97
- async function X(...d) {
98
- return E({
99
- args: d,
100
- defaultConfig: { ...x },
101
- EntityClass: o,
102
- BuilderClass: P,
103
- entityType: o.type
126
+ async function D(...x) {
127
+ return R({
128
+ args: x,
129
+ defaultConfig: { ...u },
130
+ EntityClass: c,
131
+ BuilderClass: k,
132
+ entityType: c.type
104
133
  });
105
134
  }
106
135
  export {
107
- z as TEXT_TYPE,
108
- P as TextBuilder,
109
- o as ZylemText,
110
- X as text
136
+ b as TEXT_TYPE,
137
+ k as TextBuilder,
138
+ c as ZylemText,
139
+ D as text
111
140
  };
@@ -51,3 +51,4 @@ export declare class ZylemZone extends GameEntity<ZylemZoneOptions> implements C
51
51
  type ZoneOptions = BaseNode | Partial<ZylemZoneOptions>;
52
52
  export declare function zone(...args: Array<ZoneOptions>): Promise<ZylemZone>;
53
53
  export {};
54
+ //# sourceMappingURL=zone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zone.d.ts","sourceRoot":"","sources":["../../../src/lib/entities/zone.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAG3E,MAAM,MAAM,YAAY,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,GAAG,CAAC;CACb,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC,CAAC;AAC/E,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC,CAAC;AAE9E,KAAK,gBAAgB,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K,IAAI;IAK/C,OAAO,CAAC,KAAK,EAAE,GAAG;IAWlB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAkBjC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG;CAc9B;AAED,KAAK,WAAW,GAAG,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAExD,wBAAsB,IAAI,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAS1E"}
@@ -0,0 +1,38 @@
1
+ import type { Stage } from '../stage/stage';
2
+ import type { BaseGlobals, ZylemGameConfig } from './game-interfaces';
3
+ /**
4
+ * A lightweight, serializable blueprint representing the initial configuration
5
+ * of a `Game`. It should not include runtime references. Use blueprints only to
6
+ * build games.
7
+ */
8
+ export interface GameBlueprint<TGlobals extends BaseGlobals = BaseGlobals> {
9
+ id: string;
10
+ name?: string;
11
+ config: Partial<ZylemGameConfig<Stage, any, TGlobals>>;
12
+ }
13
+ export declare const gameBlueprintsState: {
14
+ byId: Record<string, GameBlueprint>;
15
+ order: string[];
16
+ currentId: string | null;
17
+ };
18
+ /** Reset the blueprints store back to its initial empty state. */
19
+ export declare function resetGameBlueprints(): void;
20
+ /** Create and register a new `GameBlueprint`. */
21
+ export declare function createGameBlueprint<TGlobals extends BaseGlobals>(config: Partial<ZylemGameConfig<Stage, any, TGlobals>>, options?: {
22
+ id?: string;
23
+ name?: string;
24
+ setCurrent?: boolean;
25
+ }): GameBlueprint<TGlobals>;
26
+ /** Upsert a blueprint into the store. */
27
+ export declare function upsertGameBlueprint<TGlobals extends BaseGlobals>(blueprint: GameBlueprint<TGlobals>): void;
28
+ /** Remove a blueprint by id. */
29
+ export declare function removeGameBlueprint(id: string): void;
30
+ /** Get a blueprint by id. */
31
+ export declare function getGameBlueprint(id: string): GameBlueprint | undefined;
32
+ /** List all blueprints in insertion order. */
33
+ export declare function listGameBlueprints(): GameBlueprint[];
34
+ /** Set the current blueprint id (or clear by passing null). */
35
+ export declare function setCurrentGameBlueprint(id: string | null): void;
36
+ /** Get the current blueprint object, if any. */
37
+ export declare function getCurrentGameBlueprint(): GameBlueprint | null;
38
+ //# sourceMappingURL=game-blueprint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"game-blueprint.d.ts","sourceRoot":"","sources":["../../../src/lib/game/game-blueprint.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEtE;;;;GAIG;AACH,MAAM,WAAW,aAAa,CAAC,QAAQ,SAAS,WAAW,GAAG,WAAW;IACxE,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;CACvD;AAYD,eAAO,MAAM,mBAAmB;UALnB,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;WAC5B,MAAM,EAAE;eACF,MAAM,GAAG,IAAI;CAG8C,CAAC;AAEhF,kEAAkE;AAClE,wBAAgB,mBAAmB,IAAI,IAAI,CAK1C;AAED,iDAAiD;AACjD,wBAAgB,mBAAmB,CAAC,QAAQ,SAAS,WAAW,EAC/D,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC,EACtD,OAAO,CAAC,EAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAC;CAAE,GAC7D,aAAa,CAAC,QAAQ,CAAC,CAWzB;AAED,yCAAyC;AACzC,wBAAgB,mBAAmB,CAAC,QAAQ,SAAS,WAAW,EAC/D,SAAS,EAAE,aAAa,CAAC,QAAQ,CAAC,GAChC,IAAI,CAKN;AAED,gCAAgC;AAChC,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAMpD;AAED,6BAA6B;AAC7B,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAEtE;AAED,8CAA8C;AAC9C,wBAAgB,kBAAkB,IAAI,aAAa,EAAE,CAIpD;AAED,+DAA+D;AAC/D,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAE/D;AAED,gDAAgD;AAChD,wBAAgB,uBAAuB,IAAI,aAAa,GAAG,IAAI,CAG9D"}
@@ -0,0 +1,35 @@
1
+ import { AspectRatioValue } from '../device/aspect-ratio';
2
+ export interface GameCanvasOptions {
3
+ id: string;
4
+ container?: HTMLElement;
5
+ containerId?: string;
6
+ canvas?: HTMLCanvasElement;
7
+ bodyBackground?: string;
8
+ fullscreen?: boolean;
9
+ aspectRatio: AspectRatioValue | number;
10
+ }
11
+ /**
12
+ * GameCanvas is a DOM delegate that owns:
13
+ * - container lookup/creation and styling (including fullscreen centering)
14
+ * - body background application
15
+ * - canvas mounting into container
16
+ * - aspect ratio sizing via AspectRatioDelegate
17
+ */
18
+ export declare class GameCanvas {
19
+ id: string;
20
+ container: HTMLElement;
21
+ canvas: HTMLCanvasElement;
22
+ bodyBackground?: string;
23
+ fullscreen: boolean;
24
+ aspectRatio: number;
25
+ private ratioDelegate;
26
+ constructor(options: GameCanvasOptions);
27
+ applyBodyBackground(): void;
28
+ mountCanvas(): void;
29
+ mountRenderer(rendererDom: HTMLCanvasElement, onResize: (width: number, height: number) => void): void;
30
+ centerIfFullscreen(): void;
31
+ attachAspectRatio(onResize: (width: number, height: number) => void): void;
32
+ destroy(): void;
33
+ private ensureContainer;
34
+ }
35
+ //# sourceMappingURL=game-canvas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"game-canvas.d.ts","sourceRoot":"","sources":["../../../src/lib/game/game-canvas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/E,MAAM,WAAW,iBAAiB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,gBAAgB,GAAG,MAAM,CAAC;CACvC;AAED;;;;;;GAMG;AACH,qBAAa,UAAU;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAG,WAAW,CAAC;IACxB,MAAM,EAAG,iBAAiB,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,aAAa,CAAoC;gBAE7C,OAAO,EAAE,iBAAiB;IAStC,mBAAmB;IAMnB,WAAW;IAOX,aAAa,CAAC,WAAW,EAAE,iBAAiB,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI;IAS/F,kBAAkB;IAUlB,iBAAiB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI;IAiBnE,OAAO;IAKP,OAAO,CAAC,eAAe;CAevB"}
@@ -0,0 +1,57 @@
1
+ import { AspectRatioDelegate as s } from "../device/aspect-ratio.js";
2
+ class o {
3
+ id;
4
+ container;
5
+ canvas;
6
+ bodyBackground;
7
+ fullscreen;
8
+ aspectRatio;
9
+ ratioDelegate = null;
10
+ constructor(t) {
11
+ this.id = t.id, this.container = this.ensureContainer(t.containerId ?? t.id, t.container), this.canvas = t.canvas ?? document.createElement("canvas"), this.bodyBackground = t.bodyBackground, this.fullscreen = !!t.fullscreen, this.aspectRatio = (typeof t.aspectRatio == "number", t.aspectRatio);
12
+ }
13
+ applyBodyBackground() {
14
+ this.bodyBackground && (document.body.style.background = this.bodyBackground);
15
+ }
16
+ mountCanvas() {
17
+ for (; this.container.firstChild; )
18
+ this.container.removeChild(this.container.firstChild);
19
+ this.container.appendChild(this.canvas);
20
+ }
21
+ mountRenderer(t, a) {
22
+ for (; this.container.firstChild; )
23
+ this.container.removeChild(this.container.firstChild);
24
+ this.container.appendChild(t), this.canvas = t, this.attachAspectRatio(a);
25
+ }
26
+ centerIfFullscreen() {
27
+ if (!this.fullscreen)
28
+ return;
29
+ const t = this.container.style;
30
+ t.display = "flex", t.alignItems = "center", t.justifyContent = "center", t.position = "fixed", t.inset = "0";
31
+ }
32
+ attachAspectRatio(t) {
33
+ this.ratioDelegate ? (this.ratioDelegate.canvas = this.canvas, this.ratioDelegate.onResize = t, this.ratioDelegate.aspectRatio = this.aspectRatio, this.ratioDelegate.apply()) : (this.ratioDelegate = new s({
34
+ container: this.container,
35
+ canvas: this.canvas,
36
+ aspectRatio: this.aspectRatio,
37
+ onResize: t
38
+ }), this.ratioDelegate.attach());
39
+ }
40
+ destroy() {
41
+ this.ratioDelegate?.detach(), this.ratioDelegate = null;
42
+ }
43
+ ensureContainer(t, a) {
44
+ if (a)
45
+ return a;
46
+ if (t) {
47
+ const i = document.getElementById(t);
48
+ if (i)
49
+ return i;
50
+ }
51
+ const n = t || this.id || "zylem-root", e = document.createElement("main");
52
+ return e.setAttribute("id", n), e.style.position = "relative", e.style.width = "100%", e.style.height = "100%", document.body.appendChild(e), e;
53
+ }
54
+ }
55
+ export {
56
+ o as GameCanvas
57
+ };
@@ -0,0 +1,63 @@
1
+ import { StageInterface } from "../types";
2
+ import { GameInputConfig } from "./game-interfaces";
3
+ import { AspectRatio, AspectRatioValue } from "../device/aspect-ratio";
4
+ import { RetroPresetKey } from "./game-retro-resolutions";
5
+ export type GameConfigLike = Partial<{
6
+ id: string;
7
+ globals: Record<string, any>;
8
+ stages: StageInterface[];
9
+ debug: boolean;
10
+ time: number;
11
+ input: GameInputConfig;
12
+ /** numeric value or key in AspectRatio */
13
+ aspectRatio: AspectRatioValue | keyof typeof AspectRatio;
14
+ /** console/display preset to derive aspect ratio */
15
+ preset: RetroPresetKey;
16
+ /** lock internal render buffer to this resolution (e.g., '256x240' or { width, height }) */
17
+ resolution: string | {
18
+ width: number;
19
+ height: number;
20
+ };
21
+ fullscreen: boolean;
22
+ /** CSS background value for document body */
23
+ bodyBackground: string;
24
+ /** existing container by reference */
25
+ container: HTMLElement;
26
+ /** create/find container by id */
27
+ containerId: string;
28
+ /** optional canvas if caller wants to manage it */
29
+ canvas: HTMLCanvasElement;
30
+ }>;
31
+ export declare class GameConfig {
32
+ id: string;
33
+ globals: Record<string, any>;
34
+ stages: StageInterface[];
35
+ debug: boolean;
36
+ time: number;
37
+ input: GameInputConfig | undefined;
38
+ aspectRatio: number;
39
+ internalResolution: {
40
+ width: number;
41
+ height: number;
42
+ } | undefined;
43
+ fullscreen: boolean;
44
+ bodyBackground: string | undefined;
45
+ container: HTMLElement;
46
+ containerId?: string | undefined;
47
+ canvas?: HTMLCanvasElement | undefined;
48
+ constructor(id: string, globals: Record<string, any>, stages: StageInterface[], debug: boolean, time: number, input: GameInputConfig | undefined, aspectRatio: number, internalResolution: {
49
+ width: number;
50
+ height: number;
51
+ } | undefined, fullscreen: boolean, bodyBackground: string | undefined, container: HTMLElement, containerId?: string | undefined, canvas?: HTMLCanvasElement | undefined);
52
+ }
53
+ export declare function createDefaultGameConfig(base?: Partial<Pick<GameConfig, 'id' | 'debug' | 'time' | 'input'>> & {
54
+ stages?: StageInterface[];
55
+ globals?: Record<string, any>;
56
+ }): GameConfig;
57
+ export declare function resolveGameConfig(user?: GameConfigLike): GameConfig;
58
+ /**
59
+ * Factory for authoring configuration objects in user code.
60
+ * Returns a plain object that can be passed to `game(...)`.
61
+ */
62
+ export declare function gameConfig(config: GameConfigLike): GameConfigLike;
63
+ //# sourceMappingURL=game-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"game-config.d.ts","sourceRoot":"","sources":["../../../src/lib/game/game-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAA0D,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAElH,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,eAAe,CAAC;IACvB,0CAA0C;IAC1C,WAAW,EAAE,gBAAgB,GAAG,MAAM,OAAO,WAAW,CAAC;IACzD,oDAAoD;IACpD,MAAM,EAAE,cAAc,CAAC;IACvB,4FAA4F;IAC5F,UAAU,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACvD,UAAU,EAAE,OAAO,CAAC;IACpB,6CAA6C;IAC7C,cAAc,EAAE,MAAM,CAAC;IACvB,sCAAsC;IACtC,SAAS,EAAE,WAAW,CAAC;IACvB,kCAAkC;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,MAAM,EAAE,iBAAiB,CAAC;CAC1B,CAAC,CAAC;AAEH,qBAAa,UAAU;IAEd,EAAE,EAAE,MAAM;IACV,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAC5B,MAAM,EAAE,cAAc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MAAM,EAAE,cAAc,GAAG,cAAc,CAEjE"}
@@ -0,0 +1,79 @@
1
+ import { AspectRatio as p } from "../device/aspect-ratio.js";
2
+ import { getDisplayAspect as b, parseResolution as y, getPresetResolution as R } from "./game-retro-resolutions.js";
3
+ class f {
4
+ id;
5
+ globals;
6
+ stages;
7
+ debug;
8
+ time;
9
+ input;
10
+ aspectRatio;
11
+ internalResolution;
12
+ fullscreen;
13
+ bodyBackground;
14
+ container;
15
+ containerId;
16
+ canvas;
17
+ constructor(i, o, n, e, l, d, r, a, g, c, s, h, m) {
18
+ this.id = i, this.globals = o, this.stages = n, this.debug = e, this.time = l, this.input = d, this.aspectRatio = r, this.internalResolution = a, this.fullscreen = g, this.bodyBackground = c, this.container = s, this.containerId = h, this.canvas = m;
19
+ }
20
+ }
21
+ function u(t, i) {
22
+ if (i)
23
+ return i;
24
+ if (t) {
25
+ const e = document.getElementById(t);
26
+ if (e)
27
+ return e;
28
+ }
29
+ const o = t || "zylem-root", n = document.createElement("main");
30
+ return n.setAttribute("id", o), n.style.position = "relative", n.style.width = "100%", n.style.height = "100%", document.body.appendChild(n), n;
31
+ }
32
+ function B(t) {
33
+ const i = t?.id ?? "zylem", o = u(i);
34
+ return new f(i, t?.globals ?? {}, t?.stages ?? [], !!t?.debug, t?.time ?? 0, t?.input, p.SixteenByNine, void 0, !0, "#000000", o, i, void 0);
35
+ }
36
+ function C(t) {
37
+ const i = B({
38
+ id: t?.id ?? "zylem",
39
+ debug: !!t?.debug,
40
+ time: t?.time ?? 0,
41
+ input: t?.input,
42
+ stages: t?.stages ?? [],
43
+ globals: t?.globals ?? {}
44
+ }), o = t?.containerId ?? i.containerId, n = u(o, t?.container ?? null), e = t?.aspectRatio;
45
+ let l = i.aspectRatio;
46
+ if (typeof e == "number" || e && typeof e == "string")
47
+ l = typeof e == "number" ? e : p[e] ?? i.aspectRatio;
48
+ else if (t?.preset)
49
+ try {
50
+ l = b(t.preset) || i.aspectRatio;
51
+ } catch {
52
+ l = i.aspectRatio;
53
+ }
54
+ const d = t?.fullscreen ?? i.fullscreen, r = t?.bodyBackground ?? i.bodyBackground;
55
+ let a;
56
+ if (t?.resolution) {
57
+ if (typeof t.resolution == "string") {
58
+ const c = y(t.resolution);
59
+ if (c && (a = c), !a && t.preset) {
60
+ const s = R(t.preset, t.resolution);
61
+ s && (a = { width: s.width, height: s.height });
62
+ }
63
+ } else if (typeof t.resolution == "object") {
64
+ const c = t.resolution.width, s = t.resolution.height;
65
+ Number.isFinite(c) && Number.isFinite(s) && (a = { width: c, height: s });
66
+ }
67
+ }
68
+ const g = t?.canvas ?? void 0;
69
+ return new f(t?.id ?? i.id, t?.globals ?? i.globals, t?.stages ?? i.stages, !!(t?.debug ?? i.debug), t?.time ?? i.time, t?.input ?? i.input, l, a, d, r, n, o, g);
70
+ }
71
+ function k(t) {
72
+ return { ...t };
73
+ }
74
+ export {
75
+ f as GameConfig,
76
+ B as createDefaultGameConfig,
77
+ k as gameConfig,
78
+ C as resolveGameConfig
79
+ };
@@ -0,0 +1,19 @@
1
+ import { Stage } from '../stage/stage';
2
+ import type { BasicTypes, BaseGlobals, ZylemGameConfig, GameInputConfig } from './game-interfaces';
3
+ export declare const gameDefaultsState: Partial<ZylemGameConfig<Stage, any, BaseGlobals>>;
4
+ /** Replace multiple defaults at once (shallow merge). */
5
+ export declare function setGameDefaults(partial: Partial<ZylemGameConfig<Stage, any, BaseGlobals>>): void;
6
+ /** Reset defaults back to library defaults. */
7
+ export declare function resetGameDefaults(): void;
8
+ /**
9
+ * Get a plain object copy of the current defaults.
10
+ */
11
+ export declare function getGameDefaultConfig<TGlobals extends Record<string, BasicTypes> = BaseGlobals>(): {
12
+ id: string;
13
+ globals: TGlobals;
14
+ stages: Stage[];
15
+ debug?: boolean;
16
+ time?: number;
17
+ input?: GameInputConfig;
18
+ };
19
+ //# sourceMappingURL=game-default.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"game-default.d.ts","sourceRoot":"","sources":["../../../src/lib/game/game-default.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAmBnG,eAAO,MAAM,iBAAiB,mDAE7B,CAAC;AAEF,yDAAyD;AACzD,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,KAAK,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC,GAAG,IAAI,CAEhG;AAED,+CAA+C;AAC/C,wBAAgB,iBAAiB,IAAI,IAAI,CAExC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,WAAW,KAAK;IAClG,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,QAAQ,CAAC;IAClB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,eAAe,CAAC;CACxB,CASA"}
@@ -0,0 +1,24 @@
1
+ import { proxy as i } from "valtio/vanilla";
2
+ import { stage as e } from "../stage/stage.js";
3
+ const a = () => ({
4
+ id: "zylem",
5
+ globals: {},
6
+ stages: [e()],
7
+ debug: !1,
8
+ time: 0,
9
+ input: void 0
10
+ }), t = i({ ...a() });
11
+ function g() {
12
+ return {
13
+ id: t.id ?? "zylem",
14
+ globals: t.globals ?? {},
15
+ stages: t.stages ?? [e()],
16
+ debug: t.debug,
17
+ time: t.time,
18
+ input: t.input
19
+ };
20
+ }
21
+ export {
22
+ t as gameDefaultsState,
23
+ g as getGameDefaultConfig
24
+ };
@@ -1,6 +1,6 @@
1
1
  import { UpdateFunction } from "../core/base-node-life-cycle";
2
2
  export type BasicTypes = number | string | boolean;
3
- export type GlobalVariablesType = Record<string, BasicTypes>;
3
+ export type BaseGlobals = Record<string, BasicTypes>;
4
4
  export type KeyboardMapping = Record<string, string[]>;
5
5
  export type MouseMapping = Record<string, string[]>;
6
6
  export interface GameInputPlayerConfig {
@@ -17,7 +17,7 @@ export interface GameInputConfig {
17
17
  p7?: GameInputPlayerConfig;
18
18
  p8?: GameInputPlayerConfig;
19
19
  }
20
- export interface ZylemGameConfig<StageInterface, GameInterface, TGlobals extends Record<string, BasicTypes> = GlobalVariablesType> {
20
+ export interface ZylemGameConfig<StageInterface, GameInterface, TGlobals extends BaseGlobals> {
21
21
  id: string;
22
22
  globals?: TGlobals;
23
23
  stages?: StageInterface[];
@@ -26,3 +26,4 @@ export interface ZylemGameConfig<StageInterface, GameInterface, TGlobals extends
26
26
  time?: number;
27
27
  input?: GameInputConfig;
28
28
  }
29
+ //# sourceMappingURL=game-interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"game-interfaces.d.ts","sourceRoot":"","sources":["../../../src/lib/game/game-interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AACnD,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAErD,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AACvD,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AAEpD,MAAM,WAAW,qBAAqB;IACrC,GAAG,CAAC,EAAE,eAAe,CAAC;IACtB,KAAK,CAAC,EAAE,YAAY,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC/B,EAAE,CAAC,EAAE,qBAAqB,CAAC;IAC3B,EAAE,CAAC,EAAE,qBAAqB,CAAC;IAC3B,EAAE,CAAC,EAAE,qBAAqB,CAAC;IA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