From b30a4a28a666a65be21f95f4ec7cfd52841c68a0 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 6 Nov 2018 20:19:41 +0100 Subject: controller/gamecontext: even nicer updateStep() --- src/controller/gamecontext.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/controller/gamecontext.ts b/src/controller/gamecontext.ts index 38a08ed..b69b306 100644 --- a/src/controller/gamecontext.ts +++ b/src/controller/gamecontext.ts @@ -114,14 +114,12 @@ export class GameContext { const dest = vec2.scaleAndAdd(vec2.create(), this.entityPos, this.entityMovement, this.speed); const newDest = vec2.create(); - while (true) { - if (vec2.equals(dest, this.entityPos)) + while (this.updateStepCollide(newDest, dest)) { + if (vec2.equals(newDest, this.entityPos)) return; - if (!this.updateStepCollide(newDest, dest)) - break; - vec2.copy(dest, newDest); + } vec2.copy(this.entityPos, dest); -- cgit v1.2.3