WIP: handle vertical and horizontal walls
This commit is contained in:
@@ -499,11 +499,14 @@ const Move = (() => {
|
|||||||
Position[entity_id] = cornerContactPosition(p.x, p.y, px, py, contact.corner, s.radius);
|
Position[entity_id] = cornerContactPosition(p.x, p.y, px, py, contact.corner, s.radius);
|
||||||
} else if (contact.edge) {
|
} else if (contact.edge) {
|
||||||
// if (isLandable(contact.edge) && s.gearDown) s.isLanded = true;
|
// if (isLandable(contact.edge) && s.gearDown) s.isLanded = true;
|
||||||
|
const isHorizontal = contact.edge.ya === contact.edge.yb;
|
||||||
|
const isVertical = contact.edge.xa === contact.edge.xb;
|
||||||
|
|
||||||
console.log("CURRENT POSITION", px, py);
|
console.log("CURRENT POSITION", px, py);
|
||||||
console.log("INTENDED POSITION", p.x, p.y);
|
console.log("INTENDED POSITION", p.x, p.y);
|
||||||
console.log("CONTACT POSITION", contact.position);
|
console.log("CONTACT POSITION", contact.position);
|
||||||
|
|
||||||
if (contact.edge.ya === contact.edge.yb) {
|
if (isHorizontal) {
|
||||||
if (contact.edge.xa < contact.edge.xb) {
|
if (contact.edge.xa < contact.edge.xb) {
|
||||||
if (v.y <= 0) {
|
if (v.y <= 0) {
|
||||||
Velocity[entity_id] = { x: v.x, y: v.y };
|
Velocity[entity_id] = { x: v.x, y: v.y };
|
||||||
@@ -521,6 +524,27 @@ const Move = (() => {
|
|||||||
Position[entity_id] = { x: p.x, y: p.y };
|
Position[entity_id] = { x: p.x, y: p.y };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (isVertical) {
|
||||||
|
if (contact.edge.ya > contact.edge.yb) {
|
||||||
|
if (v.x <= 0) {
|
||||||
|
Velocity[entity_id] = { x: v.x, y: v.y };
|
||||||
|
Position[entity_id] = { x: p.x, y: p.y };
|
||||||
|
} else if (v.x > 0) {
|
||||||
|
Velocity[entity_id] = { x: 0, y: v.y };
|
||||||
|
Position[entity_id] = { x: contact.position.x, y: p.y };
|
||||||
|
}
|
||||||
|
} else if (contact.edge.ya < contact.edge.yb) {
|
||||||
|
if (v.x <= 0) {
|
||||||
|
Velocity[entity_id] = { x: 0, y: v.y };
|
||||||
|
Position[entity_id] = { x: contact.position.x, y: p.y };
|
||||||
|
} else if (v.x > 0) {
|
||||||
|
Velocity[entity_id] = { x: v.x, y: v.y };
|
||||||
|
Position[entity_id] = { x: p.x, y: p.y };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 49 KiB |
Reference in New Issue
Block a user