diff --git a/registration-system/view/signups/game1/js/character.js b/registration-system/view/signups/game1/js/character.js index dd965075127f7cb6e946864d5f142c50fad429aa..2ead572408ea081aadf5a37695c8127ca624c5d8 100644 --- a/registration-system/view/signups/game1/js/character.js +++ b/registration-system/view/signups/game1/js/character.js @@ -109,25 +109,26 @@ Char.prototype.animate = function() { }; Char.prototype.physics = function() { if (this.moveTarget && this.moveTarget.length == 0) return; + if (Vec.equals(this.translation, this.moveTarget[0])) { this.moveTarget.shift(); - return; - } - - var v = Vec.add(Vec.flipSign(this.translation), this.moveTarget[0]); - var d = Vec.length(v); + } else { + var stuckFixer = 0; + do { + var v = Vec.add(Vec.flipSign(this.translation), this.moveTarget[0]); + var d = Vec.length(v); - if (d > this.maxSpeed) { - var n = Vec.mul(v, 1/d); // normalized - v = Vec.mul(n, this.maxSpeed); - } + if (d > this.maxSpeed) { + var n = Vec.mul(v, 1 / d); // normalized + v = Vec.mul(n, this.maxSpeed + stuckFixer); + } + stuckFixer += 0.5; - var nextPosition = (d < g_smallValue) ? this.moveTarget[0] : Vec.add(this.translation, v); + var nextPosition = (d < g_smallValue) ? this.moveTarget[0] : Vec.add(this.translation, v); + } while (!this.pathFinder.canWalkOn(nextPosition[0], nextPosition[1])); - if (this.pathFinder.canWalkOn(nextPosition[0], nextPosition[1])) Vec.assign(this.translation, nextPosition); - else - this.moveTarget.shift(); + } Game.eventHandler.triggerEventOn('walkon', this.translation[0], this.translation[1]);