summaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-09-22 12:50:06 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-09-22 12:50:06 +0200
commit67bdf07d706fff5d3070e841252e31cd144671b9 (patch)
tree8a12e2bfb4fc1b882502b43c0131265bfe4a30a4 /core/src
parentb2b836b8c7a6a5dc0dddf8e85502f4903d4f2686 (diff)
downloadRustAndDust-67bdf07d706fff5d3070e841252e31cd144671b9.zip
RustAndDust-67bdf07d706fff5d3070e841252e31cd144671b9.tar.gz
correctly manage dragged Pawn and pawnsToDraw
Diffstat (limited to 'core/src')
-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);
}
}