mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-02-21 20:18:14 +07:00
Added max steps parameter to path generation
Added max steps parameter to path generation to avoid some behavior on Android with 1 unit walls Android movement should be reimplemented as raycasting to help with moving near walls
This commit is contained in:
parent
bc4f1f83b8
commit
8bbaec639b
@ -233,8 +233,18 @@ public class Entity {
|
||||
}
|
||||
|
||||
public void setPath(Map map, Vector3 dst) {
|
||||
setPath(map, dst, -1);
|
||||
}
|
||||
|
||||
public void setPath(Map map, Vector3 dst, int maxSteps) {
|
||||
boolean success = map.findPath(position, dst, path);
|
||||
if (!success) return;
|
||||
if (maxSteps != -1 && path.getCount() > maxSteps) {
|
||||
path.clear();
|
||||
targets = Collections.emptyIterator();
|
||||
return;
|
||||
}
|
||||
|
||||
if (DEBUG_PATH) Gdx.app.debug(TAG, "path=" + path);
|
||||
map.smoothPath(path);
|
||||
targets = new Array.ArrayIterator<>(path.nodes);
|
||||
|
@ -371,7 +371,7 @@ public class GameScreen extends ScreenAdapter implements LoadingScreen.Loadable
|
||||
float rad = MathUtils.atan2(y, x);
|
||||
x = Direction.getOffX(rad);
|
||||
y = Direction.getOffY(rad);
|
||||
player.setPath(map, new Vector3(x, y, 0).add(player.position()));
|
||||
player.setPath(map, new Vector3(x, y, 0).add(player.position()), 3);
|
||||
}
|
||||
} else {
|
||||
if (Gdx.input.isButtonPressed(Input.Buttons.LEFT)) {
|
||||
|
Loading…
Reference in New Issue
Block a user