Pull collection out of function

This commit is contained in:
2025-12-21 16:30:35 -08:00
parent d0369ca229
commit 32c1d0e56d

View File

@@ -360,18 +360,16 @@
return hc <= shipRadius; return hc <= shipRadius;
} }
function detectCornerCollision([xc, yc], corners) { function detectCornerCollision([xc, yc], [x, y]) {
return corners.some(([x, y]) => { cornerPt.x = x - xc;
cornerPt.x = x - xc; cornerPt.y = y - yc;
cornerPt.y = y - yc;
return shipBody.isPointInFill(cornerPt); return shipBody.isPointInFill(cornerPt);
});
} }
function detectCollisions(position, walls, edges) { function detectCollisions(position, walls, edges) {
return [ return [
[walls, wall => detectCornerCollision(position, wall)], [walls, wall => wall.some(corner => detectCornerCollision(position, corner))],
[edges, edge => detectEdgeCollision(position, edge)] [edges, edge => detectEdgeCollision(position, edge)]
].some(([t, f]) => t.some(f)) ].some(([t, f]) => t.some(f))
} }

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB