Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class GamePane extends GridPane{
- Scene scene = Game.scene;
- private int rowAmount;
- private int columnAmount;
- char[][] charArray = new char[11][11];
- Input input = new Input(scene);
- public GamePane(int rowAmount, int columnAmount, Input input){
- charArray = MapReader.parsedChars();
- this.columnAmount = columnAmount;
- this.rowAmount = rowAmount;
- this.input = input;
- ColumnConstraints columnn;
- RowConstraints row;
- GridPane gameGrid = new GridPane();
- for (int i = 0; i < columnAmount; i++) {
- columnn = new ColumnConstraints(45);
- gameGrid.getColumnConstraints().add(columnn);
- gameGrid.setStyle("-fx-background-color: white; -fx-grid-lines-visible:true");
- }
- for (int i = 0; i < rowAmount; i++) {
- row = new RowConstraints(45);
- gameGrid.getRowConstraints().add(row);
- }
- for (int countCols = 0; countCols < rowAmount; countCols++) {
- for (int countRows = 0; countRows < columnAmount; countRows++) {
- Pane cellPane = new Pane();
- ;
- cellPane.setMaxSize(50,50);
- cellPane.setMinSize(50, 50);
- cellPane.setStyle("fx-grid-lines-visible:true");
- this.add(cellPane, countCols, countRows);
- if (charArray[countCols][countRows] == '#') {
- ;
- Image wallImage = new Image(getClass().getResource("Wall.png").toExternalForm());
- //input.addListeners();
- this.add(new Wall(cellPane, wallImage, 0, 0, 0, 0, input), countCols, countRows);
- this.add(Game.walls, countRows, countRows);
- }
- public static boolean checkWallCollisions(){
- boolean wallCollision = false;
- for(Player player: players){
- for(Wall wall: walls){
- if(player.collidesWith(wall) && Player.canMove == true){
- //System.out.println("Player collided with wall");
- player.setDy(-player.getDy());
- player.setDx(-player.getDx());
- //Player.canMove = false;
- player.move();
- //Wall.collision = true;
- }
- }
- }
- return wallCollision;
- }
- }
- }
- }
- public void addListeners(Scene scene) {
- scene.addEventFilter(KeyEvent.KEY_PRESSED, keyPressedEventHandler);
- scene.addEventFilter(KeyEvent.KEY_RELEASED, keyReleasedEventHandler);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement