diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-09-27 23:07:19 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-09-27 23:07:19 +0200 |
commit | 90540cdf46b9a04af48926bcba2d971a54b6d640 (patch) | |
tree | 2a457a00548c819f391393556bb27755cd56ec27 /core/src/ch/asynk/tankontank | |
parent | cea2deb7e2106f9d53f08a80b8cf3c66ed80d0b3 (diff) | |
download | RustAndDust-90540cdf46b9a04af48926bcba2d971a54b6d640.zip RustAndDust-90540cdf46b9a04af48926bcba2d971a54b6d640.tar.gz |
getPawnPosAt(...) uses Tile.getCenter()
Diffstat (limited to 'core/src/ch/asynk/tankontank')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Board.java | 16 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Tile.java | 5 |
2 files changed, 8 insertions, 13 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java index 0166840..a923fb4 100644 --- a/core/src/ch/asynk/tankontank/engine/Board.java +++ b/core/src/ch/asynk/tankontank/engine/Board.java @@ -399,15 +399,6 @@ public abstract class Board extends Image implements Disposable return n; } - public Vector2 getHexCenterAt(GridPoint2 tile) - { - // FIXME could ask it to the Tile - float x = cfg.x0 + ((tile.x * cfg.w) + (cfg.w / 2)); - float y = cfg.y0 + ((tile.y * cfg.h) + (cfg.s / 2)); - if ((tile.y % 2) == 1) x += cfg.dw; - return new Vector2(x, y); - } - public Vector2 getPawnPosAt(Pawn pawn, GridPoint2 tile) { return getPawnPosAt(pawn, tile.x, tile.y); @@ -415,10 +406,9 @@ public abstract class Board extends Image implements Disposable private Vector2 getPawnPosAt(Pawn pawn, int col, int row) { - // FIXME could ask it to the Tile - float x = cfg.x0 + ((col * cfg.w) + ((cfg.w - pawn.getHeight()) / 2)); - float y = cfg.y0 + ((row * cfg.h) + ((cfg.s - pawn.getWidth()) / 2)); - if ((row % 2) == 1) x += cfg.dw; + Vector2 center = getTile(col, row).getCenter(); + float x = (center.x - (pawn.getWidth() / 2)); + float y = (center.y - (pawn.getHeight() / 2)); return new Vector2(x, y); } diff --git a/core/src/ch/asynk/tankontank/engine/Tile.java b/core/src/ch/asynk/tankontank/engine/Tile.java index 835f464..8e64ce6 100644 --- a/core/src/ch/asynk/tankontank/engine/Tile.java +++ b/core/src/ch/asynk/tankontank/engine/Tile.java @@ -30,6 +30,11 @@ public abstract class Tile implements Drawable this.overlays.centerOn(x, y); } + public Vector2 getCenter() + { + return center; + } + public int push(Pawn pawn) { if (stack == null) stack = new ArrayDeque<Pawn>(); |