1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { moveHead } from "https://esm.town/v/adamgonda/moveHead";
export function moveBody({ body, dir }) {
return body.map((part, index, arr) => {
if (index == 0) {
return moveHead(part, dir);
}
return {
...part,
x: arr[index - 1].x,
y: arr[index - 1].y,
pX: part.x,
pY: part.y,
};
});
}