diff options
| author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-09-17 09:54:28 +0200 | 
|---|---|---|
| committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-09-17 09:54:28 +0200 | 
| commit | 3f72675a5048dd9b47e8cef80fd07ed5e4aeaa10 (patch) | |
| tree | 5f3511eeb924c5d4f36306de2b1882ac82041259 /core/src/ch/asynk/tankontank | |
| parent | 1259e9aee8da8367807b32632ba5311947206944 (diff) | |
| download | RustAndDust-3f72675a5048dd9b47e8cef80fd07ed5e4aeaa10.zip RustAndDust-3f72675a5048dd9b47e8cef80fd07ed5e4aeaa10.tar.gz | |
do not push the same vector again
Diffstat (limited to 'core/src/ch/asynk/tankontank')
| -rw-r--r-- | core/src/ch/asynk/tankontank/engine/PawnImage.java | 8 | 
1 files changed, 5 insertions, 3 deletions
| diff --git a/core/src/ch/asynk/tankontank/engine/PawnImage.java b/core/src/ch/asynk/tankontank/engine/PawnImage.java index 77ef752..acb09a9 100644 --- a/core/src/ch/asynk/tankontank/engine/PawnImage.java +++ b/core/src/ch/asynk/tankontank/engine/PawnImage.java @@ -33,15 +33,17 @@ public class PawnImage extends Image implements Pawn          setPosition(x, y);          if (r != Tile.Orientation.KEEP) setRotation(r.v);          setZIndex(z); -        path.push(new Vector3(x, y, r.v)); +        Vector3 v = new Vector3(x, y, r.v); +        if ((path.size() == 0) || (!v.equals(path.getFirst()))) +            path.push(new Vector3(x, y, r.v));      }      public void resetMoves(Runnable cb)      { -        final Pawn self = this;          final Vector3 finalPos = path.getLast();          SequenceAction seq = new SequenceAction(); +          while(path.size() != 0) {              Vector3 v = path.pop();              seq.addAction(Actions.moveTo(v.x, v.y, MOVE_TIME)); @@ -56,7 +58,7 @@ public class PawnImage extends Image implements Pawn              }          })); -        // map set z index and push me in hex stack +        // the map must finalize this move          seq.addAction(Actions.run(cb));          addAction(seq); | 
