diff --git a/src/main/java/ruscz/game/gameOfProd/Image/ImageCell.java b/src/main/java/ruscz/game/gameOfProd/Image/ImageCell.java index a28037f..5db3334 100644 --- a/src/main/java/ruscz/game/gameOfProd/Image/ImageCell.java +++ b/src/main/java/ruscz/game/gameOfProd/Image/ImageCell.java @@ -14,14 +14,14 @@ import java.util.Scanner; public class ImageCell { private static BufferedImage image; private static LinkedList imagesOfTiles; - private int[] mapBackground; + private int[][] mapBackground; public void readMapFile(String name) { try { - mapBackground = new int[WindowOfFreeMove.CANVAS_WIDTH * WindowOfFreeMove.CANVAS_HEIGHT]; - int count = 0; + mapBackground = new int[WindowOfFreeMove.CANVAS_WIDTH][WindowOfFreeMove.CANVAS_HEIGHT]; File mapFile = new File("src/main/resources/maps/" + name + ".txt"); Scanner scanner = new Scanner(mapFile); + int j = 0; while (scanner.hasNextLine()) { String data = scanner.nextLine(); if (data.contains("")) { @@ -30,9 +30,9 @@ public class ImageCell { } else { String[] mapColumn = data.split(" "); for (int i = 0; i < mapColumn.length; i++) { - mapBackground[count] = Integer.parseInt(mapColumn[i]); - count++; + mapBackground[i][j] = Integer.parseInt(mapColumn[i]); } + j++; } } } catch (FileNotFoundException e) { @@ -77,8 +77,8 @@ public class ImageCell { return imagesOfTiles; } - public void paintBackground(Graphics g, int x, int y, int count) { - g.drawImage(imagesOfTiles.get(mapBackground[count]), y * WindowOfFreeMove.CELL_SIZE, - x * WindowOfFreeMove.CELL_SIZE, WindowOfFreeMove.CELL_SIZE, WindowOfFreeMove.CELL_SIZE, null); + public void paintBackground(Graphics g, int x, int y) { + g.drawImage(imagesOfTiles.get(mapBackground[x][y]), x * WindowOfFreeMove.CELL_SIZE, + y * WindowOfFreeMove.CELL_SIZE, WindowOfFreeMove.CELL_SIZE, WindowOfFreeMove.CELL_SIZE, null); } } diff --git a/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java index 4da9685..745c59f 100644 --- a/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java +++ b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java @@ -19,8 +19,8 @@ import java.util.LinkedList; public class WindowOfFreeMove extends JFrame { public static final int CELL_SIZE = 40; - public static final int CANVAS_WIDTH = 10; - public static final int CANVAS_HEIGHT = 10; + public static final int CANVAS_WIDTH = 15; + public static final int CANVAS_HEIGHT = 15; private static boolean canPersonMove; private static int nextMove; @@ -210,11 +210,9 @@ public class WindowOfFreeMove extends JFrame { Graphics2D g2D = (Graphics2D) g; g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - int count = 0; for (int i = 0; i < CANVAS_WIDTH; i++) { for (int j = 0; j < CANVAS_HEIGHT; j++) { - map.getActualMap().getImageCell().paintBackground(g2D, i, j, count); - count++; + map.getActualMap().getImageCell().paintBackground(g2D, i, j); } } for (Cell cell : map.getActualMap().getMoveToCells()) { diff --git a/src/main/resources/A2_Ground.png b/src/main/resources/A2_Ground.png index 92c6cd1..5b6e5f0 100644 Binary files a/src/main/resources/A2_Ground.png and b/src/main/resources/A2_Ground.png differ diff --git a/src/main/resources/maps/m1-tileset.txt b/src/main/resources/maps/m1-tileset.txt index 77285fc..f2397a7 100644 --- a/src/main/resources/maps/m1-tileset.txt +++ b/src/main/resources/maps/m1-tileset.txt @@ -1,12 +1,12 @@ A2_Ground.png 512 384 32 D_OutDoor.png 512 512 32 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 82 94 0 0 82 94 0 0 -0 0 83 95 0 0 83 95 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 153 0 0 0 0 153 0 0 -0 0 0 153 153 153 153 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 82 94 1 1 82 94 1 1 +1 1 83 95 1 1 83 95 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 153 1 1 1 1 153 1 1 +1 1 1 153 153 153 153 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 diff --git a/src/main/resources/maps/m2-tileset.txt b/src/main/resources/maps/m2-tileset.txt index 77285fc..f2397a7 100644 --- a/src/main/resources/maps/m2-tileset.txt +++ b/src/main/resources/maps/m2-tileset.txt @@ -1,12 +1,12 @@ A2_Ground.png 512 384 32 D_OutDoor.png 512 512 32 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 82 94 0 0 82 94 0 0 -0 0 83 95 0 0 83 95 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 153 0 0 0 0 153 0 0 -0 0 0 153 153 153 153 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 82 94 1 1 82 94 1 1 +1 1 83 95 1 1 83 95 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 153 1 1 1 1 153 1 1 +1 1 1 153 153 153 153 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 diff --git a/src/main/resources/maps/m3-tileset.txt b/src/main/resources/maps/m3-tileset.txt index 77285fc..f2397a7 100644 --- a/src/main/resources/maps/m3-tileset.txt +++ b/src/main/resources/maps/m3-tileset.txt @@ -1,12 +1,12 @@ A2_Ground.png 512 384 32 D_OutDoor.png 512 512 32 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 82 94 0 0 82 94 0 0 -0 0 83 95 0 0 83 95 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 153 0 0 0 0 153 0 0 -0 0 0 153 153 153 153 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 82 94 1 1 82 94 1 1 +1 1 83 95 1 1 83 95 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 153 1 1 1 1 153 1 1 +1 1 1 153 153 153 153 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 diff --git a/src/main/resources/maps/m4-tileset.txt b/src/main/resources/maps/m4-tileset.txt index 77285fc..f2397a7 100644 --- a/src/main/resources/maps/m4-tileset.txt +++ b/src/main/resources/maps/m4-tileset.txt @@ -1,12 +1,12 @@ A2_Ground.png 512 384 32 D_OutDoor.png 512 512 32 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 82 94 0 0 82 94 0 0 -0 0 83 95 0 0 83 95 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 153 0 0 0 0 153 0 0 -0 0 0 153 153 153 153 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 82 94 1 1 82 94 1 1 +1 1 83 95 1 1 83 95 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 153 1 1 1 1 153 1 1 +1 1 1 153 153 153 153 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 diff --git a/src/main/resources/maps/m5-tileset.txt b/src/main/resources/maps/m5-tileset.txt index 8842228..c8ff195 100644 --- a/src/main/resources/maps/m5-tileset.txt +++ b/src/main/resources/maps/m5-tileset.txt @@ -1,12 +1,12 @@ A2_Ground.png 512 384 32 D_OutDoor.png 512 512 32 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 82 94 0 0 82 94 0 0 -0 0 83 95 0 0 83 95 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 153 0 0 0 0 153 0 0 -0 0 153 153 153 153 153 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 82 94 1 1 82 94 1 1 +1 1 83 95 1 1 83 95 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 153 1 1 1 1 153 1 1 +1 1 153 153 153 153 153 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1