Skip to content

Commit

Permalink
dont move if not clicking on same row and column as player
Browse files Browse the repository at this point in the history
  • Loading branch information
k2xl committed Jun 27, 2024
1 parent 81e78e4 commit eb0282d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions components/level/game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,11 @@ export default function Game({
const dist = Math.abs(x - playerPosition.x + y - playerPosition.y);
let breaker = 0;

// if you are not on the same row and column as the player, don't move
if (x !== playerPosition.x && y !== playerPosition.y) {
return;
}

while (breaker < dist) {
moveByDXDY(x - playerPosition.x, y - playerPosition.y);
validTouchStart.current = false;
Expand Down

0 comments on commit eb0282d

Please sign in to comment.