diff --git a/src/client/js/components/keyboardMover.js b/src/client/js/components/keyboardMover.js index c9a2e96d..cd97cb11 100644 --- a/src/client/js/components/keyboardMover.js +++ b/src/client/js/components/keyboardMover.js @@ -18,6 +18,9 @@ define([ }, update: function() { + if (this.obj.moveAnimation) + this.obj.pather.clearPath(); + if (input.isKeyDown('esc')) { client.request({ cpn: 'player', @@ -72,6 +75,9 @@ define([ this.addQueue(newX, newY); }, addQueue: function(x, y) { + if (this.obj.moveAnimation) + return; + this.obj.dirty = true; this.obj.pather.add(x, y); diff --git a/src/client/js/components/pather.js b/src/client/js/components/pather.js index a38e8e22..f29b5f6d 100644 --- a/src/client/js/components/pather.js +++ b/src/client/js/components/pather.js @@ -7,6 +7,7 @@ define([ ) { var scale = 40; var scaleMult = 5; + var round = Math.round.bind(Math); return { type: 'pather', @@ -28,11 +29,11 @@ define([ events.on('onDeath', this.onDeath.bind(this)); events.on('onClearQueue', this.onDeath.bind(this)); - this.pathPos.x = this.obj.x; - this.pathPos.y = this.obj.y; + this.pathPos.x = round(this.obj.x); + this.pathPos.y = round(this.obj.y); }, - onDeath: function() { + clearPath: function() { this.path.forEach(function(p) { renderer.destroyObject({ layerName: 'effects', @@ -41,8 +42,13 @@ define([ }); this.path = []; - this.pathPos.x = this.obj.x; - this.pathPos.y = this.obj.y; + }, + + onDeath: function() { + this.clearPath(); + + this.pathPos.x = round(this.obj.x); + this.pathPos.y = round(this.obj.y); }, add: function(x, y) { @@ -66,8 +72,8 @@ define([ var y = this.obj.y; if (this.path.length == 0) { - this.pathPos.x = x; - this.pathPos.y = y; + this.pathPos.x = round(x); + this.pathPos.y = round(y); } if ((x == this.lastX) && (y == this.lastY)) @@ -95,8 +101,8 @@ define([ setPath: function(path) { this.path = this.path.concat(path); - this.pathPos.x = path[path.length - 1].x; - this.pathPos.y = path[path.length - 1].y; + this.pathPos.x = round(path[path.length - 1].x); + this.pathPos.y = round(path[path.length - 1].y); } }; }); \ No newline at end of file