From cbd3855d120cfc9e50c5431d48430df54efc570d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 22 Oct 2014 12:15:54 +0200 Subject: Bawn,Board: simplify getPawnPosAt(...) --- core/src/ch/asynk/tankontank/engine/Board.java | 4 +--- core/src/ch/asynk/tankontank/engine/Pawn.java | 10 +++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java index 93274eb..b82c8c7 100644 --- a/core/src/ch/asynk/tankontank/engine/Board.java +++ b/core/src/ch/asynk/tankontank/engine/Board.java @@ -532,9 +532,7 @@ public abstract class Board implements Disposable protected Vector2 getPawnPosAt(Pawn pawn, GridPoint2 coords, Vector2 pos) { - // FIXME the pawn should return its Vector3 - Tile tile = getTile(coords); - return pawn.getPosAt(tile.getX(), tile.getY(), pos); + return pawn.getPosAt(getTile(coords.x, coords.y), pos); } public Pawn setPawnAt(Pawn pawn, GridPoint2 coords, Orientation o) diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java index bde5f0c..f1626cc 100644 --- a/core/src/ch/asynk/tankontank/engine/Pawn.java +++ b/core/src/ch/asynk/tankontank/engine/Pawn.java @@ -131,14 +131,14 @@ public abstract class Pawn implements Moveable, Disposable return new Vector2(x, y); } - public Vector2 getPosAt(float x, float y, Vector2 pos) + public Vector2 getPosAt(Tile tile, Vector2 pos) { - float cx = (x - (image.getWidth() / 2f)); - float cy = (y - (image.getHeight() / 2f)); + float x = (tile.getX() - (image.getWidth() / 2f)); + float y = (tile.getY() - (image.getHeight() / 2f)); if (pos == null) - return new Vector2(cx, cy); + return new Vector2(x, y); else - pos.set(cx, cy); + pos.set(x, y); return pos; } -- cgit v1.1-2-g2b99