experimental walk mode with space (axis-aligned)

This commit is contained in:
Ondřej Hruška
2014-04-22 02:19:55 +02:00
parent c94cd05da5
commit 233157a443
2 changed files with 14 additions and 1 deletions
@@ -79,6 +79,14 @@ public class WorldLayer extends ScreenLayer {
w.getPlayer().walk(0, 1); w.getPlayer().walk(0, 1);
} }
}); });
bindKey(new KeyStroke(true, Keys.SPACE), new Runnable() {
@Override
public void run()
{
w.getPlayer().walk(5, 5);
}
});
w.getPlayer().setTargetListener(new Runnable() { w.getPlayer().setTargetListener(new Runnable() {
+6 -1
View File
@@ -109,9 +109,14 @@ public class Player implements IonBundled, MapObserver, Updateable {
if (walkOffset.isFinished() && !target.equals(position)) { if (walkOffset.isFinished() && !target.equals(position)) {
int x = (target.x - position.x); int x = (target.x - position.x);
int y = (target.y - position.y);
if (Math.abs(x) >= Math.abs(y)) y = 0;
if (Math.abs(y) > Math.abs(x)) x = 0;
if (x > 0) x = 1; if (x > 0) x = 1;
if (x < 0) x = -1; if (x < 0) x = -1;
int y = (target.y - position.y);
if (y > 0) y = 1; if (y > 0) y = 1;
if (y < 0) y = -1; if (y < 0) y = -1;