-
Notifications
You must be signed in to change notification settings - Fork 1
/
GameView.java
136 lines (89 loc) · 2.98 KB
/
GameView.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import java.io.FileInputStream;
import javafx.geometry.Pos;
import javafx.geometry.Rectangle2D;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundImage;
import javafx.scene.layout.BackgroundPosition;
import javafx.scene.layout.BackgroundRepeat;
import javafx.scene.layout.BackgroundSize;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.stage.Screen;
/**
* This class represent a game page's view
*
*
* @author Sevda Imany
* @version 0.0.5
*/
public class GameView extends BorderPane {
/* Fields */
//game's playground object
private GamePlayGround gamePlayGround;
//player's information hbox
private HBox hBoxInfo;
// award label
private static Label awardLable;
/* Constructor */
/**
* create new game page's view
*/
public GameView()
{
gamePlayGround = new GamePlayGround();
this.setCenter(Main.getRootPlayGround());
Rectangle2D screenBounds = Screen.getPrimary().getBounds();
this.setPrefSize(screenBounds.getWidth(),screenBounds.getHeight() -60);
//background picture
FileInputStream input = null;
try {
input = new FileInputStream(DataBase.getBackground2Icon());
}catch (Exception e){e.printStackTrace();}
Image image = new Image(input);
BackgroundImage backgroundimage = new BackgroundImage(image,
BackgroundRepeat.NO_REPEAT,
BackgroundRepeat.NO_REPEAT,
BackgroundPosition.DEFAULT,
BackgroundSize.DEFAULT);
this.setBackground(new Background(backgroundimage));
}
/* Methods */
/**
* this method add player's information hbox at the bottom of gameView
*/
public void addPlayersInfo(){
hBoxInfo = new HBox();
awardLable = new Label();
awardLable.setTextFill(Color.RED);
awardLable.setFont(Font.font(15));
VBox vBox = new VBox(awardLable , hBoxInfo);
vBox.setAlignment(Pos.CENTER);
vBox.setSpacing(10);
for (Player player : GameState.getPlayers()){
PlayerInfoView playerInfoView = new PlayerInfoView(player);
hBoxInfo.getChildren().add(playerInfoView);
GameState.getTankProgressBar().put(player.getPlayerTank(),playerInfoView.getPbHealth());
}
hBoxInfo.setAlignment(Pos.CENTER);
hBoxInfo.setSpacing(60);
this.setBottom(vBox);
}
// * getter methods *
/**
* @return game's Playground
*/
public GamePlayGround getGamePlayGround() {
return gamePlayGround;
}
/**
* @return award Label
*/
public static Label getAwardLable() {
return awardLable;
}
}