WIP: position touching on collision
This commit is contained in:
@@ -625,18 +625,20 @@
|
|||||||
const el = document.createElementNS(namespaceURIsvg, 'line');
|
const el = document.createElementNS(namespaceURIsvg, 'line');
|
||||||
el.setAttribute('x1', foot.x);
|
el.setAttribute('x1', foot.x);
|
||||||
el.setAttribute('y1', foot.y);
|
el.setAttribute('y1', foot.y);
|
||||||
el.setAttribute('x2', xc);
|
el.setAttribute('x2', s.position.x);
|
||||||
el.setAttribute('y2', yc);
|
el.setAttribute('y2', s.position.y);
|
||||||
// the problem is that by this point the ship is already closer than
|
|
||||||
// its radius so the line is less than 5 units long
|
|
||||||
console.log("foot", foot, "line", el);
|
console.log("foot", foot, "line", el);
|
||||||
const [posX, posY] = [5 * Math.sin(radAngle), 5 * Math.cos(radAngle)];
|
const [posX, posY] = [5 * Math.sin(radAngle), 5 * Math.cos(radAngle)];
|
||||||
const collPt = el.getPointAtLength(5);
|
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 - posX, foot.y - posY);
|
||||||
let l = drawLine(foot.x, foot.y, foot.x - posY, foot.y - posX);
|
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: foot.x - posY, y: foot.y - posX };
|
s.position = { x: collPt.x, y: collPt.y };
|
||||||
// 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)`;
|
s.node.style.transform = `translate(${s.position.x}px, ${s.position.y}px)`;
|
||||||
} else {
|
} else {
|
||||||
console.log("c");
|
console.log("c");
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
Reference in New Issue
Block a user