summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-09-20 23:15:53 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-09-20 23:15:53 +0200
commit7baa155e13f7e4ac304ac5daf120aa7978419e23 (patch)
treef7bdbd5d667abb3342075b29158933ff09e263d9 /core
parent1cd10aac98c03c62d277c7d77187421355ea1935 (diff)
downloadRustAndDust-7baa155e13f7e4ac304ac5daf120aa7978419e23.zip
RustAndDust-7baa155e13f7e4ac304ac5daf120aa7978419e23.tar.gz
cleanup Pawn and PawnNode
Diffstat (limited to 'core')
-rw-r--r--core/src/ch/asynk/tankontank/engine/Pawn.java18
-rw-r--r--core/src/ch/asynk/tankontank/engine/PawnNode.java45
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);
- }
}