levelMaker (#36)
All checks were successful
continuous-integration/drone/push Build is passing

This is a really simple and not efficient level Maker to build levels.

you have to run the main method in FileParserFacotry.java with your idea and respond to all the questions. it's painfully slow but less than doing it by hand on a paper I guess.

I added level11.level as an example for where to put the level when finished.

To access it you have to do: `new File(getClass().getResources("level11.level").getFile())` and put it into `FileParserFactory.loadMapFromFile(File f)`

Co-authored-by: Debucquoy <debucqquoy.anthony@gmail.com>
Co-authored-by: Anthony Debucquoy <debucquoy.anthony@gmail.com>
Reviewed-on: #36
Reviewed-by: Mat_02 <diletomatteo@gmail.com>
This commit is contained in:
Debucquoy Anthony 2023-05-03 17:29:10 +02:00
parent 72dcbcbf4f
commit f1519ba40c
2 changed files with 50 additions and 0 deletions

View File

@ -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,51 @@ public class FileParserFactory {
}
return new Pair<FileParser, Boolean>(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];
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();
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];
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));
}
saveFileFromMap(file, level);
}
}

View File

@ -0,0 +1 @@
SMSη<><CEB7>3<>€"π"°"p"°€SME