diff options
Diffstat (limited to 'core/src/ch')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Pawn.java | 18 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/PawnNode.java | 45 |
2 files changed, 23 insertions, 40 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java index 3d2c782..87c06c9 100644 --- a/core/src/ch/asynk/tankontank/engine/Pawn.java +++ b/core/src/ch/asynk/tankontank/engine/Pawn.java @@ -9,23 +9,21 @@ public interface Pawn extends Node { public Vector3 getLastPosition(); - public void moveBy(float x, float y); + public void moveDone(); - public void pushMove(float x, float y, int z, Pawn.Orientation o); + public void pushMove(float x, float y, Pawn.Orientation o); public AnimationSequence getResetMovesAnimation(); - public void moveDone(); - public enum Orientation { KEEP(0), - WEST(180), - NORTH_WEST(120), - NORTH_EAST (60), - EAST(0), - SOUTH_EAST(-60), - SOUTH_WEST(-120); + NORTH_WEST(30), + WEST(90), + SOUTH_WEST(150), + NORTH_EAST (-30), + EAST(-90), + SOUTH_EAST(-150); public final int v; Orientation(int v) { this.v = v; } diff --git a/core/src/ch/asynk/tankontank/engine/PawnNode.java b/core/src/ch/asynk/tankontank/engine/PawnNode.java index bf3287b..600c6dd 100644 --- a/core/src/ch/asynk/tankontank/engine/PawnNode.java +++ b/core/src/ch/asynk/tankontank/engine/PawnNode.java @@ -6,17 +6,15 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.math.Vector3; -import ch.asynk.tankontank.engine.gfx.TextureRegionDrawable; +import ch.asynk.tankontank.engine.gfx.SpriteNode; import ch.asynk.tankontank.engine.gfx.animations.MoveToAnimation; import ch.asynk.tankontank.engine.gfx.animations.RunnableAnimation; import ch.asynk.tankontank.engine.gfx.animations.AnimationSequence; -public class PawnNode extends TextureRegionDrawable implements Pawn +public class PawnNode extends SpriteNode implements Pawn { private static final float MOVE_TIME = 0.3f; - private static final float ROTATE_TIME = 0.2f; - private Layer layer; private ArrayDeque<Vector3> path = new ArrayDeque<Vector3>(); public PawnNode(TextureRegion region) @@ -25,37 +23,31 @@ public class PawnNode extends TextureRegionDrawable implements Pawn } @Override - public void setLayer(Layer layer) + public Vector3 getLastPosition() { - this.layer = layer; + if ((path == null) || (path.size() == 0)) return null; + return path.getFirst(); } @Override - public void clear() + public void moveDone() { - dispose(); + Vector3 v = path.pop(); + path.clear(); + path.push(v); } @Override - public void act(float delta) - { - } - - public Vector3 getLastPosition() - { - if ((path == null) || (path.size() == 0)) return null; - return path.getFirst(); - } - - public void pushMove(float x, float y, int z, Pawn.Orientation r) + public void pushMove(float x, float y, Pawn.Orientation o) { - setCoords(x, y, z); - if (r != Pawn.Orientation.KEEP) setRotation(r.v); - Vector3 v = new Vector3(x, y, r.v); + float r = ((o == Pawn.Orientation.KEEP) ? getRotation() : o.v); + setPosition(x, y, r); + Vector3 v = new Vector3(x, y, r); if ((path.size() == 0) || (!v.equals(path.getFirst()))) - path.push(new Vector3(x, y, r.v)); + path.push(new Vector3(x, y, r)); } + @Override public AnimationSequence getResetMovesAnimation() { final Vector3 finalPos = path.getLast(); @@ -75,11 +67,4 @@ public class PawnNode extends TextureRegionDrawable implements Pawn return seq; } - - public void moveDone() - { - Vector3 v = path.pop(); - path.clear(); - path.push(v); - } } |