Pull collection out of function
This commit is contained in:
@@ -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 |
Reference in New Issue
Block a user