Handle multiple edge collision in a buggy way

This commit is contained in:
2026-02-06 12:55:08 -08:00
parent 4f9db0a940
commit 340b30c8dc

View File

@@ -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 };

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB