MCPcopy Create free account
hub / github.com/Code-Bullet/Jump-King / AreLinesColliding

Function AreLinesColliding

Player.js:1304–1314  ·  view source on GitHub ↗
(x1, y1, x2, y2, x3, y3, x4, y4)

Source from the content-addressed store, hash-verified

1302}
1303
1304function AreLinesColliding(x1, y1, x2, y2, x3, y3, x4, y4) {
1305 let uA = ((x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3)) / ((y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1));
1306 let uB = ((x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3)) / ((y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1));
1307 if (uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1) {
1308 let intersectionX = x1 + (uA * (x2 - x1));
1309 let intersectionY = y1 + (uA * (y2 - y1));
1310 return [true, intersectionX, intersectionY];
1311 }
1312 return [false, 0, 0]
1313
1314}

Callers 1

IsCollidingWithLineMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected