From 0fc28556d3a2c71d184be9ed701f61618e1d1252 Mon Sep 17 00:00:00 2001 From: Debucquoy Date: Tue, 2 May 2023 14:45:28 +0200 Subject: [PATCH 1/3] Level Maker base without grinder --- .../Parsers/FileParserFactory.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/app/src/main/java/school_project/Parsers/FileParserFactory.java b/app/src/main/java/school_project/Parsers/FileParserFactory.java index a7f4f68..ec48ffb 100644 --- a/app/src/main/java/school_project/Parsers/FileParserFactory.java +++ b/app/src/main/java/school_project/Parsers/FileParserFactory.java @@ -2,11 +2,13 @@ package school_project.Parsers; import javafx.util.Pair; import school_project.Map; +import school_project.Piece; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.NotSerializableException; +import java.util.Scanner; /** * This is used to find the right parser to parser a save/level file. @@ -80,4 +82,40 @@ public class FileParserFactory { } return new Pair(fileParser, save_data); } + + public static void main(String[] args) throws IOException { + Scanner in = new Scanner(System.in); + Map level = new Map(); + + System.out.print("Entrez le nom du fichier:"); + File file = new File(in.nextLine()); + + System.out.print("Entrez la largeur de la map:"); + int map_width = in.nextInt(); + + System.out.print("Entrez la hauteur de la map:"); + int map_height = in.nextInt(); + + boolean[][] map_shape = new boolean[map_height][map_width]; + + //grind map here + + level.setShape(map_shape); + System.out.print("Entrez le nombre de pieces:"); + int piece_amount = in.nextInt(); + + for (int i = 0; i < piece_amount; i++) { + System.out.print("Entrez la largeur de la piece" + (i+1) +": "); + int _piece_width = in.nextInt(); + + System.out.print("Entrez la hauteur de la piece" + (i+1) +": "); + int _piece_height = in.nextInt(); + boolean[][] _piece_shape = new boolean[_piece_height][_piece_width]; + + //grid piece here + + level.addPiece(new Piece(_piece_shape)); + } + saveFileFromMap(file, level); + } } \ No newline at end of file -- 2.46.0 From c0e4f311a80ec9207ab94226a367b039b707c391 Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Tue, 2 May 2023 23:40:21 +0200 Subject: [PATCH 2/3] First level Maker (could be better tho) + one exemple level11 Signed-off-by: Anthony Debucquoy --- .../Parsers/FileParserFactory.java | 15 +++++++++++++-- app/src/main/resources/level11.level | Bin 0 -> 26 bytes .../main/resources/school_project/level11.level | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 app/src/main/resources/level11.level create mode 100644 app/src/main/resources/school_project/level11.level diff --git a/app/src/main/java/school_project/Parsers/FileParserFactory.java b/app/src/main/java/school_project/Parsers/FileParserFactory.java index ec48ffb..83749bf 100644 --- a/app/src/main/java/school_project/Parsers/FileParserFactory.java +++ b/app/src/main/java/school_project/Parsers/FileParserFactory.java @@ -98,9 +98,15 @@ public class FileParserFactory { boolean[][] map_shape = new boolean[map_height][map_width]; - //grind map here + for (int i = 0; i < map_height; i++) { + for (int j = 0; j < map_width; j++) { + System.out.print("mur (" + i + ", " + j + ")? (y/n):"); + map_shape[i][j] = in.next(".").charAt(0) != 'y'; + } + } level.setShape(map_shape); + System.out.println(level); System.out.print("Entrez le nombre de pieces:"); int piece_amount = in.nextInt(); @@ -112,7 +118,12 @@ public class FileParserFactory { int _piece_height = in.nextInt(); boolean[][] _piece_shape = new boolean[_piece_height][_piece_width]; - //grid piece here + for (int k = 0; k < _piece_height; k++) { + for (int j = 0; j < _piece_width; j++) { + System.out.print("mur (" + k + ", " + j + ")? (y/n):"); + _piece_shape[k][j] = in.next(".").charAt(0) != 'y'; + } + } level.addPiece(new Piece(_piece_shape)); } diff --git a/app/src/main/resources/level11.level b/app/src/main/resources/level11.level new file mode 100644 index 0000000000000000000000000000000000000000..1a98225aeaa0a8e4958dcbcb5bb3182301e0068f GIT binary patch literal 26 ccmWIc4Q6Fs{{Mdin=u1}5)=wD1pB%I0AW=H+5i9m literal 0 HcmV?d00001 diff --git a/app/src/main/resources/school_project/level11.level b/app/src/main/resources/school_project/level11.level new file mode 100644 index 0000000..b66355c --- /dev/null +++ b/app/src/main/resources/school_project/level11.level @@ -0,0 +1 @@ +SMSçÿÿ€3ÿ€"ð"°"p"°€SME \ No newline at end of file -- 2.46.0 From 174af9c4c896b01398a90b418e5ac8c1612deb6f Mon Sep 17 00:00:00 2001 From: Debucquoy Anthony Date: Wed, 3 May 2023 00:11:07 +0200 Subject: [PATCH 3/3] Delete 'app/src/main/resources/level11.level' --- app/src/main/resources/level11.level | Bin 26 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 app/src/main/resources/level11.level diff --git a/app/src/main/resources/level11.level b/app/src/main/resources/level11.level deleted file mode 100644 index 1a98225aeaa0a8e4958dcbcb5bb3182301e0068f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 26 ccmWIc4Q6Fs{{Mdin=u1}5)=wD1pB%I0AW=H+5i9m -- 2.46.0