diff options
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Map.java | 4 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/MapNode.java | 29 |
2 files changed, 33 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Map.java b/core/src/ch/asynk/tankontank/engine/Map.java index 8e5fcbf..253edf0 100644 --- a/core/src/ch/asynk/tankontank/engine/Map.java +++ b/core/src/ch/asynk/tankontank/engine/Map.java @@ -40,4 +40,8 @@ public interface Map extends Drawable, Disposable public float h; // square height : s + dh public float slope; // north-west side slope : (dh / (float) dw) } + + public void touchUp(float x, float y); + public void touchDown(float x, float y); + public boolean drag(float dx, float dy); } diff --git a/core/src/ch/asynk/tankontank/engine/MapNode.java b/core/src/ch/asynk/tankontank/engine/MapNode.java index 740074e..bf9928a 100644 --- a/core/src/ch/asynk/tankontank/engine/MapNode.java +++ b/core/src/ch/asynk/tankontank/engine/MapNode.java @@ -31,6 +31,9 @@ public class MapNode extends Image implements Map private Matrix4 prevTransform; private Matrix4 nextTransform; + private Pawn currentPawn; + private GridPoint2 currentHex = new GridPoint2(-1, -1); + private final Vector<Animation> animations = new Vector<Animation>(2); private final Vector<Animation> nextAnimations = new Vector<Animation>(2); private final LinkedHashSet<Tile> tilesToDraw = new LinkedHashSet<Tile>(); @@ -277,5 +280,31 @@ public class MapNode extends Image implements Map return hex; } + + @Override + public boolean drag(float dx, float dy) + { + if (currentPawn == null) return false; + currentPawn.translate(dx, dy); + return true; + } + + @Override + public void touchDown(float x, float y) + { + getHexAt(currentHex, x, y); + if (currentHex.x != -1) { + currentPawn = getTopPawnAt(currentHex); + } + } + + @Override + public void touchUp(float x, float y) + { + getHexAt(currentHex, x, y); + if (currentPawn != null) { + movePawnTo(currentPawn, currentHex); + } + } } |