create-mud 2.0.0-alpha.1.21 → 2.0.0-alpha.1.211

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 (229) hide show
  1. package/README.md +1 -1
  2. package/dist/cli.js +1 -1
  3. package/dist/templates/{minimal/packages/client → phaser}/.eslintrc +1 -3
  4. package/dist/templates/phaser/package.json +28 -0
  5. package/dist/templates/phaser/packages/art/.gitignore +0 -0
  6. package/dist/templates/phaser/packages/art/README.md +33 -0
  7. package/dist/templates/phaser/packages/art/config-sprites.json +21 -0
  8. package/dist/templates/phaser/packages/art/package.json +27 -0
  9. package/dist/templates/phaser/packages/art/scripts/cli.mjs +190 -0
  10. package/dist/templates/phaser/packages/art/scripts/export-tiled-types.ts +292 -0
  11. package/dist/templates/phaser/packages/art/sprites/golem/attack/0.png +0 -0
  12. package/dist/templates/phaser/packages/art/sprites/golem/attack/1.png +0 -0
  13. package/dist/templates/phaser/packages/art/sprites/golem/attack/2.png +0 -0
  14. package/dist/templates/phaser/packages/art/sprites/golem/attack/3.png +0 -0
  15. package/dist/templates/phaser/packages/art/sprites/golem/attack/4.png +0 -0
  16. package/dist/templates/phaser/packages/art/sprites/golem/attack/5.png +0 -0
  17. package/dist/templates/phaser/packages/art/sprites/golem/death/0.png +0 -0
  18. package/dist/templates/phaser/packages/art/sprites/golem/death/1.png +0 -0
  19. package/dist/templates/phaser/packages/art/sprites/golem/death/2.png +0 -0
  20. package/dist/templates/phaser/packages/art/sprites/golem/idle/0.png +0 -0
  21. package/dist/templates/phaser/packages/art/sprites/golem/idle/1.png +0 -0
  22. package/dist/templates/phaser/packages/art/sprites/golem/idle/2.png +0 -0
  23. package/dist/templates/phaser/packages/art/sprites/golem/idle/3.png +0 -0
  24. package/dist/templates/phaser/packages/art/tilesets/images/world.png +0 -0
  25. package/dist/templates/phaser/packages/art/tilesets/world.tsx +19 -0
  26. package/dist/templates/phaser/packages/client/.env +1 -0
  27. package/dist/templates/phaser/packages/client/.eslintrc +7 -0
  28. package/dist/templates/phaser/packages/client/index.html +39 -0
  29. package/dist/templates/phaser/packages/client/package.json +48 -0
  30. package/dist/templates/phaser/packages/client/public/assets/atlases/atlas.json +292 -0
  31. package/dist/templates/phaser/packages/client/public/assets/atlases/atlas.png +0 -0
  32. package/dist/templates/phaser/packages/client/public/assets/tilesets/world.png +0 -0
  33. package/dist/templates/phaser/packages/client/src/artTypes/world.ts +9 -0
  34. package/dist/templates/phaser/packages/client/src/index.tsx +11 -0
  35. package/dist/templates/phaser/packages/client/src/layers/network/createNetworkLayer.ts +24 -0
  36. package/dist/templates/phaser/packages/client/src/layers/phaser/configurePhaser.ts +91 -0
  37. package/dist/templates/phaser/packages/client/src/layers/phaser/constants.ts +22 -0
  38. package/dist/templates/phaser/packages/client/src/layers/phaser/createPhaserLayer.ts +33 -0
  39. package/dist/templates/phaser/packages/client/src/layers/phaser/systems/createCamera.ts +13 -0
  40. package/dist/templates/phaser/packages/client/src/layers/phaser/systems/createMapSystem.ts +32 -0
  41. package/dist/templates/phaser/packages/client/src/layers/phaser/systems/index.ts +1 -0
  42. package/dist/templates/phaser/packages/client/src/layers/phaser/systems/registerSystems.ts +8 -0
  43. package/dist/templates/phaser/packages/client/src/mud/contractComponents.ts +24 -0
  44. package/dist/templates/phaser/packages/client/src/mud/createClientComponents.ts +10 -0
  45. package/dist/templates/phaser/packages/client/src/mud/createSystemCalls.ts +21 -0
  46. package/dist/templates/phaser/packages/client/src/mud/getNetworkConfig.ts +53 -0
  47. package/dist/templates/phaser/packages/client/src/mud/setup.ts +16 -0
  48. package/dist/templates/phaser/packages/client/src/mud/setupNetwork.ts +102 -0
  49. package/dist/templates/phaser/packages/client/src/mud/supportedChains.ts +5 -0
  50. package/dist/templates/phaser/packages/client/src/mud/world.ts +3 -0
  51. package/dist/templates/phaser/packages/client/src/store.ts +38 -0
  52. package/dist/templates/phaser/packages/client/src/ui/App.tsx +23 -0
  53. package/dist/templates/phaser/packages/client/src/ui/LoadingScreen/BootScreen.tsx +42 -0
  54. package/dist/templates/phaser/packages/client/src/ui/LoadingScreen/LoadingBar.tsx +21 -0
  55. package/dist/templates/phaser/packages/client/src/ui/LoadingScreen/LoadingScreen.tsx +52 -0
  56. package/dist/templates/phaser/packages/client/src/ui/LoadingScreen/index.ts +1 -0
  57. package/dist/templates/phaser/packages/client/src/ui/PhaserLayer.tsx +20 -0
  58. package/dist/templates/phaser/packages/client/src/ui/UIRoot.tsx +20 -0
  59. package/dist/templates/phaser/packages/client/src/ui/Wrapper.tsx +5 -0
  60. package/dist/templates/phaser/packages/client/src/ui/hooks/useNetworkLayer.tsx +17 -0
  61. package/dist/templates/phaser/packages/client/src/ui/hooks/usePhaserLayer.tsx +87 -0
  62. package/dist/templates/phaser/packages/client/src/ui/hooks/usePromiseValue.ts +24 -0
  63. package/dist/templates/phaser/packages/client/src/ui/theme/ClickWrapper.tsx +18 -0
  64. package/dist/templates/phaser/packages/client/src/ui/theme/SpriteImage.tsx +52 -0
  65. package/dist/templates/{minimal → phaser}/packages/client/tsconfig.json +3 -4
  66. package/dist/templates/phaser/packages/client/vite.config.ts +15 -0
  67. package/dist/templates/phaser/packages/contracts/.env +8 -0
  68. package/dist/templates/{minimal → phaser}/packages/contracts/.gitignore +3 -2
  69. package/dist/templates/{minimal → phaser}/packages/contracts/.solhint.json +2 -1
  70. package/dist/templates/phaser/packages/contracts/foundry.toml +22 -0
  71. package/dist/templates/phaser/packages/contracts/mud.config.ts +10 -0
  72. package/dist/templates/phaser/packages/contracts/package.json +45 -0
  73. package/dist/templates/phaser/packages/contracts/remappings.txt +3 -0
  74. package/dist/templates/phaser/packages/contracts/script/PostDeploy.s.sol +17 -0
  75. package/dist/templates/phaser/packages/contracts/src/codegen/Tables.sol +6 -0
  76. package/dist/templates/phaser/packages/contracts/src/codegen/tables/Counter.sol +120 -0
  77. package/dist/templates/phaser/packages/contracts/src/codegen/world/IIncrementSystem.sol +8 -0
  78. package/dist/templates/phaser/packages/contracts/src/codegen/world/IWorld.sol +16 -0
  79. package/dist/templates/phaser/packages/contracts/src/systems/IncrementSystem.sol +14 -0
  80. package/dist/templates/phaser/packages/contracts/test/CounterTest.t.sol +38 -0
  81. package/dist/templates/phaser/packages/contracts/tsconfig.json +13 -0
  82. package/dist/templates/phaser/packages/contracts/worlds.json +5 -0
  83. package/dist/templates/react/.eslintrc +10 -0
  84. package/dist/templates/react/package.json +13 -3
  85. package/dist/templates/react/packages/client/.env +1 -0
  86. package/dist/templates/react/packages/client/.eslintrc +2 -12
  87. package/dist/templates/react/packages/client/package.json +18 -21
  88. package/dist/templates/react/packages/client/src/App.tsx +11 -13
  89. package/dist/templates/react/packages/client/src/MUDContext.tsx +21 -0
  90. package/dist/templates/react/packages/client/src/index.tsx +12 -31
  91. package/dist/templates/react/packages/client/src/mud/contractComponents.ts +24 -0
  92. package/dist/templates/react/packages/client/src/mud/createClientComponents.ts +10 -0
  93. package/dist/templates/react/packages/client/src/mud/createSystemCalls.ts +21 -0
  94. package/dist/templates/react/packages/client/src/mud/getNetworkConfig.ts +53 -0
  95. package/dist/templates/react/packages/client/src/mud/setup.ts +16 -0
  96. package/dist/templates/react/packages/client/src/mud/setupNetwork.ts +102 -0
  97. package/dist/templates/react/packages/client/src/mud/supportedChains.ts +5 -0
  98. package/dist/templates/react/packages/client/src/mud/world.ts +3 -0
  99. package/dist/templates/react/packages/client/tsconfig.json +0 -3
  100. package/dist/templates/react/packages/client/vite.config.ts +3 -0
  101. package/dist/templates/react/packages/contracts/.env +8 -0
  102. package/dist/templates/react/packages/contracts/.gitignore +3 -2
  103. package/dist/templates/react/packages/contracts/.solhint.json +2 -1
  104. package/dist/templates/react/packages/contracts/foundry.toml +13 -2
  105. package/dist/templates/react/packages/contracts/mud.config.ts +10 -0
  106. package/dist/templates/react/packages/contracts/package.json +25 -20
  107. package/dist/templates/react/packages/contracts/remappings.txt +3 -9
  108. package/dist/templates/react/packages/contracts/script/PostDeploy.s.sol +24 -0
  109. package/dist/templates/react/packages/contracts/src/codegen/Tables.sol +6 -0
  110. package/dist/templates/react/packages/contracts/src/codegen/tables/Counter.sol +120 -0
  111. package/dist/templates/react/packages/contracts/src/codegen/world/IIncrementSystem.sol +8 -0
  112. package/dist/templates/react/packages/contracts/src/codegen/world/IWorld.sol +16 -0
  113. package/dist/templates/react/packages/contracts/src/systems/IncrementSystem.sol +7 -15
  114. package/dist/templates/react/packages/contracts/test/CounterTest.t.sol +38 -0
  115. package/dist/templates/react/packages/contracts/tsconfig.json +9 -8
  116. package/dist/templates/react/packages/contracts/worlds.json +5 -0
  117. package/dist/templates/threejs/.eslintrc +10 -0
  118. package/dist/templates/threejs/.gitignore +1 -0
  119. package/dist/templates/threejs/.vscode/extensions.json +3 -0
  120. package/dist/templates/threejs/.vscode/settings.json +3 -0
  121. package/dist/templates/threejs/package.json +28 -0
  122. package/dist/templates/threejs/packages/client/.env +1 -0
  123. package/dist/templates/threejs/packages/client/.eslintrc +7 -0
  124. package/dist/templates/threejs/packages/client/.gitignore +3 -0
  125. package/dist/templates/threejs/packages/client/index.html +12 -0
  126. package/dist/templates/threejs/packages/client/package.json +41 -0
  127. package/dist/templates/threejs/packages/client/src/App.tsx +81 -0
  128. package/dist/templates/threejs/packages/client/src/MUDContext.tsx +21 -0
  129. package/dist/templates/threejs/packages/client/src/index.tsx +19 -0
  130. package/dist/templates/threejs/packages/client/src/mud/contractComponents.ts +26 -0
  131. package/dist/templates/threejs/packages/client/src/mud/createClientComponents.ts +10 -0
  132. package/dist/templates/threejs/packages/client/src/mud/createSystemCalls.ts +15 -0
  133. package/dist/templates/threejs/packages/client/src/mud/getNetworkConfig.ts +53 -0
  134. package/dist/templates/threejs/packages/client/src/mud/setup.ts +16 -0
  135. package/dist/templates/threejs/packages/client/src/mud/setupNetwork.ts +102 -0
  136. package/dist/templates/threejs/packages/client/src/mud/supportedChains.ts +5 -0
  137. package/dist/templates/threejs/packages/client/src/mud/world.ts +3 -0
  138. package/dist/templates/threejs/packages/client/src/useKeyboardMovement.ts +60 -0
  139. package/dist/templates/threejs/packages/client/tsconfig.json +19 -0
  140. package/dist/templates/threejs/packages/client/vite.config.ts +15 -0
  141. package/dist/templates/threejs/packages/contracts/.env +8 -0
  142. package/dist/templates/threejs/packages/contracts/.gitignore +11 -0
  143. package/dist/templates/threejs/packages/contracts/.prettierrc +8 -0
  144. package/dist/templates/threejs/packages/contracts/.solhint.json +12 -0
  145. package/dist/templates/threejs/packages/contracts/foundry.toml +22 -0
  146. package/dist/templates/threejs/packages/contracts/mud.config.ts +13 -0
  147. package/dist/templates/threejs/packages/contracts/package.json +45 -0
  148. package/dist/templates/threejs/packages/contracts/remappings.txt +3 -0
  149. package/dist/templates/threejs/packages/contracts/src/codegen/Tables.sol +6 -0
  150. package/dist/templates/threejs/packages/contracts/src/codegen/tables/Position.sol +263 -0
  151. package/dist/templates/threejs/packages/contracts/src/codegen/world/IMoveSystem.sol +8 -0
  152. package/dist/templates/threejs/packages/contracts/src/codegen/world/IWorld.sol +16 -0
  153. package/dist/templates/threejs/packages/contracts/src/systems/MoveSystem.sol +25 -0
  154. package/dist/templates/threejs/packages/contracts/tsconfig.json +13 -0
  155. package/dist/templates/threejs/packages/contracts/worlds.json +5 -0
  156. package/dist/templates/threejs/pnpm-workspace.yaml +2 -0
  157. package/dist/templates/vanilla/.eslintrc +10 -0
  158. package/dist/templates/vanilla/.gitignore +1 -0
  159. package/dist/templates/vanilla/.vscode/extensions.json +3 -0
  160. package/dist/templates/vanilla/.vscode/settings.json +3 -0
  161. package/dist/templates/vanilla/package.json +28 -0
  162. package/dist/templates/vanilla/packages/client/.env +1 -0
  163. package/dist/templates/vanilla/packages/client/.gitignore +3 -0
  164. package/dist/templates/vanilla/packages/client/package.json +32 -0
  165. package/dist/templates/vanilla/packages/client/src/index.ts +22 -0
  166. package/dist/templates/vanilla/packages/client/src/mud/contractComponents.ts +24 -0
  167. package/dist/templates/vanilla/packages/client/src/mud/createClientComponents.ts +10 -0
  168. package/dist/templates/vanilla/packages/client/src/mud/createSystemCalls.ts +21 -0
  169. package/dist/templates/vanilla/packages/client/src/mud/getNetworkConfig.ts +53 -0
  170. package/dist/templates/vanilla/packages/client/src/mud/setup.ts +16 -0
  171. package/dist/templates/vanilla/packages/client/src/mud/setupNetwork.ts +102 -0
  172. package/dist/templates/vanilla/packages/client/src/mud/supportedChains.ts +5 -0
  173. package/dist/templates/vanilla/packages/client/src/mud/world.ts +3 -0
  174. package/dist/templates/vanilla/packages/client/tsconfig.json +18 -0
  175. package/dist/templates/{minimal → vanilla}/packages/client/vite.config.ts +3 -0
  176. package/dist/templates/vanilla/packages/contracts/.env +8 -0
  177. package/dist/templates/vanilla/packages/contracts/.gitignore +11 -0
  178. package/dist/templates/vanilla/packages/contracts/.prettierrc +8 -0
  179. package/dist/templates/vanilla/packages/contracts/.solhint.json +12 -0
  180. package/dist/templates/vanilla/packages/contracts/foundry.toml +22 -0
  181. package/dist/templates/vanilla/packages/contracts/mud.config.ts +10 -0
  182. package/dist/templates/vanilla/packages/contracts/package.json +45 -0
  183. package/dist/templates/vanilla/packages/contracts/remappings.txt +3 -0
  184. package/dist/templates/vanilla/packages/contracts/script/PostDeploy.s.sol +24 -0
  185. package/dist/templates/vanilla/packages/contracts/src/codegen/Tables.sol +6 -0
  186. package/dist/templates/vanilla/packages/contracts/src/codegen/tables/Counter.sol +120 -0
  187. package/dist/templates/vanilla/packages/contracts/src/codegen/world/IIncrementSystem.sol +8 -0
  188. package/dist/templates/vanilla/packages/contracts/src/codegen/world/IWorld.sol +16 -0
  189. package/dist/templates/vanilla/packages/contracts/src/systems/IncrementSystem.sol +14 -0
  190. package/dist/templates/vanilla/packages/contracts/test/CounterTest.t.sol +38 -0
  191. package/dist/templates/vanilla/packages/contracts/tsconfig.json +13 -0
  192. package/dist/templates/vanilla/packages/contracts/worlds.json +5 -0
  193. package/dist/templates/vanilla/pnpm-workspace.yaml +2 -0
  194. package/package.json +14 -11
  195. package/dist/templates/minimal/package.json +0 -18
  196. package/dist/templates/minimal/packages/client/package.json +0 -37
  197. package/dist/templates/minimal/packages/client/src/config.ts +0 -22
  198. package/dist/templates/minimal/packages/client/src/index.ts +0 -37
  199. package/dist/templates/minimal/packages/contracts/chainSpec.json +0 -5
  200. package/dist/templates/minimal/packages/contracts/deploy.json +0 -4
  201. package/dist/templates/minimal/packages/contracts/exports.sh +0 -22
  202. package/dist/templates/minimal/packages/contracts/foundry.toml +0 -11
  203. package/dist/templates/minimal/packages/contracts/package.json +0 -40
  204. package/dist/templates/minimal/packages/contracts/remappings.txt +0 -9
  205. package/dist/templates/minimal/packages/contracts/src/components/CounterComponent.sol +0 -9
  206. package/dist/templates/minimal/packages/contracts/src/libraries/LibMath.sol +0 -10
  207. package/dist/templates/minimal/packages/contracts/src/systems/IncrementSystem.sol +0 -22
  208. package/dist/templates/minimal/packages/contracts/src/systems/README.md +0 -7
  209. package/dist/templates/minimal/packages/contracts/src/test/Deploy.sol +0 -19
  210. package/dist/templates/minimal/packages/contracts/src/test/Deploy.t.sol +0 -14
  211. package/dist/templates/minimal/packages/contracts/src/test/LibDeploy.sol +0 -22
  212. package/dist/templates/minimal/packages/contracts/tsconfig.json +0 -12
  213. package/dist/templates/react/packages/client/src/config.ts +0 -22
  214. package/dist/templates/react/packages/contracts/chainSpec.json +0 -5
  215. package/dist/templates/react/packages/contracts/deploy.json +0 -4
  216. package/dist/templates/react/packages/contracts/exports.sh +0 -22
  217. package/dist/templates/react/packages/contracts/src/components/CounterComponent.sol +0 -9
  218. package/dist/templates/react/packages/contracts/src/libraries/LibMath.sol +0 -10
  219. package/dist/templates/react/packages/contracts/src/systems/README.md +0 -7
  220. package/dist/templates/react/packages/contracts/src/test/Deploy.sol +0 -19
  221. package/dist/templates/react/packages/contracts/src/test/Deploy.t.sol +0 -14
  222. package/dist/templates/react/packages/contracts/src/test/LibDeploy.sol +0 -22
  223. /package/dist/templates/{minimal → phaser}/.gitignore +0 -0
  224. /package/dist/templates/{minimal → phaser}/.vscode/extensions.json +0 -0
  225. /package/dist/templates/{minimal → phaser}/.vscode/settings.json +0 -0
  226. /package/dist/templates/{minimal → phaser}/packages/client/.gitignore +0 -0
  227. /package/dist/templates/{minimal → phaser}/packages/contracts/.prettierrc +0 -0
  228. /package/dist/templates/{minimal → phaser}/pnpm-workspace.yaml +0 -0
  229. /package/dist/templates/{minimal → vanilla}/packages/client/index.html +0 -0
@@ -0,0 +1 @@
1
+ VITE_CHAIN_ID=31337
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": ["../../.eslintrc", "plugin:react/recommended", "plugin:react-hooks/recommended"],
3
+ "plugins": ["react", "react-hooks"],
4
+ "rules": {
5
+ "react/react-in-jsx-scope": "off"
6
+ }
7
+ }
@@ -0,0 +1,39 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>a minimal MUD client</title>
7
+
8
+ <style>
9
+ body,
10
+ p,
11
+ h1,
12
+ h2,
13
+ h3,
14
+ h4,
15
+ h5,
16
+ h6,
17
+ ul,
18
+ ol,
19
+ li,
20
+ dl,
21
+ dt,
22
+ dd,
23
+ form,
24
+ input,
25
+ textarea,
26
+ button,
27
+ img {
28
+ all: initial;
29
+ margin: 0;
30
+ padding: 0;
31
+ border: none;
32
+ }
33
+ </style>
34
+ </head>
35
+ <body>
36
+ <div id="react-root"></div>
37
+ <script type="module" src="/src/index.tsx"></script>
38
+ </body>
39
+ </html>
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "client",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "scripts": {
8
+ "build": "vite build",
9
+ "dev": "wait-port localhost:8545 && vite",
10
+ "initialize": "pnpm build",
11
+ "preview": "vite preview",
12
+ "test": "tsc --noEmit"
13
+ },
14
+ "dependencies": {
15
+ "@ethersproject/providers": "^5.7.2",
16
+ "@latticexyz/common": "{{mud-version}}",
17
+ "@latticexyz/dev-tools": "{{mud-version}}",
18
+ "@latticexyz/network": "{{mud-version}}",
19
+ "@latticexyz/phaserx": "{{mud-version}}",
20
+ "@latticexyz/react": "{{mud-version}}",
21
+ "@latticexyz/recs": "{{mud-version}}",
22
+ "@latticexyz/schema-type": "{{mud-version}}",
23
+ "@latticexyz/std-client": "{{mud-version}}",
24
+ "@latticexyz/utils": "{{mud-version}}",
25
+ "@latticexyz/world": "{{mud-version}}",
26
+ "@wagmi/chains": "^0.2.14",
27
+ "contracts": "workspace:*",
28
+ "ethers": "^5.7.2",
29
+ "lodash": "^4.17.21",
30
+ "react": "^18.2.0",
31
+ "react-dom": "^18.2.0",
32
+ "simplex-noise": "^4.0.1",
33
+ "styled-components": "^5.3.10",
34
+ "use-resize-observer": "^9.1.0",
35
+ "zustand": "^4.3.8"
36
+ },
37
+ "devDependencies": {
38
+ "@types/lodash": "^4.14.194",
39
+ "@types/react": "^18.2.6",
40
+ "@types/react-dom": "^18.2.4",
41
+ "@types/styled-components": "^5.1.26",
42
+ "@vitejs/plugin-react": "^3.1.0",
43
+ "eslint-plugin-react": "7.31.11",
44
+ "eslint-plugin-react-hooks": "4.6.0",
45
+ "vite": "^4.2.1",
46
+ "wait-port": "^1.0.4"
47
+ }
48
+ }
@@ -0,0 +1,292 @@
1
+ {
2
+ "meta": {
3
+ "app": "",
4
+ "version": "1.0.0"
5
+ },
6
+ "textures": [
7
+ {
8
+ "image": "atlas.png?timestamp=1684344504521",
9
+ "format": "RGBA8888",
10
+ "size": {
11
+ "w": 2048,
12
+ "h": 2048
13
+ },
14
+ "scale": 1,
15
+ "frames": [
16
+ {
17
+ "filename": "sprites/golem/attack/0.png",
18
+ "rotated": false,
19
+ "trimmed": false,
20
+ "sourceSize": {
21
+ "w": 32,
22
+ "h": 32
23
+ },
24
+ "spriteSourceSize": {
25
+ "x": 0,
26
+ "y": 0,
27
+ "w": 32,
28
+ "h": 32
29
+ },
30
+ "frame": {
31
+ "x": 0,
32
+ "y": 0,
33
+ "w": 32,
34
+ "h": 32
35
+ }
36
+ },
37
+ {
38
+ "filename": "sprites/golem/attack/1.png",
39
+ "rotated": false,
40
+ "trimmed": false,
41
+ "sourceSize": {
42
+ "w": 32,
43
+ "h": 32
44
+ },
45
+ "spriteSourceSize": {
46
+ "x": 0,
47
+ "y": 0,
48
+ "w": 32,
49
+ "h": 32
50
+ },
51
+ "frame": {
52
+ "x": 32,
53
+ "y": 0,
54
+ "w": 32,
55
+ "h": 32
56
+ }
57
+ },
58
+ {
59
+ "filename": "sprites/golem/attack/2.png",
60
+ "rotated": false,
61
+ "trimmed": false,
62
+ "sourceSize": {
63
+ "w": 32,
64
+ "h": 32
65
+ },
66
+ "spriteSourceSize": {
67
+ "x": 0,
68
+ "y": 0,
69
+ "w": 32,
70
+ "h": 32
71
+ },
72
+ "frame": {
73
+ "x": 0,
74
+ "y": 32,
75
+ "w": 32,
76
+ "h": 32
77
+ }
78
+ },
79
+ {
80
+ "filename": "sprites/golem/attack/3.png",
81
+ "rotated": false,
82
+ "trimmed": false,
83
+ "sourceSize": {
84
+ "w": 32,
85
+ "h": 32
86
+ },
87
+ "spriteSourceSize": {
88
+ "x": 0,
89
+ "y": 0,
90
+ "w": 32,
91
+ "h": 32
92
+ },
93
+ "frame": {
94
+ "x": 32,
95
+ "y": 32,
96
+ "w": 32,
97
+ "h": 32
98
+ }
99
+ },
100
+ {
101
+ "filename": "sprites/golem/attack/4.png",
102
+ "rotated": false,
103
+ "trimmed": false,
104
+ "sourceSize": {
105
+ "w": 32,
106
+ "h": 32
107
+ },
108
+ "spriteSourceSize": {
109
+ "x": 0,
110
+ "y": 0,
111
+ "w": 32,
112
+ "h": 32
113
+ },
114
+ "frame": {
115
+ "x": 64,
116
+ "y": 0,
117
+ "w": 32,
118
+ "h": 32
119
+ }
120
+ },
121
+ {
122
+ "filename": "sprites/golem/attack/5.png",
123
+ "rotated": false,
124
+ "trimmed": false,
125
+ "sourceSize": {
126
+ "w": 32,
127
+ "h": 32
128
+ },
129
+ "spriteSourceSize": {
130
+ "x": 0,
131
+ "y": 0,
132
+ "w": 32,
133
+ "h": 32
134
+ },
135
+ "frame": {
136
+ "x": 64,
137
+ "y": 32,
138
+ "w": 32,
139
+ "h": 32
140
+ }
141
+ },
142
+ {
143
+ "filename": "sprites/golem/death/0.png",
144
+ "rotated": false,
145
+ "trimmed": false,
146
+ "sourceSize": {
147
+ "w": 32,
148
+ "h": 32
149
+ },
150
+ "spriteSourceSize": {
151
+ "x": 0,
152
+ "y": 0,
153
+ "w": 32,
154
+ "h": 32
155
+ },
156
+ "frame": {
157
+ "x": 0,
158
+ "y": 64,
159
+ "w": 32,
160
+ "h": 32
161
+ }
162
+ },
163
+ {
164
+ "filename": "sprites/golem/death/1.png",
165
+ "rotated": false,
166
+ "trimmed": false,
167
+ "sourceSize": {
168
+ "w": 32,
169
+ "h": 32
170
+ },
171
+ "spriteSourceSize": {
172
+ "x": 0,
173
+ "y": 0,
174
+ "w": 32,
175
+ "h": 32
176
+ },
177
+ "frame": {
178
+ "x": 32,
179
+ "y": 64,
180
+ "w": 32,
181
+ "h": 32
182
+ }
183
+ },
184
+ {
185
+ "filename": "sprites/golem/death/2.png",
186
+ "rotated": false,
187
+ "trimmed": false,
188
+ "sourceSize": {
189
+ "w": 32,
190
+ "h": 32
191
+ },
192
+ "spriteSourceSize": {
193
+ "x": 0,
194
+ "y": 0,
195
+ "w": 32,
196
+ "h": 32
197
+ },
198
+ "frame": {
199
+ "x": 64,
200
+ "y": 64,
201
+ "w": 32,
202
+ "h": 32
203
+ }
204
+ },
205
+ {
206
+ "filename": "sprites/golem/idle/0.png",
207
+ "rotated": false,
208
+ "trimmed": false,
209
+ "sourceSize": {
210
+ "w": 32,
211
+ "h": 32
212
+ },
213
+ "spriteSourceSize": {
214
+ "x": 0,
215
+ "y": 0,
216
+ "w": 32,
217
+ "h": 32
218
+ },
219
+ "frame": {
220
+ "x": 96,
221
+ "y": 0,
222
+ "w": 32,
223
+ "h": 32
224
+ }
225
+ },
226
+ {
227
+ "filename": "sprites/golem/idle/1.png",
228
+ "rotated": false,
229
+ "trimmed": false,
230
+ "sourceSize": {
231
+ "w": 32,
232
+ "h": 32
233
+ },
234
+ "spriteSourceSize": {
235
+ "x": 0,
236
+ "y": 0,
237
+ "w": 32,
238
+ "h": 32
239
+ },
240
+ "frame": {
241
+ "x": 96,
242
+ "y": 32,
243
+ "w": 32,
244
+ "h": 32
245
+ }
246
+ },
247
+ {
248
+ "filename": "sprites/golem/idle/2.png",
249
+ "rotated": false,
250
+ "trimmed": false,
251
+ "sourceSize": {
252
+ "w": 32,
253
+ "h": 32
254
+ },
255
+ "spriteSourceSize": {
256
+ "x": 0,
257
+ "y": 0,
258
+ "w": 32,
259
+ "h": 32
260
+ },
261
+ "frame": {
262
+ "x": 96,
263
+ "y": 64,
264
+ "w": 32,
265
+ "h": 32
266
+ }
267
+ },
268
+ {
269
+ "filename": "sprites/golem/idle/3.png",
270
+ "rotated": false,
271
+ "trimmed": false,
272
+ "sourceSize": {
273
+ "w": 32,
274
+ "h": 32
275
+ },
276
+ "spriteSourceSize": {
277
+ "x": 0,
278
+ "y": 0,
279
+ "w": 32,
280
+ "h": 32
281
+ },
282
+ "frame": {
283
+ "x": 0,
284
+ "y": 0,
285
+ "w": 32,
286
+ "h": 32
287
+ }
288
+ }
289
+ ]
290
+ }
291
+ ]
292
+ }
@@ -0,0 +1,9 @@
1
+ // GENERATED CODE - DO NOT MODIFY BY HAND
2
+
3
+ export enum Tileset {
4
+ Grass = 0,
5
+ Mountain = 1,
6
+ Forest = 2,
7
+ }
8
+ export enum TileAnimationKey {}
9
+ export const TileAnimations: { [key in TileAnimationKey]: number[] } = {};
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import ReactDOM from "react-dom/client";
3
+ import { App } from "./ui/App";
4
+ import { mount as mountDevTools } from "@latticexyz/dev-tools";
5
+
6
+ const rootElement = document.getElementById("react-root");
7
+ if (!rootElement) throw new Error("React root not found");
8
+ const root = ReactDOM.createRoot(rootElement);
9
+
10
+ root.render(<App />);
11
+ mountDevTools();
@@ -0,0 +1,24 @@
1
+ import { world } from "../../mud/world";
2
+ import { setup } from "../../mud/setup";
3
+
4
+ export type NetworkLayer = Awaited<ReturnType<typeof createNetworkLayer>>;
5
+
6
+ export const createNetworkLayer = async () => {
7
+ const {
8
+ components,
9
+ network: { singletonEntity },
10
+ systemCalls,
11
+ } = await setup();
12
+
13
+ // Give components a Human-readable ID
14
+ Object.entries(components).forEach(([name, component]) => {
15
+ component.id = name;
16
+ });
17
+
18
+ return {
19
+ world,
20
+ singletonEntity,
21
+ systemCalls,
22
+ components,
23
+ };
24
+ };
@@ -0,0 +1,91 @@
1
+ import {
2
+ defineSceneConfig,
3
+ AssetType,
4
+ defineScaleConfig,
5
+ defineMapConfig,
6
+ defineCameraConfig,
7
+ } from "@latticexyz/phaserx";
8
+ import worldTileset from "../../../public/assets/tilesets/world.png";
9
+ import { TileAnimations, Tileset } from "../../artTypes/world";
10
+ import { Sprites, Assets, Maps, Scenes, TILE_HEIGHT, TILE_WIDTH, Animations } from "./constants";
11
+
12
+ const ANIMATION_INTERVAL = 200;
13
+
14
+ const mainMap = defineMapConfig({
15
+ chunkSize: TILE_WIDTH * 64, // tile size * tile amount
16
+ tileWidth: TILE_WIDTH,
17
+ tileHeight: TILE_HEIGHT,
18
+ backgroundTile: [Tileset.Grass],
19
+ animationInterval: ANIMATION_INTERVAL,
20
+ tileAnimations: TileAnimations,
21
+ layers: {
22
+ layers: {
23
+ Background: { tilesets: ["Default"] },
24
+ Foreground: { tilesets: ["Default"] },
25
+ },
26
+ defaultLayer: "Background",
27
+ },
28
+ });
29
+
30
+ export const phaserConfig = {
31
+ sceneConfig: {
32
+ [Scenes.Main]: defineSceneConfig({
33
+ assets: {
34
+ [Assets.Tileset]: {
35
+ type: AssetType.Image,
36
+ key: Assets.Tileset,
37
+ path: worldTileset,
38
+ },
39
+ [Assets.MainAtlas]: {
40
+ type: AssetType.MultiAtlas,
41
+ key: Assets.MainAtlas,
42
+ // Add a timestamp to the end of the path to prevent caching
43
+ path: `/assets/atlases/atlas.json?timestamp=${Date.now()}`,
44
+ options: {
45
+ imagePath: "/assets/atlases/",
46
+ },
47
+ },
48
+ },
49
+ maps: {
50
+ [Maps.Main]: mainMap,
51
+ },
52
+ sprites: {
53
+ [Sprites.Soldier]: {
54
+ assetKey: Assets.MainAtlas,
55
+ frame: "sprites/soldier/idle/0.png",
56
+ },
57
+ },
58
+ animations: [
59
+ {
60
+ key: Animations.SwordsmanIdle,
61
+ assetKey: Assets.MainAtlas,
62
+ startFrame: 0,
63
+ endFrame: 3,
64
+ frameRate: 6,
65
+ repeat: -1,
66
+ prefix: "sprites/soldier/idle/",
67
+ suffix: ".png",
68
+ },
69
+ ],
70
+ tilesets: {
71
+ Default: {
72
+ assetKey: Assets.Tileset,
73
+ tileWidth: TILE_WIDTH,
74
+ tileHeight: TILE_HEIGHT,
75
+ },
76
+ },
77
+ }),
78
+ },
79
+ scale: defineScaleConfig({
80
+ parent: "phaser-game",
81
+ zoom: 1,
82
+ mode: Phaser.Scale.NONE,
83
+ }),
84
+ cameraConfig: defineCameraConfig({
85
+ pinchSpeed: 1,
86
+ wheelSpeed: 1,
87
+ maxZoom: 3,
88
+ minZoom: 1,
89
+ }),
90
+ cullingChunkSize: TILE_HEIGHT * 16,
91
+ };
@@ -0,0 +1,22 @@
1
+ export enum Scenes {
2
+ Main = "Main",
3
+ }
4
+
5
+ export enum Maps {
6
+ Main = "Main",
7
+ }
8
+
9
+ export enum Animations {
10
+ SwordsmanIdle = "SwordsmanIdle",
11
+ }
12
+ export enum Sprites {
13
+ Soldier,
14
+ }
15
+
16
+ export enum Assets {
17
+ MainAtlas = "MainAtlas",
18
+ Tileset = "Tileset",
19
+ }
20
+
21
+ export const TILE_HEIGHT = 32;
22
+ export const TILE_WIDTH = 32;
@@ -0,0 +1,33 @@
1
+ import { createPhaserEngine } from "@latticexyz/phaserx";
2
+ import { namespaceWorld } from "@latticexyz/recs";
3
+ import { NetworkLayer } from "../network/createNetworkLayer";
4
+ import { registerSystems } from "./systems";
5
+
6
+ export type PhaserLayer = Awaited<ReturnType<typeof createPhaserLayer>>;
7
+ type PhaserEngineConfig = Parameters<typeof createPhaserEngine>[0];
8
+
9
+ export const createPhaserLayer = async (networkLayer: NetworkLayer, phaserConfig: PhaserEngineConfig) => {
10
+ const world = namespaceWorld(networkLayer.world, "phaser");
11
+
12
+ const { game, scenes, dispose: disposePhaser } = await createPhaserEngine(phaserConfig);
13
+ world.registerDisposer(disposePhaser);
14
+
15
+ const { camera } = scenes.Main;
16
+
17
+ camera.phaserCamera.setBounds(-1000, -1000, 2000, 2000);
18
+ camera.phaserCamera.centerOn(0, 0);
19
+
20
+ const components = {};
21
+
22
+ const layer = {
23
+ networkLayer,
24
+ world,
25
+ game,
26
+ scenes,
27
+ components,
28
+ };
29
+
30
+ registerSystems(layer);
31
+
32
+ return layer;
33
+ };
@@ -0,0 +1,13 @@
1
+ import { PhaserLayer } from "../createPhaserLayer";
2
+
3
+ export const createCamera = (layer: PhaserLayer) => {
4
+ const {
5
+ scenes: {
6
+ Main: {
7
+ camera: { phaserCamera },
8
+ },
9
+ },
10
+ } = layer;
11
+
12
+ phaserCamera.centerOn(0, 0);
13
+ };
@@ -0,0 +1,32 @@
1
+ import { Tileset } from "../../../artTypes/world";
2
+ import { PhaserLayer } from "../createPhaserLayer";
3
+ import { createNoise2D } from "simplex-noise";
4
+
5
+ export function createMapSystem(layer: PhaserLayer) {
6
+ const {
7
+ scenes: {
8
+ Main: {
9
+ maps: {
10
+ Main: { putTileAt },
11
+ },
12
+ },
13
+ },
14
+ } = layer;
15
+
16
+ const noise = createNoise2D();
17
+
18
+ for (let x = -500; x < 500; x++) {
19
+ for (let y = -500; y < 500; y++) {
20
+ const coord = { x, y };
21
+ const seed = noise(x, y);
22
+
23
+ putTileAt(coord, Tileset.Grass, "Background");
24
+
25
+ if (seed >= 0.45) {
26
+ putTileAt(coord, Tileset.Mountain, "Foreground");
27
+ } else if (seed < -0.45) {
28
+ putTileAt(coord, Tileset.Forest, "Foreground");
29
+ }
30
+ }
31
+ }
32
+ }
@@ -0,0 +1 @@
1
+ export * from "./registerSystems";
@@ -0,0 +1,8 @@
1
+ import { PhaserLayer } from "../createPhaserLayer";
2
+ import { createCamera } from "./createCamera";
3
+ import { createMapSystem } from "./createMapSystem";
4
+
5
+ export const registerSystems = (layer: PhaserLayer) => {
6
+ createCamera(layer);
7
+ createMapSystem(layer);
8
+ };
@@ -0,0 +1,24 @@
1
+ /* Autogenerated file. Do not edit manually. */
2
+
3
+ import { TableId } from "@latticexyz/utils";
4
+ import { defineComponent, Type as RecsType, World } from "@latticexyz/recs";
5
+
6
+ export function defineContractComponents(world: World) {
7
+ return {
8
+ Counter: (() => {
9
+ const tableId = new TableId("", "Counter");
10
+ return defineComponent(
11
+ world,
12
+ {
13
+ value: RecsType.Number,
14
+ },
15
+ {
16
+ metadata: {
17
+ contractId: tableId.toHexString(),
18
+ tableId: tableId.toString(),
19
+ },
20
+ }
21
+ );
22
+ })(),
23
+ };
24
+ }