Fixing merge conflict
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @ -53,3 +53,4 @@ build | |||||||
|  |  | ||||||
| .idea/ | .idea/ | ||||||
| .settings/ | .settings/ | ||||||
|  | *.slevel | ||||||
|  | |||||||
| @ -29,7 +29,7 @@ dependencies { | |||||||
|  |  | ||||||
| application { | application { | ||||||
|     // Define the main class for the application. |     // Define the main class for the application. | ||||||
|     mainClass = 'school_project.Controller' |     mainClass = project.hasProperty("mainClass") ? project.getProperty("mainClass") : 'school_project.Controller' | ||||||
| } | } | ||||||
|  |  | ||||||
| javafx { | javafx { | ||||||
| @ -41,3 +41,7 @@ tasks.named('test') { | |||||||
|     // Use JUnit Platform for unit tests. |     // Use JUnit Platform for unit tests. | ||||||
|     useJUnitPlatform() |     useJUnitPlatform() | ||||||
| } | } | ||||||
|  |  | ||||||
|  | run{ | ||||||
|  | standardInput = System.in | ||||||
|  | } | ||||||
|  | |||||||
| @ -4,11 +4,14 @@ import javafx.application.Application; | |||||||
| import javafx.scene.Parent; | import javafx.scene.Parent; | ||||||
| import javafx.scene.Scene; | import javafx.scene.Scene; | ||||||
|  |  | ||||||
|  | import javafx.scene.input.KeyCode; | ||||||
| import javafx.scene.input.KeyCombination; | import javafx.scene.input.KeyCombination; | ||||||
| import javafx.stage.Screen; | import javafx.stage.Screen; | ||||||
| import javafx.stage.Stage; | import javafx.stage.Stage; | ||||||
| import school_project.Menu.MenuAccueil; | import school_project.Menu.MenuAccueil; | ||||||
|  | import school_project.Parsers.FileParserFactory; | ||||||
|  |  | ||||||
|  | import java.io.File; | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
|  |  | ||||||
|  |  | ||||||
| @ -19,6 +22,7 @@ public class Controller extends Application { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void start(Stage primaryStage) throws IOException { |     public void start(Stage primaryStage) throws IOException { | ||||||
|  |         new File("save.slevel"); | ||||||
|         stage = primaryStage; |         stage = primaryStage; | ||||||
|         screen_size = new Vec2( |         screen_size = new Vec2( | ||||||
|             (int) Screen.getPrimary().getBounds().getWidth(), |             (int) Screen.getPrimary().getBounds().getWidth(), | ||||||
| @ -41,6 +45,19 @@ public class Controller extends Application { | |||||||
|  |  | ||||||
|     public static void switchRoot(Parent root){ |     public static void switchRoot(Parent root){ | ||||||
|         Scene scene = new Scene(root); |         Scene scene = new Scene(root); | ||||||
|  |         if(root instanceof GameUI){ | ||||||
|  |             scene.setOnKeyPressed(event ->{ | ||||||
|  |                 GameUI game = (GameUI) root; | ||||||
|  |                 if(event.getCode() == KeyCode.ESCAPE){ | ||||||
|  |                     try { | ||||||
|  |                         FileParserFactory.saveFileFromMap(new File("save.slevel"), game.getLevel()); | ||||||
|  |                         switchRoot(new MenuAccueil()); | ||||||
|  |                     } catch (IOException e) { | ||||||
|  |                         throw new RuntimeException(e); | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |             }); | ||||||
|  |         } | ||||||
|         stage.setScene(scene); |         stage.setScene(scene); | ||||||
|     } |     } | ||||||
|     public static void main(String[] args) { |     public static void main(String[] args) { | ||||||
|  | |||||||
| @ -13,8 +13,11 @@ public class GameUI extends Group{ | |||||||
|     public final static int SPACE_SIZE = 5; |     public final static int SPACE_SIZE = 5; | ||||||
|     private final Vec2 piece_pos_click = new Vec2(); |     private final Vec2 piece_pos_click = new Vec2(); | ||||||
|  |  | ||||||
|  |     private Map level; | ||||||
|  |  | ||||||
|     public GameUI(Map level) throws FileNotFoundException { |     public GameUI(Map level) throws FileNotFoundException { | ||||||
|         super(); |         super(); | ||||||
|  |         this.level = level; | ||||||
|  |  | ||||||
|         MatrixShape grid = new MatrixShape(level); |         MatrixShape grid = new MatrixShape(level); | ||||||
|  |  | ||||||
| @ -29,17 +32,17 @@ public class GameUI extends Group{ | |||||||
|         for (Piece p : level.getPieces()) { |         for (Piece p : level.getPieces()) { | ||||||
|             MatrixShape _piece = new MatrixShape(p); |             MatrixShape _piece = new MatrixShape(p); | ||||||
|  |  | ||||||
|             _piece.setLayoutX(piece_space.x); |             if(piece_space.y + _piece.boundary_size.y >= Controller.screen_size.y){ | ||||||
|             _piece.setLayoutY(piece_space.y); |  | ||||||
|  |  | ||||||
|             piece_space.y += _piece.boundary_size.y; |  | ||||||
|  |  | ||||||
|             if(piece_space.y >= Controller.screen_size.y){ |  | ||||||
|                 column++; |                 column++; | ||||||
|                 piece_space.y = SPACE_SIZE; |                 piece_space.y = SPACE_SIZE; | ||||||
|                 piece_space.x = (SEGMENT_SIZE*3 + SPACE_SIZE*4 )* column; |                 piece_space.x = (SEGMENT_SIZE*3 + SPACE_SIZE*4 )* column; | ||||||
|             } |             } | ||||||
|  |  | ||||||
|  |             _piece.setLayoutX(piece_space.x); | ||||||
|  |             _piece.setLayoutY(piece_space.y); | ||||||
|  |  | ||||||
|  |             piece_space.y += _piece.boundary_size.y; | ||||||
|  |  | ||||||
|             // Pieces Events |             // Pieces Events | ||||||
|             _piece.setOnMouseClicked(event -> { |             _piece.setOnMouseClicked(event -> { | ||||||
|                 if(event.getButton() == MouseButton.SECONDARY){ |                 if(event.getButton() == MouseButton.SECONDARY){ | ||||||
| @ -59,6 +62,7 @@ public class GameUI extends Group{ | |||||||
|             _piece.setOnMouseReleased(event -> { |             _piece.setOnMouseReleased(event -> { | ||||||
|                 if(event.getButton() != MouseButton.PRIMARY) |                 if(event.getButton() != MouseButton.PRIMARY) | ||||||
|                     return; |                     return; | ||||||
|  |                 p.setPosition(null); | ||||||
|                 if(event.getSceneX() > grid.getLayoutX() && event.getSceneX() < grid.getLayoutX() + grid.boundary_size.x |                 if(event.getSceneX() > grid.getLayoutX() && event.getSceneX() < grid.getLayoutX() + grid.boundary_size.x | ||||||
|                     && event.getSceneY() > grid.getLayoutY() && event.getSceneY() < grid.getLayoutY() + grid.boundary_size.y ) |                     && event.getSceneY() > grid.getLayoutY() && event.getSceneY() < grid.getLayoutY() + grid.boundary_size.y ) | ||||||
|                 { |                 { | ||||||
| @ -67,7 +71,7 @@ public class GameUI extends Group{ | |||||||
|                             (int) (_piece.getLayoutY() + (SEGMENT_SIZE+SPACE_SIZE)/2 - grid.getLayoutY())/(SEGMENT_SIZE+SPACE_SIZE), |                             (int) (_piece.getLayoutY() + (SEGMENT_SIZE+SPACE_SIZE)/2 - grid.getLayoutY())/(SEGMENT_SIZE+SPACE_SIZE), | ||||||
|                             (int) (_piece.getLayoutX() + (SEGMENT_SIZE+SPACE_SIZE)/2 - grid.getLayoutX())/(SEGMENT_SIZE+SPACE_SIZE) |                             (int) (_piece.getLayoutX() + (SEGMENT_SIZE+SPACE_SIZE)/2 - grid.getLayoutX())/(SEGMENT_SIZE+SPACE_SIZE) | ||||||
|                     ); |                     ); | ||||||
|                     System.out.println(level.placePiece(p, piece_position_in_grid) + piece_position_in_grid.toString()); |                     level.placePiece(p, piece_position_in_grid); | ||||||
|                     if(p.getPosition() != null){ |                     if(p.getPosition() != null){ | ||||||
|                         _piece.setLayoutX(grid.getLayoutX() + p.getPosition().y * (SEGMENT_SIZE+SPACE_SIZE)); |                         _piece.setLayoutX(grid.getLayoutX() + p.getPosition().y * (SEGMENT_SIZE+SPACE_SIZE)); | ||||||
|                         _piece.setLayoutY(grid.getLayoutY() + p.getPosition().x * (SEGMENT_SIZE+SPACE_SIZE)); |                         _piece.setLayoutY(grid.getLayoutY() + p.getPosition().x * (SEGMENT_SIZE+SPACE_SIZE)); | ||||||
| @ -77,8 +81,11 @@ public class GameUI extends Group{ | |||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             }); |             }); | ||||||
|  |  | ||||||
|             getChildren().add(_piece); |             getChildren().add(_piece); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public Map getLevel() { | ||||||
|  |         return level; | ||||||
|  |     } | ||||||
| } | } | ||||||
| @ -10,10 +10,13 @@ import javafx.scene.text.Font; | |||||||
| import school_project.Controller; | import school_project.Controller; | ||||||
| import school_project.GameUI; | import school_project.GameUI; | ||||||
| import school_project.MapGenerator; | import school_project.MapGenerator; | ||||||
|  | import school_project.Parsers.FileParserFactory; | ||||||
|  |  | ||||||
|  | import java.io.File; | ||||||
| import java.io.FileNotFoundException; | import java.io.FileNotFoundException; | ||||||
|  | import java.io.IOException; | ||||||
|  |  | ||||||
| public class MenuAccueil extends StackPane { | public class MenuAccueil extends StackPane { | ||||||
|  |  | ||||||
|     public MenuAccueil(){ |     public MenuAccueil(){ | ||||||
|         super(); |         super(); | ||||||
|         //create all the objet that I need |         //create all the objet that I need | ||||||
| @ -21,7 +24,9 @@ public class MenuAccueil extends StackPane { | |||||||
|         SlctDifficulty.getItems().addAll("Easy", "Medium", "Difficult"); |         SlctDifficulty.getItems().addAll("Easy", "Medium", "Difficult"); | ||||||
|  |  | ||||||
|         Label RdmLvl = new Label("Random Level : "); |         Label RdmLvl = new Label("Random Level : "); | ||||||
|  |         Button LoadLvl = new Button("Load game"); | ||||||
|         Button SelectLevel= new Button("Select Level"); |         Button SelectLevel= new Button("Select Level"); | ||||||
|  |  | ||||||
|         Label Title = new Label("Welcome to Road to Master"); |         Label Title = new Label("Welcome to Road to Master"); | ||||||
|             SlctDifficulty.setOnAction(event -> { |             SlctDifficulty.setOnAction(event -> { | ||||||
|                 String choosediff = SlctDifficulty.getSelectionModel().getSelectedItem(); |                 String choosediff = SlctDifficulty.getSelectionModel().getSelectedItem(); | ||||||
| @ -52,12 +57,14 @@ public class MenuAccueil extends StackPane { | |||||||
|             }); |             }); | ||||||
|  |  | ||||||
|         //set up all the Button where I need |         //set up all the Button where I need | ||||||
|         getChildren().addAll(Title,SlctDifficulty,SelectLevel,RdmLvl); |  | ||||||
|  |         getChildren().addAll(Title,SlctDifficulty,SelectLevel,RdmLvl,LoadLvl); | ||||||
|         RdmLvl.setFont(Font.font(25)); |         RdmLvl.setFont(Font.font(25)); | ||||||
|         RdmLvl.setTextFill(Color.GOLD); |         RdmLvl.setTextFill(Color.GOLD); | ||||||
|         Title.setFont(Font.font(40)); |         Title.setFont(Font.font(40)); | ||||||
|         Title.setTextFill(Color.RED); |         Title.setTextFill(Color.RED); | ||||||
|         setAlignment(Title, Pos.TOP_CENTER); |         setAlignment(Title, Pos.TOP_CENTER); | ||||||
|  |         setAlignment(LoadLvl,Pos.BOTTOM_CENTER); | ||||||
|         setAlignment(SlctDifficulty,Pos.CENTER_LEFT); |         setAlignment(SlctDifficulty,Pos.CENTER_LEFT); | ||||||
|         setAlignment(SelectLevel,Pos.CENTER_RIGHT); |         setAlignment(SelectLevel,Pos.CENTER_RIGHT); | ||||||
|         setAlignment(RdmLvl, Pos.CENTER_LEFT); |         setAlignment(RdmLvl, Pos.CENTER_LEFT); | ||||||
| @ -66,16 +73,18 @@ public class MenuAccueil extends StackPane { | |||||||
|         setMargin(SlctDifficulty,new Insets(0,0,0,300)); |         setMargin(SlctDifficulty,new Insets(0,0,0,300)); | ||||||
|         setMargin(SelectLevel,new Insets(0,300,0,0)); |         setMargin(SelectLevel,new Insets(0,300,0,0)); | ||||||
|         setMargin(Title,new Insets(200,0,0,0)); |         setMargin(Title,new Insets(200,0,0,0)); | ||||||
|  |         setMargin(LoadLvl,new Insets(0,0,200,0)); | ||||||
|  |  | ||||||
|         SelectLevel.setOnAction(event ->  Controller.switchRoot(new MenuLevel(1))); |         SelectLevel.setOnAction(event ->  Controller.switchRoot(new MenuLevel(1))); | ||||||
|  |         LoadLvl.setOnAction(event -> { | ||||||
|  |             try { | ||||||
|  |                 FileParserFactory.loadMapFromFile(new File("save.slevel")); | ||||||
|  |             } catch (IOException e) { | ||||||
|  |                 throw new RuntimeException(e); | ||||||
|  |             } | ||||||
|  |         }); | ||||||
|  |  | ||||||
|         getStyleClass().add("BorderPane"); |         getStyleClass().add("BorderPane"); | ||||||
|         getStylesheets().add(String.valueOf(getClass().getResource("StyleMenuAcceuil.css"))); |         getStylesheets().add(String.valueOf(getClass().getResource("StyleMenuAcceuil.css"))); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     } |     } | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
| } |  | ||||||
| @ -7,6 +7,11 @@ import javafx.scene.layout.ColumnConstraints; | |||||||
| import javafx.scene.layout.GridPane; | import javafx.scene.layout.GridPane; | ||||||
| import javafx.scene.layout.RowConstraints; | import javafx.scene.layout.RowConstraints; | ||||||
| import school_project.Controller; | import school_project.Controller; | ||||||
|  | import school_project.GameUI; | ||||||
|  | import school_project.Parsers.FileParserFactory; | ||||||
|  |  | ||||||
|  | import java.io.File; | ||||||
|  | import java.io.IOException; | ||||||
|  |  | ||||||
| public class MenuLevel extends GridPane { | public class MenuLevel extends GridPane { | ||||||
|     private int StartLevel; |     private int StartLevel; | ||||||
| @ -60,30 +65,38 @@ public class MenuLevel extends GridPane { | |||||||
|         //It's here that I put all buttons where I need (base on column not row) |         //It's here that I put all buttons where I need (base on column not row) | ||||||
|         for (int i = 0; i < 3; i++) { |         for (int i = 0; i < 3; i++) { | ||||||
|             for (int j = 1; j < 5; j++) { |             for (int j = 1; j < 5; j++) { | ||||||
|  | 				Button levelButton = new Button("level "+(StartLevel)); | ||||||
|  |                 levelButton.setOnAction(event -> { | ||||||
|  |                     try { | ||||||
|  |                         String levelName = ((Button)event.getSource()).getText().replace(" ", "") + ".level"; | ||||||
|  |                         System.out.println(levelName); | ||||||
|  |                         GameUI level = new GameUI(FileParserFactory.loadMapFromFile(new File(Controller.class.getResource("levels/" + levelName).getFile()))); | ||||||
|  |                         Controller.switchRoot(level); | ||||||
|  |                     } catch (IOException e) { | ||||||
|  |                         System.out.println("Le niveau " + StartLevel + "n'existe pas."); | ||||||
|  |                     } | ||||||
|  |                 }); | ||||||
|                 if(i==0){ |                 if(i==0){ | ||||||
|                     Button Level = new Button("level "+(StartLevel)); |  | ||||||
|                     StartLevel+=3; |                     StartLevel+=3; | ||||||
|                     add(Level,i,j); |                     add(levelButton,i,j); | ||||||
|                     setHalignment(Level,HPos.CENTER); |                     setHalignment(levelButton,HPos.CENTER); | ||||||
|                     if(j==4){ |                     if(j==4){ | ||||||
|                         StartLevel-=11; |                         StartLevel-=11; | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|                 else if(i==1&&j!=4) { |                 else if(i==1&&j!=4) { | ||||||
|                     Button Level = new Button("level "+(StartLevel)); |  | ||||||
|                     StartLevel += 3; |                     StartLevel += 3; | ||||||
|                     add(Level, i, j); |                     add(levelButton, i, j); | ||||||
|                     setHalignment(Level,HPos.CENTER); |                     setHalignment(levelButton,HPos.CENTER); | ||||||
|                     if (j == 3) { |                     if (j == 3) { | ||||||
|                         StartLevel -=8; |                         StartLevel -=8; | ||||||
|  |  | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|                 else if(i==2&&j!=4){ |                 else if(i==2&&j!=4){ | ||||||
|                     Button Level = new Button("level "+(StartLevel)); |  | ||||||
|                     StartLevel+=3; |                     StartLevel+=3; | ||||||
|                     add(Level,i,j); |                     add(levelButton,i,j); | ||||||
|                     setHalignment(Level,HPos.CENTER); |                     setHalignment(levelButton,HPos.CENTER); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -0,0 +1 @@ | |||||||
|  | SMS<03><13>SME | ||||||
| @ -0,0 +1 @@ | |||||||
|  | SMS<04><>"<22>"<22>"p1<70>SME | ||||||
| @ -0,0 +1 @@ | |||||||
|  | SMS<05><><EFBFBD><EFBFBD>"<22>1<EFBFBD><13>2<EFBFBD>"p3<70><33>SME | ||||||
| @ -0,0 +1 @@ | |||||||
|  | SMS?<3F><><EFBFBD><EFBFBD><13>"<22>3<EFBFBD><33><13>"<22>2<EFBFBD>3<EFBFBD><33>SME | ||||||
| @ -0,0 +1 @@ | |||||||
|  | SMSf<><66><EFBFBD><	1<>"<22>"p<11>&<26><>"<22>"<22>"<22><13>SME | ||||||
| @ -0,0 +1 @@ | |||||||
|  | SMS<05><><EFBFBD>"<22>1<EFBFBD><11>"p#<23><12>!<21>SME | ||||||
| @ -0,0 +1 @@ | |||||||
|  | SMS<05><><EFBFBD><EFBFBD>"<22><13><11>"p3<70><33>3o<33>SME | ||||||
| @ -0,0 +1 @@ | |||||||
|  | SMS<06><><EFBFBD><EFBFBD><EFBFBD>3<><33>3<EFBFBD><33>1<EFBFBD>1<EFBFBD>#<23>#<23>SME | ||||||
							
								
								
									
										
											BIN
										
									
								
								app/src/main/resources/school_project/levels/level18.level
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								app/src/main/resources/school_project/levels/level18.level
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| @ -0,0 +1 @@ | |||||||
|  | SMS<06><><EFBFBD><EFBFBD><EFBFBD><13>3<EFBFBD><33>3o<33>4<34>"<22>SME | ||||||
| @ -0,0 +1 @@ | |||||||
|  | SMS<01>1<>SME | ||||||
| @ -0,0 +1 @@ | |||||||
|  | SMS<05><><EFBFBD><EFBFBD><12>3<EFBFBD><33>"<22>2<EFBFBD>3<EFBFBD><33>SME | ||||||
							
								
								
									
										
											BIN
										
									
								
								app/src/main/resources/school_project/levels/level21.level
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								app/src/main/resources/school_project/levels/level21.level
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| @ -0,0 +1 @@ | |||||||
|  | SMS<05><><EFBFBD><EFBFBD>"p<13><12>"<22>#<23>#<23>#<23>SME | ||||||
| @ -0,0 +1 @@ | |||||||
|  | SMS<05><><EFBFBD><EFBFBD>2<><13>"<22>#<23>#<23>BSME | ||||||
| @ -0,0 +1 @@ | |||||||
|  | SMSv<><76><EFBFBD>#<23><11><11>#<23>#<23>BSME | ||||||
| @ -0,0 +1 @@ | |||||||
|  | SMS<06><><EFBFBD><EFBFBD><EFBFBD>#<23>#|!<21>#\#<23>2<EFBFBD>2<EFBFBD>BSME | ||||||
							
								
								
									
										
											BIN
										
									
								
								app/src/main/resources/school_project/levels/level26.level
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								app/src/main/resources/school_project/levels/level26.level
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| @ -0,0 +1 @@ | |||||||
|  | SMS<06><><EFBFBD><EFBFBD><EFBFBD>#<23>#<23>!<21>!<21>#<23>4<34>3o<33>SME | ||||||
| @ -0,0 +1 @@ | |||||||
|  | SMS<07><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<>B#|3?<3F>3<EFBFBD><33>#<23>&<26><>SME | ||||||
| @ -0,0 +1 @@ | |||||||
|  | SMSy<><79>y<EFBFBD>B<>!<21>B<EFBFBD>$<24>#<23>#<23>SME | ||||||
| @ -0,0 +1 @@ | |||||||
|  | SMS<03><>#<23><13>SME | ||||||
| @ -0,0 +1 @@ | |||||||
|  | SMS<07><><EFBFBD>}<7D>߀$<24>3ۀ2<DB80><11><11>"<22>2x"p2<70>"<22>2<EFBFBD>SME | ||||||
| @ -0,0 +1 @@ | |||||||
|  | SMS<04><>#<23>#<23><11>1<EFBFBD>SME | ||||||
| @ -0,0 +1 @@ | |||||||
|  | SMS<>p<11><11>1<EFBFBD>#<23>#<23>SME | ||||||
| @ -0,0 +1 @@ | |||||||
|  | SMS<>3<><33><13>1<EFBFBD>SME | ||||||
| @ -0,0 +1 @@ | |||||||
|  | SMS3<>2<><13>"<22>SME | ||||||
| @ -0,0 +1 @@ | |||||||
|  | SMS<05><><EFBFBD><EFBFBD>2<>"<22>"<22>"p1<70><11>1<EFBFBD>"pSME | ||||||
| @ -0,0 +1 @@ | |||||||
|  | SMS<05><>߀1<>1<EFBFBD>3<EFBFBD><33>#<23>"<22>SME | ||||||
		Reference in New Issue
	
	Block a user