From 340b30c8dc058fa41969fd5f41cbd445b8f1facf Mon Sep 17 00:00:00 2001 From: Catalin Constantin Mititiuc Date: Fri, 6 Feb 2026 12:55:08 -0800 Subject: [PATCH] Handle multiple edge collision in a buggy way --- html/images/space.svg | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/html/images/space.svg b/html/images/space.svg index 5659ec6..118f3f1 100644 --- a/html/images/space.svg +++ b/html/images/space.svg @@ -790,7 +790,7 @@ const Move = (() => { let posP; const contact = contacts[0]; - if (contact.corner) { + if (contacts.length == 1 && contact.corner) { contact.position = cornerContactPosition(p.x, p.y, px, py, contact.corner, s.radius); contact.position.x = +contact.position.x.toPrecision(13); contact.position.y = +contact.position.y.toPrecision(13); @@ -804,14 +804,12 @@ const Move = (() => { const tangentVect = { x: normalVect.y, y: -normalVect.x }; // drawLine(contact.position.x, contact.position.y, contact.position.x + tangentVect.x, contact.position.y + tangentVect.y, "green"); contact.velocity = bounceVector(v, tangentVect.x, tangentVect.y); - - // drawLine(contact.position.x, contact.position.y, contact.position.x + contact.velocity.x, contact.position.y + contact.velocity.y, "blue"); // Velocity[entity_id] = { x: 0, y: 0 }; Velocity[entity_id] = contact.velocity; Position[entity_id] = cornerContactPosition(p.x, p.y, px, py, contact.corner, s.radius); - } else if (contact.edge) { + } else if (contacts.length == 1 && contact.edge) { // if (isLandable(contact.edge) && s.gearDown) s.isLanded = true; const rise = contact.edge.yb-contact.edge.ya; const run = contact.edge.xb-contact.edge.xa; @@ -906,6 +904,10 @@ const Move = (() => { // drawCircle(newP.x, newP.y, "black"); Position[entity_id] = newP; + } else if (contacts.every(c => c.edge)) { + // all edges + // doing nothing seems to kind of work (but it's buggy), ideally we + // should add the vectors of all the contacts together } } else { Velocity[entity_id] = { x: v.x, y: v.y };