From 4e7a2210c94589cd9a5370497d8a28f5ba487c54 Mon Sep 17 00:00:00 2001 From: pacien Date: Fri, 12 Jan 2018 00:14:53 +0100 Subject: Fix coordinate inversion Signed-off-by: pacien --- .../java/fr/umlv/java/wallj/board/TileVec2.java | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/main/java/fr/umlv/java/wallj/board/TileVec2.java b/src/main/java/fr/umlv/java/wallj/board/TileVec2.java index 60a2b75..b00c044 100644 --- a/src/main/java/fr/umlv/java/wallj/board/TileVec2.java +++ b/src/main/java/fr/umlv/java/wallj/board/TileVec2.java @@ -14,12 +14,12 @@ public final class TileVec2 { private static final int TILE_DIM = 20; /** - * @param row the row * @param col the column + * @param row the row * @return a corresponding tile vector */ - public static TileVec2 of(int row, int col) { - return new TileVec2(row, col); + public static TileVec2 of(int col, int row) { + return new TileVec2(col, row); } /** @@ -30,32 +30,32 @@ public final class TileVec2 { return new TileVec2((int) (v.x / TILE_DIM), (int) (v.y / TILE_DIM)); } - private final int row, col; + private final int col, row; - private TileVec2(int row, int col) { - this.row = row; + private TileVec2(int col, int row) { this.col = col; + this.row = row; } /** - * @return the row + * @return the column */ - public int getRow() { - return row; + public int getCol() { + return col; } /** - * @return the column + * @return the row */ - public int getCol() { - return col; + public int getRow() { + return row; } /** * @return the corresponding JBox2D coordinates of the top-left corner of the tile */ public Vec2 toVec2() { - return new Vec2(row * TILE_DIM, col * TILE_DIM); + return new Vec2(col * TILE_DIM, row * TILE_DIM); } @Override @@ -63,20 +63,20 @@ public final class TileVec2 { if (this == o) return true; if (!(o instanceof TileVec2)) return false; TileVec2 tileVec2 = (TileVec2) o; - return row == tileVec2.row && - col == tileVec2.col; + return col == tileVec2.col && + row == tileVec2.row; } @Override public int hashCode() { - return Objects.hash(row, col); + return Objects.hash(col, row); } @Override public String toString() { return "TileVec2{" + - "row=" + row + - ", col=" + col + + "col=" + col + + ", row=" + row + '}'; } -- cgit v1.2.3