summaryrefslogtreecommitdiffstats
path: root/core/src/ch
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-03 10:10:48 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-03 10:10:48 +0200
commita69bb5652bb5228cb3718f2c4503e3490c1072fa (patch)
tree207e9fc2bee7f3989adbe37f335c418ebc2ae01f /core/src/ch
parentaf5583f825ac4d358d2205f7823d9acdabf6abc2 (diff)
downloadRustAndDust-a69bb5652bb5228cb3718f2c4503e3490c1072fa.zip
RustAndDust-a69bb5652bb5228cb3718f2c4503e3490c1072fa.tar.gz
Board: use Orientation.fromMove(...)
Diffstat (limited to 'core/src/ch')
-rw-r--r--core/src/ch/asynk/tankontank/engine/Board.java21
1 files changed, 2 insertions, 19 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java
index 01839e9..9f85fab 100644
--- a/core/src/ch/asynk/tankontank/engine/Board.java
+++ b/core/src/ch/asynk/tankontank/engine/Board.java
@@ -320,24 +320,6 @@ public abstract class Board implements Disposable
return nodesToSet(paths, points);
}
- private Orientation getOrientation(SearchBoard.Node from, SearchBoard.Node to)
- {
- int dx = to.col - from .col;
- int dy = to.row - from.row;
-
- if (dy == 0) {
- if (dx > 0) return Orientation.NORTH;
- return Orientation.SOUTH;
- }
- if (dy > 0) {
- if (dx > 0) return Orientation.NORTH_WEST;
- return Orientation.SOUTH_WEST;
- } else {
- if (dx > 0) return Orientation.NORTH_EAST;
- return Orientation.SOUTH_EAST;
- }
- }
-
public int getFinalPath(Vector<GridPoint3> path)
{
List<Vector<SearchBoard.Node>> paths = searchBoard.possiblePaths();
@@ -354,7 +336,8 @@ public abstract class Board implements Disposable
for (int i = (nodes.size() - 2); i >= 0; i--) {
SearchBoard.Node node = nodes.get(i);
GridPoint3 point = gridPoint3Pool.obtain();
- point.set(node.col, node.row, (int) getOrientation(prev, node).r());
+ Orientation o = Orientation.fromMove(prev.col, prev.row, node.col, node.row);
+ point.set(node.col, node.row, (int) o.r());
path.add(point);
prev = node;
}