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.
+16
-28
@@ -196,33 +196,16 @@ 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);
|
||||
|
||||
let origin = new Point(szX / 2, szY / 2);
|
||||
let bbox = new Rect(
|
||||
this.floatingPlayer.offset(origin.negate()),
|
||||
new Size(szX, szY),
|
||||
);
|
||||
let { displacement, dxy } = displace(bbox, this.velocity, (b: Rect) =>
|
||||
this.isBlocked(b),
|
||||
);
|
||||
this.floatingPlayer = this.floatingPlayer.offset(displacement);
|
||||
// this.velocity = dxy;
|
||||
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(offset.scale(new Size(0.06, 0.06)))
|
||||
.offset(new Point(-szX / 2, -szY / 2)),
|
||||
new Size(szX, szY),
|
||||
);
|
||||
@@ -235,19 +218,24 @@ export class HuntMode {
|
||||
}
|
||||
}
|
||||
if (hitsWall) {
|
||||
bbox = new Rect(
|
||||
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()),
|
||||
new Size(szX, szY),
|
||||
);
|
||||
let { displacement } = displace(
|
||||
bbox,
|
||||
offset.scale(new Point(strength, strength)).negate(),
|
||||
(b: Rect) => this.isBlocked(b),
|
||||
let { displacement, dxy } = displace(bbox, this.velocity, (b: Rect) =>
|
||||
this.isBlocked(b),
|
||||
);
|
||||
this.floatingPlayer = this.floatingPlayer.offset(displacement);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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);
|
||||
}
|
||||
|
||||
#updateFov() {
|
||||
|
||||
Reference in New Issue
Block a user