WIP: land
This commit is contained in:
@@ -567,12 +567,14 @@
|
|||||||
|
|
||||||
const collE = getCollisionEdges(edgeszz, position);
|
const collE = getCollisionEdges(edgeszz, position);
|
||||||
console.log("collision edges", collE);
|
console.log("collision edges", collE);
|
||||||
|
current = s.collision;
|
||||||
s.collision = detectCollisions(position, allWallCorners, findAllEdges(allEdgePts, position), collE);
|
s.collision = detectCollisions(position, allWallCorners, findAllEdges(allEdgePts, position), collE);
|
||||||
|
|
||||||
console.log("future position", xc, yc);
|
console.log("future position", xc, yc);
|
||||||
|
|
||||||
if (s.collision) {
|
if (!current && s.collision) {
|
||||||
const baseSlope = slope(s.collision.edge);
|
const baseSlope = slope(s.collision.edge);
|
||||||
|
if (Object.is(baseSlope, 0)) s.isLanded = true;
|
||||||
const { xa, ya, xb, yb } = s.collision.edge;
|
const { xa, ya, xb, yb } = s.collision.edge;
|
||||||
const baseLine = { x1: xa, y1: ya, x2: xb, y2: yb };
|
const baseLine = { x1: xa, y1: ya, x2: xb, y2: yb };
|
||||||
|
|
||||||
@@ -583,6 +585,7 @@
|
|||||||
y2: s.position.y + s.velocity.y
|
y2: s.position.y + s.velocity.y
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log("COLLISION DETECTED", s.collision);
|
||||||
|
|
||||||
console.log("baseSlope", baseSlope);
|
console.log("baseSlope", baseSlope);
|
||||||
const baseNrmlIntxn = perpIntxn(baseSlope, xa, ya, s.position.x, s.position.y);
|
const baseNrmlIntxn = perpIntxn(baseSlope, xa, ya, s.position.x, s.position.y);
|
||||||
@@ -607,6 +610,9 @@
|
|||||||
s.velocity = { x: 0, y: 0 };
|
s.velocity = { x: 0, y: 0 };
|
||||||
s.position = { x: clPos.x, y: clPos.y }
|
s.position = { x: clPos.x, y: clPos.y }
|
||||||
s.node.style.transform = `translate(${s.position.x}px, ${s.position.y}px)`;
|
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 {
|
} else {
|
||||||
// console.log("c");
|
// console.log("c");
|
||||||
|
|
||||||
@@ -763,7 +769,6 @@
|
|||||||
if (drawCollisionLines) updateTriangles(position);
|
if (drawCollisionLines) updateTriangles(position);
|
||||||
|
|
||||||
if (s.collision && !s.isLanded) {
|
if (s.collision && !s.isLanded) {
|
||||||
console.log(s.collision);
|
|
||||||
started = false;
|
started = false;
|
||||||
isReadingKeys = false;
|
isReadingKeys = false;
|
||||||
walls.forEach(w => w.setAttribute('fill', 'red'));
|
walls.forEach(w => w.setAttribute('fill', 'red'));
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
Reference in New Issue
Block a user