summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r--core/src/ch/asynk/tankontank/engine/Board.java15
-rw-r--r--core/src/ch/asynk/tankontank/game/Map.java4
2 files changed, 17 insertions, 2 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java
index e8c56d7..3115c40 100644
--- a/core/src/ch/asynk/tankontank/engine/Board.java
+++ b/core/src/ch/asynk/tankontank/engine/Board.java
@@ -70,7 +70,7 @@ public abstract class Board extends Image implements Disposable
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>();
- private final LinkedHashSet<Pawn> pawnsToDraw = new LinkedHashSet<Pawn>();
+ protected final LinkedHashSet<Pawn> pawnsToDraw = new LinkedHashSet<Pawn>();
public Board(Config cfg, Tile[][] board, Texture texture)
{
@@ -194,6 +194,19 @@ public abstract class Board extends Image implements Disposable
tilesToDraw.remove(tile);
}
+ public Pawn removeTopPawnFrom(GridPoint2 tile)
+ {
+ return removeTopPawnFrom(tile.x, tile.y);
+ }
+
+ public Pawn removeTopPawnFrom(int col, int row)
+ {
+ Pawn pawn = getTopPawnAt(col, row);
+ if (pawn != null)
+ removePawnFrom(pawn, col, row);
+ return pawn;
+ }
+
public Pawn getTopPawnAt(GridPoint2 tile)
{
return getTopPawnAt(tile.x, tile.y);
diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java
index 9eef409..7271f22 100644
--- a/core/src/ch/asynk/tankontank/game/Map.java
+++ b/core/src/ch/asynk/tankontank/game/Map.java
@@ -27,7 +27,8 @@ public class Map extends Board
{
getHexAt(currentHex, x, y);
if (currentHex.x != -1) {
- currentPawn = getTopPawnAt(currentHex);
+ currentPawn = removeTopPawnFrom(currentHex);
+ if (currentPawn != null) pawnsToDraw.add(currentPawn);
}
}
@@ -35,6 +36,7 @@ public class Map extends Board
{
getHexAt(currentHex, x, y);
if (currentPawn != null) {
+ pawnsToDraw.remove(currentPawn);
movePawnTo(currentPawn, currentHex);
}
}