SandGame/actions.js

15 lines
400 B
JavaScript
Raw Normal View History

2026-10-22 14:05:51 +00:00
import { grid } from './state.js';
export function move(x1, y1, x2, y2) {
grid[x2][y2] = grid[x1][y1];
grid[x1][y1] = null;
grid[x2][y2].updated = true;
}
export function swap(x1, y1, x2, y2) {
const temp = grid[x1][y1];
grid[x1][y1] = grid[x2][y2];
grid[x2][y2] = temp;
if (grid[x1][y1]) grid[x1][y1].updated = true;
if (grid[x2][y2]) grid[x2][y2].updated = true;
}