diff --git a/html/images/space.svg b/html/images/space.svg index 6b96830..a5b7ab4 100644 --- a/html/images/space.svg +++ b/html/images/space.svg @@ -109,9 +109,9 @@ - + - + @@ -253,16 +253,10 @@ return { node: wall, edges: es }; }); - - // console.log("edgeszz", edgeszz); - // console.log("wall corners", allWallCorners); - const allEdgePts = allWallCorners.map(w => w.map((pt, i, arr) => [pt, arr[(i + 1) % arr.length]]) ); - // console.log("all edge points", allEdgePts); - let allStartingEdges; init(allEdgePts); @@ -487,7 +481,6 @@ } function slope({ xa, ya, xb, yb }) { - // const [[xa, ya], [xb, yb]] = edge.split(' ').map(n => n.split(',').map(n => +n)); return (yb - ya) / (xb - xa); } @@ -520,40 +513,19 @@ } function detectCollisions(position, walls, edges, z) { - // console.log("edges to test for collision", edgesToCheck); - // console.log("walls", walls); - // this returns the wall with the corner, no the corner let actualCorner; const corner = walls.find(wall => { - // console.log("checking corners on wall", wall); const c = wall.find(corner => detectCornerCollision(position, corner)); - // console.log("corner", c); actualCorner = c; - // console.log("c", c); return c; }); - // console.log("actual corner", actualCorner); - // if (corner) console.log("corner collision", corner); - const edge = z.find(({ edge: pts, node: ee }) => { const str = `${pts.xa},${pts.ya} ${pts.xb},${pts.yb}`; return detectEdgeCollision(position, pts); } ); - - // if (found) console.log("found", found.node, found.node.node.classList.contains("inverse")); - - // return [ - // [walls, wall => wall.some(corner => detectCornerCollision(position, corner))], - // [edges, edge => { - // const coll = detectEdgeCollision(position, edge); - // if (coll) console.log(edge, slope(edge) == -0); - // return coll; - // }] - // ].some(([t, f]) => t.some(f)) - return edge || actualCorner; } @@ -660,22 +632,13 @@ } function updateLines(elapsed, edges, currentPos, futurePos) { - // console.log("velocity", s.velocity); - // console.log("collision", s.collision); - // console.log("edges", edges); - - // const edgeIds = [...linesContainer.children].map(c => c.id); const edgeIds = edges.map(({edge: { xa, ya, xb, yb }}) => `normal${xa}-${ya}-${xb}-${yb}`); const nodes = [...linesContainer.children]; - // console.log("EDGE IDS", edgeIds, "NODES", nodes); - nodes.forEach(n => { if (!edgeIds.includes(n.id)) n.remove(); }); - console.log("update lines", currentPos, futurePos); - edges.forEach(({ edge: { xa, ya, xb, yb }}) => { const id = `normal${xa}-${ya}-${xb}-${yb}`; const g = linesContainer.querySelector(`#${id}`) || document.createElementNS(namespaceURIsvg, 'g'); @@ -791,18 +754,11 @@ } updateShip(s, elapsed, edgeszz); - // console.log("S POSITION", s.position); updateBullets(elapsed); // updateEdges(position); // if (!s.collision) updateLines(elapsed, collE, {x, y}, s.position); if (drawCollisionLines) updateTriangles(position); - // const collision = detectCollisions(position, allWallCorners, findAllEdges(allEdgePts, position), getCollisionEdges(edgeszz, position)); - - // console.log("collision", collision && collision.hasOwnProperty("edge")); - // console.log("landable?", isLandable(collision)); - - // console.log("collision", s.collision); if (s.collision && !s.isLanded) { console.log(s.collision); started = false; @@ -969,7 +925,7 @@ const svgP = pointerPt.matrixTransform(svg.getScreenCTM().inverse()); if (bg.isPointInFill(svgP)) { - console.log(Math.trunc(svgP.x), Math.trunc(svgP.y)); + // console.log(Math.trunc(svgP.x), Math.trunc(svgP.y)); xp.innerText = Math.trunc(svgP.x); yp.innerText = Math.trunc(svgP.y);