Anyone got a clue why this doesn’t work?
When I walk down or left it does getX()/getY() - speed once instead of doing that till it reaches the next tile in the list.
getCoordinateX() returns Math.ceil(x/32);
if (currentPath != null) {// Rounding issues.
Node p = currentPath
.getNextNode(getCoordinateX(), getCoordinateY());
if (p == null) {
currentPath = null;
setMoving(false);
} else {
setMoving(true);
Node next = new Node(p.x * 32, p.y * 32);
if (next.x > getX()) {//Right works
setX((int) Math.min(next.getX(), getX() + getSpeed()));
setDir(1);
if (getX() == next.x) {
if (nextPath != null)
currentPath = nextPath;
}
} else if (next.x < getX()) {//Left doesn"t
setX((int) Math.max(next.getX(), getX() - getSpeed()));
setDir(3);
if (getX() == next.x) {
if (nextPath != null)
currentPath = nextPath;
}
} else {
if (getX() == next.x) {
if (nextPath != null)
currentPath = nextPath;
}
}
if (next.y > getY()) {//Up works
setY((int) Math.min(next.getY(), getY() + getSpeed()));
setDir(0);
if (getY() == next.y) {
if (nextPath != null)
currentPath = nextPath;
}
} else if (next.y < getY()) {//Down doesn't
setY((int) Math.max(next.getY(), getY() - getSpeed()));
setDir(2);
if (getY() == next.y) {
if (nextPath != null)
currentPath = nextPath;
}
} else {
if (getY() == next.y) {
if (nextPath != null)
currentPath = nextPath;
}
}
}