summaryrefslogtreecommitdiffstats
path: root/src/controller
diff options
context:
space:
mode:
Diffstat (limited to 'src/controller')
-rw-r--r--src/controller/gamecontext.ts7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/controller/gamecontext.ts b/src/controller/gamecontext.ts
index 295872d..8107b31 100644
--- a/src/controller/gamecontext.ts
+++ b/src/controller/gamecontext.ts
@@ -39,6 +39,7 @@ export class GameContext {
private readonly entityPos: vec2 = vec2.clone([6, 6]);
private readonly entityMovement: vec2 = vec2.create();
+ private readonly collisionRadius = 7 / 16;
private readonly walls: LineSegment[] = [
LineSegment.fromPoints(vec2.fromValues(1, 1), vec2.fromValues(11, 1)),
@@ -99,10 +100,14 @@ export class GameContext {
const move = new Movement(this.entityPos, dest);
for (const w of this.walls) {
- if (!w.collidesMove(dest2, move))
+ if (!w.collidesMoveCircle(dest2, move, this.collisionRadius))
continue;
if (!vec2.exactEquals(dest, dest2)) {
+ // Ensure termination
+ if (vec2.squaredDistance(this.entityPos, dest2) >= vec2.squaredDistance(this.entityPos, dest))
+ return;
+
vec2.copy(dest, dest2);
rescan = true;
break;