diff --git a/html/images/space.svg b/html/images/space.svg
index bf05f88..df33c92 100644
--- a/html/images/space.svg
+++ b/html/images/space.svg
@@ -204,15 +204,16 @@
let acceleration; // meters per second per second
let rotate = 0;
- let mult = 1000;
+ let mult = 10000;
const s = {
position: { x: 0, y: 0 },
// velocity: { x: 0, y: 0 },
- // velocity: { x: 5, y: 10 },
- velocity: { x: 5*mult, y: 10*mult },
- acceleration: { x: 0, y: 0 },
+ velocity: { x: 5, y: 7 },
+ // velocity: { x: 5*mult, y: 8*mult },
+ acceleration: { x: 5, y: 7 },
+ // acceleration: { x: 0, y: 0 },
rotate: 0,
collision: null,
isLanded: false,
@@ -495,7 +496,7 @@
}
const { a, b } = perppts;
- if (a && b) drawLine(a.x, a.y, b.x, b.y);
+ // if (a && b) drawLine(a.x, a.y, b.x, b.y);
return walls.reduce((acc, w) => {
const filtered = a && b ? w.corners.filter(c => {
@@ -898,10 +899,10 @@
const changeY = 0.001 * elapsed * velocityY;
let { x, y } = s.position;
- console.log("current position", x, y);
+ // console.log("current position", x, y);
let position = [positionX, positionY] = [changeX + x, changeY + y];
let [xc, yc] = position;
- console.log("future position", xc, yc);
+ // console.log("future position", xc, yc);
const collE = getCollisionEdges(edgeszz, position);
@@ -910,16 +911,16 @@
const det = (xb - xa) * (y - ya) - (x - xa) * (yb - ya);
return det < 0;
});
- console.log("edges facing ship", efs);
+ // console.log("edges facing ship", efs);
+
+ const positionSeg = { xa: x, ya: y, xb: xc, yb: yc };
+
+ // console.log("positionSeg", positionSeg);
const edgeCollision = efs.find(({ edge, wall }) => {
const { xa, ya, xb, yb } = edge;
if (xc === x && yc === y) return;
- const positionSeg = { xa: x, ya: y, xb: xc, yb: yc };
- // const slopeps = slope(positionSeg);
- // const posNormIntxn = perpIntxn(slopeps, x, y, c.corner.x, c.corner.y);
-
const rise = yb - ya;
const run = xb - xa;
const length = distance(xa, ya, xb, yb);
@@ -939,10 +940,15 @@
const roundedT = +t.toFixed(2);
const roundedS = +s.toFixed(2);
- console.log("positionSeg", positionSeg, "edgeSeg", edgeSeg);
+ console.log("positionSeg", positionSeg);
+ console.log("edgeSeg", edgeSeg);
console.log("s", roundedS, "t", roundedT);
- return roundedS <= 1 && roundedT >= 0;
+ // return roundedS >= 0 && roundedS <= 1 && roundedT >= 0 && roundedT <= 1;
+ return roundedS <= 1 && roundedT >= 0 && roundedT <= 1;
+ // return roundedS >= 0 && roundedS <= 1 && roundedT <= 1;
+ // return roundedS >= 0 && roundedS <= 1 && roundedT <= 1;
+ // return false;
});
efs.forEach(({ edge, wall }) => {
@@ -996,7 +1002,8 @@
// return +hc.toFixed(2) <= shipRadius;
// });
- s.collision = cornerColl || edgeCollision;
+ // s.collision = cornerColl || edgeCollision;
+ s.collision = edgeCollision || cornerColl;
if (s.collision) console.log("COLLISION", s.collision);