Pull collection out of function
This commit is contained in:
@@ -360,18 +360,16 @@
|
||||
return hc <= shipRadius;
|
||||
}
|
||||
|
||||
function detectCornerCollision([xc, yc], corners) {
|
||||
return corners.some(([x, y]) => {
|
||||
cornerPt.x = x - xc;
|
||||
cornerPt.y = y - yc;
|
||||
function detectCornerCollision([xc, yc], [x, y]) {
|
||||
cornerPt.x = x - xc;
|
||||
cornerPt.y = y - yc;
|
||||
|
||||
return shipBody.isPointInFill(cornerPt);
|
||||
});
|
||||
return shipBody.isPointInFill(cornerPt);
|
||||
}
|
||||
|
||||
function detectCollisions(position, walls, edges) {
|
||||
return [
|
||||
[walls, wall => detectCornerCollision(position, wall)],
|
||||
[walls, wall => wall.some(corner => detectCornerCollision(position, corner))],
|
||||
[edges, edge => detectEdgeCollision(position, edge)]
|
||||
].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