-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPaneOrganizer.java
49 lines (35 loc) · 1.28 KB
/
PaneOrganizer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package HACKATBROWNSLAY;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.Pane;
public class PaneOrganizer {
private BorderPane root;
private Pane gamePane;
private Pane backgroundPane;
private ImageView background;
private Game game;
public PaneOrganizer(){
this.root = new BorderPane();
this.createGamePane();
// this.createBackgroundPane();
this.game = new Game(this.gamePane, this.background);
}
public BorderPane getRoot(){
return this.root;
}
private void createGamePane(){
this.gamePane = new Pane();
this.gamePane.setPrefSize(Constants.GAME_WIDTH, Constants.GAME_HEIGHT);
this.root.setCenter(this.gamePane);
Image backgroundImage = new Image("./HACKATBROWNSLAY/base-map.jpeg");
this.background = new ImageView();
background.setImage(backgroundImage);
background.setFitHeight(750);
background.setPreserveRatio(true);
this.gamePane.getChildren().add(background);
this.gamePane.setOnKeyPressed((KeyEvent event) -> this.game.handleKeyPressed(event));
this.gamePane.setFocusTraversable(true);
}
}