An iteration of the original solution that maybe feels less bad
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+27
-39
@@ -196,11 +196,34 @@ export class HuntMode {
|
||||
this.faceLeft = false;
|
||||
}
|
||||
|
||||
let szX = 0.1;
|
||||
let szY = 0.1;
|
||||
let szX = 0.5;
|
||||
let szY = 0.5;
|
||||
|
||||
this.velocity = new Point(dx, dy);
|
||||
|
||||
// try to push us away from walls if we're close
|
||||
for (let offset of CARDINAL_DIRECTIONS.values()) {
|
||||
let bigBbox = new Rect(
|
||||
this.floatingPlayer
|
||||
.offset(offset.scale(new Size(0.06, 0.06)))
|
||||
.offset(new Point(-szX / 2, -szY / 2)),
|
||||
new Size(szX, szY),
|
||||
);
|
||||
|
||||
let hitsWall = false;
|
||||
for (let cell of bigBbox.overlappedCells(new Size(1, 1)).values()) {
|
||||
if (this.#blocksMovement(cell.top)) {
|
||||
hitsWall = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (hitsWall) {
|
||||
this.velocity = this.velocity.offset(
|
||||
offset.scale(new Point(0.005, 0.005)).negate(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let origin = new Point(szX / 2, szY / 2);
|
||||
let bbox = new Rect(
|
||||
this.floatingPlayer.offset(origin.negate()),
|
||||
@@ -210,44 +233,9 @@ export class HuntMode {
|
||||
this.isBlocked(b),
|
||||
);
|
||||
this.floatingPlayer = this.floatingPlayer.offset(displacement);
|
||||
// this.velocity = dxy;
|
||||
// this.velocity = dxy; // don't let the wall break our speed, this sucks on corners
|
||||
// let friction do it
|
||||
getPlayerProgress().spendBlood(displacement.distance(new Point(0, 0)) * 10);
|
||||
|
||||
// try to push us away from walls if we're close
|
||||
for (let { dist, strength } of [
|
||||
{ dist: 0.12, strength: 0.02 },
|
||||
{ dist: 0.22, strength: 0.015 },
|
||||
{ dist: 0.32, strength: 0.01 },
|
||||
].values()) {
|
||||
for (let offset of CARDINAL_DIRECTIONS.values()) {
|
||||
let bigBbox = new Rect(
|
||||
this.floatingPlayer
|
||||
.offset(offset.scale(new Size(dist, dist)))
|
||||
.offset(new Point(-szX / 2, -szY / 2)),
|
||||
new Size(szX, szY),
|
||||
);
|
||||
|
||||
let hitsWall = false;
|
||||
for (let cell of bigBbox.overlappedCells(new Size(1, 1)).values()) {
|
||||
if (this.#blocksMovement(cell.top)) {
|
||||
hitsWall = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (hitsWall) {
|
||||
bbox = new Rect(
|
||||
this.floatingPlayer.offset(origin.negate()),
|
||||
new Size(szX, szY),
|
||||
);
|
||||
let { displacement } = displace(
|
||||
bbox,
|
||||
offset.scale(new Point(strength, strength)).negate(),
|
||||
(b: Rect) => this.isBlocked(b),
|
||||
);
|
||||
this.floatingPlayer = this.floatingPlayer.offset(displacement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#updateFov() {
|
||||
|
||||
Reference in New Issue
Block a user