2023-04-29 19:01:31 +02:00
|
|
|
package school_project;
|
|
|
|
|
2023-05-03 11:11:16 +02:00
|
|
|
import javafx.geometry.Insets;
|
2023-04-29 19:01:31 +02:00
|
|
|
import javafx.geometry.Pos;
|
|
|
|
import javafx.scene.layout.BorderPane;
|
|
|
|
import javafx.scene.layout.HBox;
|
|
|
|
import javafx.scene.paint.Color;
|
|
|
|
import school_project.Utils.MatrixShape;
|
|
|
|
|
2023-05-03 11:11:16 +02:00
|
|
|
import java.io.FileNotFoundException;
|
|
|
|
|
2023-04-29 19:01:31 +02:00
|
|
|
public class GameUI extends BorderPane {
|
|
|
|
public final static int SEGMENT_SIZE = 50;
|
2023-05-03 11:11:16 +02:00
|
|
|
public final static int SPACE_SIZE = 5;
|
|
|
|
public GameUI(Map level) throws FileNotFoundException {
|
2023-04-29 19:01:31 +02:00
|
|
|
super();
|
|
|
|
|
2023-05-03 11:11:16 +02:00
|
|
|
MatrixShape grid = new MatrixShape(level, true);
|
2023-04-29 19:01:31 +02:00
|
|
|
grid.setAlignment(Pos.CENTER);
|
|
|
|
grid.setColor(Color.WHITE);
|
|
|
|
|
|
|
|
HBox pieces = new HBox();
|
|
|
|
pieces.setSpacing(10);
|
|
|
|
for (Piece p : level.getPieces()) {
|
2023-05-03 11:11:16 +02:00
|
|
|
MatrixShape _piece = new MatrixShape(p, false);
|
2023-05-01 19:48:42 +02:00
|
|
|
_piece.setColor(p.getColor());
|
2023-04-29 19:01:31 +02:00
|
|
|
pieces.getChildren().add(_piece);
|
|
|
|
}
|
|
|
|
|
|
|
|
setCenter(grid);
|
|
|
|
setBottom(pieces);
|
|
|
|
}
|
|
|
|
}
|