WIP: position touching on collision

This commit is contained in:
2025-12-26 12:03:41 -08:00
parent c9b7c62365
commit b8df14625c

View File

@@ -625,18 +625,20 @@
const el = document.createElementNS(namespaceURIsvg, 'line');
el.setAttribute('x1', foot.x);
el.setAttribute('y1', foot.y);
el.setAttribute('x2', xc);
el.setAttribute('y2', yc);
// the problem is that by this point the ship is already closer than
// its radius so the line is less than 5 units long
el.setAttribute('x2', s.position.x);
el.setAttribute('y2', s.position.y);
console.log("foot", foot, "line", el);
const [posX, posY] = [5 * Math.sin(radAngle), 5 * Math.cos(radAngle)];
const collPt = el.getPointAtLength(5);
// let l = drawLine(foot.x, foot.y, foot.x - posX, foot.y - posY);
let l = drawLine(foot.x, foot.y, foot.x - posY, foot.y - posX);
console.log("line length", l.getTotalLength(), l);
s.position = { x: foot.x - posY, y: foot.y - posX };
// s.position = { x: collPt.x, y: collPt.y };
// s.position = { x: foot.x - posY, y: foot.y - posX };
s.position = { x: collPt.x, y: collPt.y };
console.log("line length", el.getTotalLength(), el, s.position);
console.log("line length", l.getTotalLength(), l, foot.x - posY, foot.y - posX);
s.node.style.transform = `translate(${s.position.x}px, ${s.position.y}px)`;
} else {
console.log("c");

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB