diff --git a/src/main/java/pacmanGame/Map.java b/src/main/java/pacmanGame/Map.java index ed5db46..0927b56 100644 --- a/src/main/java/pacmanGame/Map.java +++ b/src/main/java/pacmanGame/Map.java @@ -69,7 +69,7 @@ public class Map { for(int y = 0; y < size.y; y++) { Vector2 cellPos = new Vector2(x,y); - String cellType = mapTypes.get(String.valueOf(mapData[y].charAt(x))); + String cellType = mapTypes.get(String.valueOf(mapData[size.y - 1 - y].charAt(x))); cells[x][y] = new Cell(cellPos, cellType); } diff --git a/src/main/java/pacmanGame/VisualizerPlainText.java b/src/main/java/pacmanGame/VisualizerPlainText.java index eea95a2..87a4075 100644 --- a/src/main/java/pacmanGame/VisualizerPlainText.java +++ b/src/main/java/pacmanGame/VisualizerPlainText.java @@ -31,7 +31,7 @@ public class VisualizerPlainText implements Visualizer { for(int y = 0; y < map.size.y; y++) { for(int x = 0; x < map.size.x; x++) { - Cell cell = map.GetCell(new Vector2(x,y)); + Cell cell = map.GetCell(new Vector2(x, map.size.y - 1 - y)); boolean containsGhosts = false; for( int i = 0; i < gameManager.ghosts.length; i++) { if(gameManager.ghosts[i].position.equals(cell.pos)) { diff --git a/src/test/java/pacmanTests/MapTest.java b/src/test/java/pacmanTests/MapTest.java index e895acf..cc94256 100644 --- a/src/test/java/pacmanTests/MapTest.java +++ b/src/test/java/pacmanTests/MapTest.java @@ -24,15 +24,15 @@ class MapTest { // act Map testMap = new Map(mapTest); - String topLeft = testMap.cells[0][0].type; + String topLeft = testMap.cells[0][2].type; String middle = testMap.cells[1][1].type; - String bottomRight = testMap.cells[2][2].type; + String bottomRight = testMap.cells[2][0].type; // assert assertThat(expectedTopLeft).isEqualTo(topLeft); assertThat(expectedMiddle).isEqualTo(middle); assertThat(expectedBottomRight).isEqualTo(bottomRight); } - + @Test void Map_getCell_returnsCorrectCells() { // arrange @@ -42,13 +42,13 @@ class MapTest { "ee." }; Map testMap = new Map(mapTest); - Cell expectedTopLeft = testMap.cells[0][0]; + Cell expectedTopLeft = testMap.cells[0][2]; Cell expectedMiddle = testMap.cells[1][1]; - Cell expectedBottomRight = testMap.cells[2][2]; + Cell expectedBottomRight = testMap.cells[2][0]; // act - Cell topLeft = testMap.GetCell(new Vector2(0, 0)); + Cell topLeft = testMap.GetCell(new Vector2(0, 2)); Cell middle = testMap.GetCell(new Vector2(1, 1)); - Cell bottomRight = testMap.GetCell(new Vector2(2, 2)); + Cell bottomRight = testMap.GetCell(new Vector2(2, 0)); // assert assertThat(expectedTopLeft).isEqualTo(topLeft); assertThat(expectedMiddle).isEqualTo(middle);