From 7fc6fc06bf5b1e6c3a07640cfb2ac7456e030e06 Mon Sep 17 00:00:00 2001 From: pacien Date: Thu, 11 Jan 2018 21:27:07 +0100 Subject: Unify width/height order Signed-off-by: pacien --- src/main/java/fr/umlv/java/wallj/board/Board.java | 6 +++--- src/test/java/fr/umlv/java/wallj/board/BoardParserTest.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/fr/umlv/java/wallj/board/Board.java b/src/main/java/fr/umlv/java/wallj/board/Board.java index a4ac421..c846fd3 100644 --- a/src/main/java/fr/umlv/java/wallj/board/Board.java +++ b/src/main/java/fr/umlv/java/wallj/board/Board.java @@ -21,7 +21,7 @@ public final class Board { * @param height height in tiles */ public Builder(int width, int height) { - this.map = new BlockType[width][height]; + map = new BlockType[height][width]; } /** @@ -30,7 +30,7 @@ public final class Board { * @return the Builder */ public Builder setBlockTypeAt(TileVec2 pos, BlockType type) { - map[pos.getCol()][pos.getRow()] = type; + map[pos.getRow()][pos.getCol()] = type; return this; } @@ -55,7 +55,7 @@ public final class Board { * @return the element at the given position */ public BlockType getBlockTypeAt(TileVec2 pos) { - return map[pos.getCol()][pos.getRow()]; + return map[pos.getRow()][pos.getCol()]; } /** diff --git a/src/test/java/fr/umlv/java/wallj/board/BoardParserTest.java b/src/test/java/fr/umlv/java/wallj/board/BoardParserTest.java index de6799b..87ca08a 100644 --- a/src/test/java/fr/umlv/java/wallj/board/BoardParserTest.java +++ b/src/test/java/fr/umlv/java/wallj/board/BoardParserTest.java @@ -35,7 +35,7 @@ final class BoardParserTest { Board board = BoardParser.parse(getResourcePath("/maps/smallValid.txt")); - Assertions.assertEquals(board.getDim(), TileVec2.of(blocks.length, blocks[0].length)); + Assertions.assertEquals(board.getDim(), TileVec2.of(blocks[0].length, blocks.length)); for (int row = 0; row < blocks.length; ++row) for (int col = 0; col < blocks[0].length; ++col) Assertions.assertEquals(board.getBlockTypeAt(TileVec2.of(row, col)), blocks[row][col]); -- cgit v1.2.3