From 2d72c7f83ef0546555128acbdfdf8dcd6c8a5fb2 Mon Sep 17 00:00:00 2001 From: Catalin Constantin Mititiuc Date: Sun, 28 Dec 2025 16:28:04 -0800 Subject: [PATCH] WIP: land --- html/images/space.svg | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/html/images/space.svg b/html/images/space.svg index 7e5dd5c..02ed568 100644 --- a/html/images/space.svg +++ b/html/images/space.svg @@ -567,12 +567,14 @@ const collE = getCollisionEdges(edgeszz, position); console.log("collision edges", collE); + current = s.collision; s.collision = detectCollisions(position, allWallCorners, findAllEdges(allEdgePts, position), collE); console.log("future position", xc, yc); - if (s.collision) { + if (!current && s.collision) { const baseSlope = slope(s.collision.edge); + if (Object.is(baseSlope, 0)) s.isLanded = true; const { xa, ya, xb, yb } = s.collision.edge; const baseLine = { x1: xa, y1: ya, x2: xb, y2: yb }; @@ -583,6 +585,7 @@ y2: s.position.y + s.velocity.y }; + console.log("COLLISION DETECTED", s.collision); console.log("baseSlope", baseSlope); const baseNrmlIntxn = perpIntxn(baseSlope, xa, ya, s.position.x, s.position.y); @@ -607,6 +610,9 @@ s.velocity = { x: 0, y: 0 }; s.position = { x: clPos.x, y: clPos.y } s.node.style.transform = `translate(${s.position.x}px, ${s.position.y}px)`; + } else if (current && s.collision) { + // nothing + s.velocity = { x: 0, y: 0 }; } else { // console.log("c"); @@ -763,7 +769,6 @@ if (drawCollisionLines) updateTriangles(position); if (s.collision && !s.isLanded) { - console.log(s.collision); started = false; isReadingKeys = false; walls.forEach(w => w.setAttribute('fill', 'red'));