Skip to content

Commit

Permalink
docs: fix emojimon map wrap (latticexyz#917)
Browse files Browse the repository at this point in the history
  • Loading branch information
holic authored May 19, 2023
1 parent 9e98a81 commit 76be5d2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions docs/pages/tutorials/emojimon/a-wild-emojimon-appears.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ function spawn(uint32 x, uint32 y) public {
// Constrain position to map size, wrapping around if necessary
(uint32 width, uint32 height, ) = MapConfig.get();
x = x + (width % width);
y = y + (height % height);
x = (x + width) % width;
y = (y + height) % height;
bytes32 position = positionToEntityKey(x, y);
require(!Obstruction.get(position), "this space is obstructed");
Expand Down Expand Up @@ -187,8 +187,8 @@ function move(uint32 x, uint32 y) public {
// Constrain position to map size, wrapping around if necessary
(uint32 width, uint32 height, ) = MapConfig.get();
x = x + (width % width);
y = y + (height % height);
x = (x + width) % width;
y = (y + height) % height;
Position.set(player, x, y);
Expand Down Expand Up @@ -229,8 +229,8 @@ function move(uint32 x, uint32 y) public {
// Constrain position to map size, wrapping around if necessary
(uint32 width, uint32 height, ) = MapConfig.get();
x = x + (width % width);
y = y + (height % height);
x = (x + width) % width;
y = (y + height) % height;
Position.set(player, x, y);
Expand Down
16 changes: 8 additions & 8 deletions docs/pages/tutorials/emojimon/map-and-terrain.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ contract MapSystem is System {
// Constrain position to map size, wrapping around if necessary
(uint32 width, uint32 height, ) = MapConfig.get();
x = x + (width % width);
y = y + (height % height);
x = (x + width) % width;
y = (y + height) % height;
bytes32 position = positionToEntityKey(x, y);
require(!Obstruction.get(position), "this space is obstructed");
Expand All @@ -317,8 +317,8 @@ contract MapSystem is System {
// Constrain position to map size, wrapping around if necessary
(uint32 width, uint32 height, ) = MapConfig.get();
x = x + (width % width);
y = y + (height % height);
x = (x + width) % width;
y = (y + height) % height;
Position.set(player, x, y);
}
Expand Down Expand Up @@ -449,8 +449,8 @@ function move(uint32 x, uint32 y) public {

// Constrain position to map size, wrapping around if necessary
(uint32 width, uint32 height, ) = MapConfig.get();
x = x + (width % width);
y = y + (height % height);
x = (x + width) % width;
y = (y + height) % height;

Position.set(player, x, y);
}
Expand All @@ -465,8 +465,8 @@ function spawn(uint32 x, uint32 y) public {

// Constrain position to map size, wrapping around if necessary
(uint32 width, uint32 height, ) = MapConfig.get();
x = x + (width % width);
y = y + (height % height);
x = (x + width) % width;
y = (y + height) % height;

Player.set(player, true);
Position.set(player, x, y);
Expand Down

0 comments on commit 76be5d2

Please sign in to comment.