Browse Source

fixes #260

tags/v0.1.7^2
Big Bad Waffle 6 years ago
parent
commit
d9b9f4508e
2 changed files with 21 additions and 9 deletions
  1. +6
    -0
      src/client/js/components/keyboardMover.js
  2. +15
    -9
      src/client/js/components/pather.js

+ 6
- 0
src/client/js/components/keyboardMover.js View File

@@ -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);


+ 15
- 9
src/client/js/components/pather.js View File

@@ -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);
}
};
});

Loading…
Cancel
Save