Skip to content
Snippets Groups Projects
Commit 73095d88 authored by Manuel Herrmann's avatar Manuel Herrmann
Browse files

castle fixup and pathfinder next try

parent ce774c51
No related branches found
No related tags found
No related merge requests found
...@@ -119,7 +119,7 @@ Char.prototype.physics = function() { ...@@ -119,7 +119,7 @@ Char.prototype.physics = function() {
var x = this.translation[0]; var x = this.translation[0];
var y = this.translation[1]; var y = this.translation[1];
var self = this; var self = this;
if (!this.pathFinder.canWalkOn(x-x%5, y-y%5)) { if (!this.pathFinder.canWalkOn(x, y)) {
var queue = [[x-x%5, y-y%5, null, null]]; var queue = [[x-x%5, y-y%5, null, null]];
function recoverWalkable() { function recoverWalkable() {
...@@ -165,7 +165,7 @@ Char.prototype.physics = function() { ...@@ -165,7 +165,7 @@ Char.prototype.physics = function() {
this.moveTarget.shift(); this.moveTarget.shift();
} else { } else {
var stuckFixer = 0; var stuckFixer = 0;
do { //do {
var v = Vec.add(Vec.flipSign(this.translation), this.moveTarget[0]); var v = Vec.add(Vec.flipSign(this.translation), this.moveTarget[0]);
var d = Vec.length(v); var d = Vec.length(v);
...@@ -173,19 +173,19 @@ Char.prototype.physics = function() { ...@@ -173,19 +173,19 @@ Char.prototype.physics = function() {
var n = Vec.mul(v, 1 / d); // normalized var n = Vec.mul(v, 1 / d); // normalized
v = Vec.mul(n, this.maxSpeed + stuckFixer); v = Vec.mul(n, this.maxSpeed + stuckFixer);
} }
stuckFixer += 0.5; /* stuckFixer += 0.5;
if (stuckFixer >= 4.0) { if (stuckFixer >= 4.0) {
this.setMoveTarget(this.translation[0], this.translation[1]); this.setMoveTarget(this.translation[0], this.translation[1]);
return; return;
} }*/
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])); //} while (!this.pathFinder.canWalkOn(nextPosition[0], nextPosition[1]));
if (stuckFixer >= 3.0) /*if (stuckFixer >= 3.0)
this.setMoveTarget(this.translation[0], this.translation[1]); this.setMoveTarget(this.translation[0], this.translation[1]);
else else*/
Vec.assign(this.translation, nextPosition); Vec.assign(this.translation, nextPosition);
} }
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment