Skip to content

Commit

Permalink
Merge pull request #287 from dojoengine/fix/examples-readme
Browse files Browse the repository at this point in the history
fix: readme + phaser recs example
  • Loading branch information
ponderingdemocritus authored Oct 31, 2024
2 parents 6450e1a + ac99ffa commit c5c1fa1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
[submodule "worlds/onchain-dash"]
path = worlds/onchain-dash
url = https://github.com/MartianGreed/onchain-dash
[submodule "worlds/dojo-starter"]
path = worlds/dojo-starter
url = https://github.com/dojoengine/dojo-starter
8 changes: 4 additions & 4 deletions examples/example-nodejs-bot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ Features:
### Developing

```bash
bun install
pnpm install
```

### Terminal 1 - Serve the Bot

```bash
bun run serve
pnpm serve
```

### Terminal 2 - Build and Watch

```bash
bun run build --watch
pnpm build --watch
```

Now, try running it on your server. Remember to restart your bot after making changes.
Expand All @@ -46,7 +46,7 @@ You can access the GraphQL dashboard by navigating to [http://0.0.0.0:8080/graph
Add your GraphQL schema to `src/graphql/schema.graphql`, then run

```bash
bun run codegen
pnpm codegen
```

Now you can access the sdk in your app like:
Expand Down
5 changes: 1 addition & 4 deletions examples/example-vanillajs-phaser-recs/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,4 @@ export default setup(dojoConfig)
game.scene.add("MainScene", new SceneMain(dojo));
return game;
})
.catch((e) => {
console.error(e);
return;
});
.catch(console.error);
13 changes: 8 additions & 5 deletions examples/example-vanillajs-phaser-recs/src/scenes/scene-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default class SceneMain extends Scene {
return chunk;
}

update() {
async update() {
if (this.followPoint === null || this.followPoint === undefined) {
throw new Error("failed to initialize followPoint");
}
Expand Down Expand Up @@ -135,25 +135,28 @@ export default class SceneMain extends Scene {
if (null !== this.keyW && this.keyW.isDown) {
this.followPoint.y -= this.cameraSpeed;
this.cameras.main.centerOn(this.followPoint.x, this.followPoint.y);
this.dojo.systemCalls.move(this.dojo.account, Direction.Up);
await this.dojo.systemCalls.move(this.dojo.account, Direction.Up);
return;
}
if (null !== this.keyS && this.keyS.isDown) {
this.followPoint.y += this.cameraSpeed;
await this.dojo.systemCalls.move(this.dojo.account, Direction.Down);
this.cameras.main.centerOn(this.followPoint.x, this.followPoint.y);
this.dojo.systemCalls.move(this.dojo.account, Direction.Down);
return;
}
if (null !== this.keyA && this.keyA.isDown) {
this.followPoint.x -= this.cameraSpeed;
await this.dojo.systemCalls.move(this.dojo.account, Direction.Left);
this.cameras.main.centerOn(this.followPoint.x, this.followPoint.y);
this.dojo.systemCalls.move(this.dojo.account, Direction.Left);
return;
}
if (null !== this.keyD && this.keyD.isDown) {
this.followPoint.x += this.cameraSpeed;
await this.dojo.systemCalls.move(
this.dojo.account,
Direction.Right
);
this.cameras.main.centerOn(this.followPoint.x, this.followPoint.y);
this.dojo.systemCalls.move(this.dojo.account, Direction.Right);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ To run the examples, you'll need to set up three terminal windows:
3. Run Torii (indexer) with the world address and allowed origins:
```bash
torii --world 0xc82dfe2cb4f8a90dba1e88dfa24578aeb1c19152d51e3c7cf413be6d65d9e --allowed-origins "*"
torii --world <WORLD_ADDRESS> --allowed-origins "*"
```
Note: The world address may change. Ensure you're using the correct address from your migration output.
Expand Down

0 comments on commit c5c1fa1

Please sign in to comment.