diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2018-11-06 20:19:41 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2018-11-06 20:19:41 +0100 |
commit | b30a4a28a666a65be21f95f4ec7cfd52841c68a0 (patch) | |
tree | 36eb318f4703f964cea437438f10b83680f87ec8 | |
parent | a3962f36aaa4d4aace4f56fca482d4f93df1b565 (diff) | |
download | rpgedit-b30a4a28a666a65be21f95f4ec7cfd52841c68a0.tar rpgedit-b30a4a28a666a65be21f95f4ec7cfd52841c68a0.zip |
controller/gamecontext: even nicer updateStep()
-rw-r--r-- | src/controller/gamecontext.ts | 8 |
1 files 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); |