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