aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpacien2018-01-11 21:27:07 +0100
committerpacien2018-01-11 21:27:07 +0100
commit7fc6fc06bf5b1e6c3a07640cfb2ac7456e030e06 (patch)
tree9150ef2c6b66de7a81c4d0abe9fee45f6831aae8 /src
parent1347f30afbed7ee9c149f77534f5e75fbe819b98 (diff)
downloadwallj-7fc6fc06bf5b1e6c3a07640cfb2ac7456e030e06.tar.gz
Unify width/height order
Signed-off-by: pacien <pacien.trangirard@pacien.net>
Diffstat (limited to 'src')
-rw-r--r--src/main/java/fr/umlv/java/wallj/board/Board.java6
-rw-r--r--src/test/java/fr/umlv/java/wallj/board/BoardParserTest.java2
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 {
21 * @param height height in tiles 21 * @param height height in tiles
22 */ 22 */
23 public Builder(int width, int height) { 23 public Builder(int width, int height) {
24 this.map = new BlockType[width][height]; 24 map = new BlockType[height][width];
25 } 25 }
26 26
27 /** 27 /**
@@ -30,7 +30,7 @@ public final class Board {
30 * @return the Builder 30 * @return the Builder
31 */ 31 */
32 public Builder setBlockTypeAt(TileVec2 pos, BlockType type) { 32 public Builder setBlockTypeAt(TileVec2 pos, BlockType type) {
33 map[pos.getCol()][pos.getRow()] = type; 33 map[pos.getRow()][pos.getCol()] = type;
34 return this; 34 return this;
35 } 35 }
36 36
@@ -55,7 +55,7 @@ public final class Board {
55 * @return the element at the given position 55 * @return the element at the given position
56 */ 56 */
57 public BlockType getBlockTypeAt(TileVec2 pos) { 57 public BlockType getBlockTypeAt(TileVec2 pos) {
58 return map[pos.getCol()][pos.getRow()]; 58 return map[pos.getRow()][pos.getCol()];
59 } 59 }
60 60
61 /** 61 /**
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 {
35 35
36 Board board = BoardParser.parse(getResourcePath("/maps/smallValid.txt")); 36 Board board = BoardParser.parse(getResourcePath("/maps/smallValid.txt"));
37 37
38 Assertions.assertEquals(board.getDim(), TileVec2.of(blocks.length, blocks[0].length)); 38 Assertions.assertEquals(board.getDim(), TileVec2.of(blocks[0].length, blocks.length));
39 for (int row = 0; row < blocks.length; ++row) 39 for (int row = 0; row < blocks.length; ++row)
40 for (int col = 0; col < blocks[0].length; ++col) 40 for (int col = 0; col < blocks[0].length; ++col)
41 Assertions.assertEquals(board.getBlockTypeAt(TileVec2.of(row, col)), blocks[row][col]); 41 Assertions.assertEquals(board.getBlockTypeAt(TileVec2.of(row, col)), blocks[row][col]);