Piece rotation
This commit is contained in:
@ -2,6 +2,7 @@ package school_project;
|
||||
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.input.MouseButton;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.paint.Color;
|
||||
@ -15,15 +16,20 @@ public class GameUI extends BorderPane {
|
||||
public GameUI(Map level) throws FileNotFoundException {
|
||||
super();
|
||||
|
||||
MatrixShape grid = new MatrixShape(level, true);
|
||||
MatrixShape grid = new MatrixShape(level);
|
||||
grid.setAlignment(Pos.CENTER);
|
||||
grid.setColor(Color.WHITE);
|
||||
|
||||
HBox pieces = new HBox();
|
||||
pieces.setSpacing(10);
|
||||
for (Piece p : level.getPieces()) {
|
||||
MatrixShape _piece = new MatrixShape(p, false);
|
||||
_piece.setColor(p.getColor());
|
||||
MatrixShape _piece = new MatrixShape(p);
|
||||
_piece.setOnMouseClicked(event -> {
|
||||
if(event.getButton() == MouseButton.SECONDARY){
|
||||
((Piece) _piece.shape).RotateRight(1);
|
||||
_piece.update();
|
||||
}
|
||||
});
|
||||
pieces.getChildren().add(_piece);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user