Skip to content

Commit

Permalink
feat: using Wasm function + fix address value (dojo 0.5)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienbrs committed Jan 31, 2024
1 parent 0fb0712 commit 4ddc4f3
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/react/react-phaser-example/.env.development
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VITE_PUBLIC_ETH_CONTRACT_ADDRESS=0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7
VITE_PUBLIC_ACCOUNT_CLASS_HASH=0x04d07e40e93398ed3c76981e72dd1fd22557a78ce36c0515f679e27f0bb5bc5f
VITE_PUBLIC_MASTER_ADDRESS=0x517ececd29116499f4a1b64b094da79ba08dfd54a3edaa316134c41f8160973
VITE_PUBLIC_MASTER_ADDRESS=0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03
VITE_PUBLIC_MASTER_PRIVATE_KEY=0x1800000000300000180000000000030000000000003006001800006600
VITE_PUBLIC_WORLD_ADDRESS=0x33ac2f528bb97cc7b79148fd1756dc368be0e95d391d8c6d6473ecb60b4560e
VITE_PUBLIC_NODE_URL=http://localhost:5050
Expand Down
7 changes: 4 additions & 3 deletions examples/react/react-phaser-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
"dependencies": {
"@dojoengine/core": "^0.5.0",
"@dojoengine/create-burner": "^0.5.0",
"@dojoengine/react": "^0.5.0",
"@dojoengine/recs": "0.1.35",
"@dojoengine/state": "^0.5.0",
"@dojoengine/torii-client": "^0.5.0",
"@dojoengine/torii-wasm": "^0.5.0",
"@dojoengine/utils": "^0.5.0",
"@dojoengine/react": "^0.5.0",
"@dojoengine/state": "^0.5.0",
"@dojoengine/recs": "0.1.35",
"@dojoengine/utils-wasm": "^0.3.3",
"@latticexyz/phaserx": "^2.0.0-next.14",
"@latticexyz/utils": "^2.0.0-next.14",
"@radix-ui/react-slot": "^1.0.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Tileset } from "../../assets/world";
import { PhaserLayer } from "../createPhaserLayer";
import { snoise } from "@dojoengine/utils";
import { snoise } from "@dojoengine/utils-wasm";
import { MAP_AMPLITUDE } from "../config/constants";

export function mapSystem(layer: PhaserLayer) {
Expand All @@ -17,11 +17,13 @@ export function mapSystem(layer: PhaserLayer) {
for (let x = 0; x < 50; x++) {
for (let y = 0; y < 50; y++) {
const coord = { x, y };
const noiseInput = new Float64Array([
x / MAP_AMPLITUDE,
0,
y / MAP_AMPLITUDE,
]);
// Get a noise value between 0 and 100
const seed = Math.floor(
((snoise([x / MAP_AMPLITUDE, 0, y / MAP_AMPLITUDE]) + 1) / 2) *
100
);
const seed = Math.floor(((snoise(noiseInput) + 1) / 2) * 100);

if (seed > 70) {
// This would be the highest 'elevation'
Expand Down
26 changes: 26 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4ddc4f3

Please sign in to comment.