Skip to content

Commit

Permalink
phaser example
Browse files Browse the repository at this point in the history
  • Loading branch information
ponderingdemocritus committed Dec 13, 2023
1 parent ec49cda commit 46d3adb
Show file tree
Hide file tree
Showing 67 changed files with 830 additions and 448 deletions.
Binary file modified bun.lockb
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ VITE_PUBLIC_ETH_CONTRACT_ADDRESS=0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c74
VITE_PUBLIC_ACCOUNT_CLASS_HASH=0x04d07e40e93398ed3c76981e72dd1fd22557a78ce36c0515f679e27f0bb5bc5f
VITE_PUBLIC_MASTER_ADDRESS=0x517ececd29116499f4a1b64b094da79ba08dfd54a3edaa316134c41f8160973
VITE_PUBLIC_MASTER_PRIVATE_KEY=0x1800000000300000180000000000030000000000003006001800006600
VITE_PUBLIC_WORLD_ADDRESS=0x534692277764b04cfc469858891b825c799d1da550d2509fdd5be2f32abdaa0
VITE_PUBLIC_WORLD_ADDRESS=0x33ac2f528bb97cc7b79148fd1756dc368be0e95d391d8c6d6473ecb60b4560e
VITE_PUBLIC_NODE_URL=http://localhost:5050
VITE_PUBLIC_TORII=http://localhost:8080
VITE_PUBLIC_TORII=http://localhost:8080
VITE_PUBLIC_DEV=true
8 changes: 8 additions & 0 deletions examples/react-phaser-example/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"trailingComma": "es5",
"tabWidth": 4,
"semi": true,
"singleQuote": false,
"bracketSpacing": true,
"printWidth": 80
}
Binary file added examples/react-phaser-example/bun.lockb
Binary file not shown.
19 changes: 0 additions & 19 deletions examples/react-phaser-example/codegen.ts

This file was deleted.

16 changes: 16 additions & 0 deletions examples/react-phaser-example/components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "default",
"rsc": false,
"tsx": true,
"tailwind": {
"config": "tailwind.config.js",
"css": "src/index.css",
"baseColor": "stone",
"cssVariables": true
},
"aliases": {
"components": "src/components",
"utils": "src/lib/utils"
}
}
2 changes: 1 addition & 1 deletion examples/react-phaser-example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
<title>🪨 v 📄 x ✂️</title>
</head>
<body>
<div id="root"></div>
Expand Down
22 changes: 15 additions & 7 deletions examples/react-phaser-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,27 @@
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
"codegen": "graphql-codegen",
"components": "npx @dojoengine/core ../dojo-starter/target/dev/manifest.json src/dojo/contractComponents.ts http://localhost:5050 0x534692277764b04cfc469858891b825c799d1da550d2509fdd5be2f32abdaa0"
"components": "npx @dojoengine/core ../dojo-starter/target/dev/manifest.json src/dojo/contractComponents.ts http://localhost:5050 0x33ac2f528bb97cc7b79148fd1756dc368be0e95d391d8c6d6473ecb60b4560e"
},
"dependencies": {
"@dojoengine/core": "link:dojo-packages/packages/core",
"@dojoengine/create-burner": "link:dojo-packages/packages/create-burner",
"@dojoengine/torii-client": "link:dojo-packages/packages/torii-client",
"@dojoengine/torii-wasm": "link:dojo-packages/packages/torii-wasm",
"@dojoengine/utils": "link:dojo-packages/packages/utils",
"@dojoengine/react": "link:dojo-packages/packages/react",
"@dojoengine/recs": "0.1.35",
"@latticexyz/utils": "^2.0.0-next.11",
"@latticexyz/phaserx": "^2.0.0-next.11",
"@latticexyz/phaserx": "^2.0.0-next.14",
"@latticexyz/utils": "^2.0.0-next.14",
"@radix-ui/react-slot": "^1.0.2",
"alea": "^1.0.1",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"ethers": "^5.7.2",
"events": "^3.3.0",
"graphql": "^16.7.1",
"graphql-request": "^6.1.0",
"lucide-react": "^0.292.0",
"mobx": "^6.9.0",
"phaser": "3.60.0-beta.14",
"proxy-deep": "^3.1.1",
Expand All @@ -33,16 +39,18 @@
"simplex-noise": "^4.0.1",
"starknet": "5.19.5",
"styled-components": "^6.0.7",
"zustand": "^4.4.1",
"tailwind-merge": "^2.0.0",
"tailwindcss-animate": "^1.0.7",
"vite-plugin-top-level-await": "^1.3.1",
"vite-plugin-wasm": "^3.2.2"
"vite-plugin-wasm": "^3.2.2",
"zustand": "^4.4.1"
},
"devDependencies": {
"@graphql-codegen/cli": "^5.0.0",
"@graphql-codegen/typescript": "^4.0.1",
"@graphql-codegen/typescript-graphql-request": "^5.0.0",
"@graphql-codegen/typescript-operations": "^4.0.1",
"@types/node": "^20.4.8",
"@types/node": "^20.9.0",
"@types/react": "^18.0.37",
"@types/react-dom": "^18.0.11",
"@typescript-eslint/eslint-plugin": "^5.59.0",
Expand All @@ -54,7 +62,7 @@
"eslint-plugin-react-refresh": "^0.3.4",
"postcss": "^8.4.31",
"tailwindcss": "^3.3.5",
"typescript": "^5.0.2",
"typescript": "^5.2.2",
"vite": "^4.3.9"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"textures": [
{
"image": "atlas.png?timestamp=1678825051140",
"image": "../texture.png?timestamp=1678825051140",
"format": "RGBA8888",
"size": {
"w": 2048,
Expand All @@ -14,7 +14,7 @@
"scale": 1,
"frames": [
{
"filename": "sprites/soldier/idle/0.png",
"filename": "sprites/paper/0.png",
"rotated": false,
"trimmed": false,
"sourceSize": {
Expand All @@ -35,7 +35,7 @@
}
},
{
"filename": "sprites/soldier/idle/1.png",
"filename": "sprites/rock/0.png",
"rotated": false,
"trimmed": false,
"sourceSize": {
Expand All @@ -56,7 +56,7 @@
}
},
{
"filename": "sprites/soldier/idle/2.png",
"filename": "sprites/scissors/0.png",
"rotated": false,
"trimmed": false,
"sourceSize": {
Expand All @@ -70,31 +70,10 @@
"h": 32
},
"frame": {
"x": 0,
"y": 32,
"w": 32,
"h": 32
}
},
{
"filename": "sprites/soldier/idle/3.png",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 32,
"h": 32
},
"spriteSourceSize": {
"x": 0,
"x": 64,
"y": 0,
"w": 32,
"h": 32
},
"frame": {
"x": 32,
"y": 32,
"w": 32,
"h": 32
}
}
]
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/react-phaser-example/public/assets/rock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
83 changes: 83 additions & 0 deletions examples/react-phaser-example/public/assets/texture.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"textures": [
{
"image": "texture.png",
"format": "RGBA8888",
"size": {
"w": 96,
"h": 32
},
"scale": 1,
"frames": [
{
"filename": "paper.png",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 32,
"h": 32
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 32,
"h": 32
},
"frame": {
"x": 0,
"y": 0,
"w": 32,
"h": 32
}
},
{
"filename": "rock.png",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 32,
"h": 32
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 32,
"h": 32
},
"frame": {
"x": 32,
"y": 0,
"w": 32,
"h": 32
}
},
{
"filename": "scissors.png",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 32,
"h": 32
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 32,
"h": 32
},
"frame": {
"x": 64,
"y": 0,
"w": 32,
"h": 32
}
}
]
}
],
"meta": {
"app": "https://www.codeandweb.com/texturepacker",
"version": "3.0",
"smartupdate": "$TexturePacker:SmartUpdate:7dd38248733509cfafbacea47809c895:4ba9ad81aa06f2955894ea13212a26b7:88db1022cd6b660616541d2788fcd4f7$"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/react-phaser-example/public/paper.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/react-phaser-example/public/rock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/react-phaser-example/public/scissors.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/react-phaser-example/public/texture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion examples/react-phaser-example/readme.md
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
## Integrate Phaser with Dojo: A Quick Start Guide
12 changes: 8 additions & 4 deletions examples/react-phaser-example/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { useEffect } from "react";
import { useNetworkLayer } from "./hooks/useNetworkLayer";
import { useNetworkLayer } from "./ui/hooks/useNetworkLayer";
import { PhaserLayer } from "./phaser/phaserLayer";
import { store } from "./store/store";
import { store } from "./store";
import { UI } from "./ui";

function App() {
const networkLayer = useNetworkLayer();

useEffect(() => {
if (!networkLayer) return;
if (!networkLayer || !networkLayer.account) return;

console.log("Setting network layer");

Expand All @@ -17,8 +17,12 @@ function App() {

return (
<div>
<div className="w-full h-screen bg-black text-white flex justify-center">
<div className="self-center">
{!networkLayer && "loading..."}
</div>
</div>
<PhaserLayer networkLayer={networkLayer} />

<UI />
</div>
);
Expand Down
Binary file added examples/react-phaser-example/src/assets/paper.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion examples/react-phaser-example/src/assets/react.svg

This file was deleted.

Binary file added examples/react-phaser-example/src/assets/rock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 46d3adb

Please sign in to comment.