From 0fc28556d3a2c71d184be9ed701f61618e1d1252 Mon Sep 17 00:00:00 2001 From: Debucquoy Date: Tue, 2 May 2023 14:45:28 +0200 Subject: [PATCH] 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