Skip to content

Commit d3131c2

Browse files
Merge pull request steam-bell-92#654 from Pratikshya32/fix/2048-game-over-check
fix: routing mobile swipe actions through makeMove validation in 2048
2 parents d7a69e8 + dc96456 commit d3131c2

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

web-app/js/projects/2048-game.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -454,16 +454,11 @@ function init2048Game() {
454454
let moved = false;
455455

456456
if (Math.abs(dx) > Math.abs(dy)) {
457-
if (dx > 30) moved = moveRight();
458-
else if (dx < -30) moved = moveLeft();
457+
if (dx > 30) makeMove("right");
458+
else if (dx < -30) makeMove("left");
459459
} else {
460-
if (dy > 30) moved = moveDown();
461-
else if (dy < -30) moved = moveUp();
462-
}
463-
464-
if(moved) {
465-
addNewTile();
466-
drawBoard();
460+
if (dy > 30) makeMove("down");
461+
else if (dy < -30) makeMove("up");
467462
}
468463
}, { passive: false });
469464

0 commit comments

Comments
 (0)