Skip to content
Snippets Groups Projects
Commit 6ee91891 authored by Tran Peter's avatar Tran Peter
Browse files

update(ui): update gamescene ui #14

parent 7fcc0378
No related branches found
No related tags found
5 merge requests!74V1,!73Initial commit,!71Merge DataBase into Development,!27Player can now place bombs that have a explosion radius that dont go through the wall.,!26Merge game scene into development
...@@ -21,8 +21,10 @@ import javafx.geometry.Rectangle2D; ...@@ -21,8 +21,10 @@ import javafx.geometry.Rectangle2D;
import javafx.scene.canvas.Canvas; import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext; import javafx.scene.canvas.GraphicsContext;
import javafx.scene.control.Label;
import javafx.scene.control.Slider; import javafx.scene.control.Slider;
import javafx.scene.layout.BorderPane; import javafx.scene.layout.BorderPane;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane; import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
import javafx.scene.shape.Rectangle; import javafx.scene.shape.Rectangle;
...@@ -46,14 +48,14 @@ public class GameSceneController implements Initializable { ...@@ -46,14 +48,14 @@ public class GameSceneController implements Initializable {
@FXML @FXML
private Rectangle playerHealth, enemyHealth; private Rectangle playerHealth, enemyHealth;
@FXML @FXML
private VBox healthVBox, hpVBox; private Pane playerPane, enemyPane;
@FXML @FXML
private Text playerHp, enemyHp; private Label playerHp, enemyHp;
@FXML @FXML
private StackPane stackPane; private StackPane stackPane;
Screen screen = Screen.getPrimary(); Screen screen = Screen.getPrimary();
Rectangle2D visualBounds = screen.getVisualBounds(); Rectangle2D visualBounds = screen.getVisualBounds();
final private double healthBarWidth = screen.getBounds().getWidth() / 2.844; final private double healthBarWidth = screen.getBounds().getWidth() / 5;
ScreenDimensionCalculator screenCalculator = new ScreenDimensionCalculator(); ScreenDimensionCalculator screenCalculator = new ScreenDimensionCalculator();
private GraphicsContext graphicsContext2D; private GraphicsContext graphicsContext2D;
...@@ -105,12 +107,18 @@ public class GameSceneController implements Initializable { ...@@ -105,12 +107,18 @@ public class GameSceneController implements Initializable {
playerHp.setFont(Font.loadFont(getClass().getResourceAsStream("/fonts/StarshipShadow.ttf"), 55)); playerHp.setFont(Font.loadFont(getClass().getResourceAsStream("/fonts/StarshipShadow.ttf"), 55));
enemyHp.setFont(Font.loadFont(getClass().getResourceAsStream("/fonts/StarshipShadow.ttf"), 55)); enemyHp.setFont(Font.loadFont(getClass().getResourceAsStream("/fonts/StarshipShadow.ttf"), 55));
playerHp.setText("100%"); playerHp.setText("100%");
playerHp.setMinWidth(120);
enemyHp.setText("100%"); enemyHp.setText("100%");
enemyHp.setMinWidth(120);
// stopping the VBox from shrinking when health bar gets smaller // stopping the VBox from shrinking when health bar gets smaller
healthVBox.setMinWidth(healthBarWidth); // healthVBox.setMinWidth(healthBarWidth);
healthVBox.setMaxWidth(healthBarWidth); // healthVBox.setMaxWidth(healthBarWidth);
hpVBox.setMinWidth(110); // hpVBox.setMinWidth(110);
playerPane.setMinWidth(healthBarWidth);
playerPane.setMaxWidth(healthBarWidth);
enemyPane.setMinWidth(healthBarWidth);
enemyPane.setMaxWidth(healthBarWidth);
playerHealth.setWidth(healthBarWidth); playerHealth.setWidth(healthBarWidth);
enemyHealth.setWidth(healthBarWidth); enemyHealth.setWidth(healthBarWidth);
......
...@@ -38,7 +38,7 @@ public class Driver extends Application { ...@@ -38,7 +38,7 @@ public class Driver extends Application {
Font.loadFont(getClass().getResourceAsStream("/fonts/Arthemis-mLA22.ttf"), 50); Font.loadFont(getClass().getResourceAsStream("/fonts/Arthemis-mLA22.ttf"), 50);
Font.loadFont(getClass().getResourceAsStream("/fonts/ShadowsIntoLight-Regular.ttf"), 50); Font.loadFont(getClass().getResourceAsStream("/fonts/ShadowsIntoLight-Regular.ttf"), 50);
Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/LoadingScreen.fxml"))); Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/GameScene.fxml")));
Scene scene = new Scene(root); Scene scene = new Scene(root);
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<?import javafx.geometry.Insets?> <?import javafx.geometry.Insets?>
<?import javafx.scene.canvas.Canvas?> <?import javafx.scene.canvas.Canvas?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Slider?> <?import javafx.scene.control.Slider?>
<?import javafx.scene.layout.BorderPane?> <?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?> <?import javafx.scene.layout.HBox?>
...@@ -9,8 +10,6 @@ ...@@ -9,8 +10,6 @@
<?import javafx.scene.layout.StackPane?> <?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<?import javafx.scene.shape.Rectangle?> <?import javafx.scene.shape.Rectangle?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>
<BorderPane fx:id="gameScene" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.GameSceneController"> <BorderPane fx:id="gameScene" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.GameSceneController">
<center> <center>
...@@ -24,32 +23,35 @@ ...@@ -24,32 +23,35 @@
</StackPane> </StackPane>
</center> </center>
<top> <top>
<HBox alignment="CENTER" spacing="30.0" BorderPane.alignment="CENTER"> <VBox BorderPane.alignment="CENTER">
<children> <children>
<VBox fx:id="healthVBox" alignment="CENTER_LEFT" spacing="20.0" HBox.hgrow="NEVER"> <Pane prefHeight="50.0" VBox.vgrow="ALWAYS" />
<HBox alignment="CENTER" spacing="30.0">
<children> <children>
<Pane VBox.vgrow="ALWAYS" /> <HBox alignment="CENTER_RIGHT" spacing="10.0">
<Rectangle fx:id="playerHealth" arcHeight="5.0" arcWidth="5.0" fill="#c92c1a" height="70.0" stroke="BLACK" strokeType="INSIDE" strokeWidth="0.0" width="900.0" /> <children>
<Rectangle fx:id="enemyHealth" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="70.0" stroke="BLACK" strokeType="INSIDE" strokeWidth="0.0" width="900.0" /> <Pane fx:id="playerPane" HBox.hgrow="ALWAYS">
<children>
<Rectangle fx:id="playerHealth" arcHeight="5.0" arcWidth="5.0" fill="#c92c1a" height="70.0" stroke="BLACK" strokeType="INSIDE" strokeWidth="0.0" width="900.0" />
</children>
</Pane>
<Label fx:id="playerHp" alignment="CENTER_RIGHT" />
</children>
</HBox>
<HBox spacing="10.0">
<children>
<Label fx:id="enemyHp" />
<Pane fx:id="enemyPane" HBox.hgrow="ALWAYS">
<children>
<Rectangle fx:id="enemyHealth" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="70.0" stroke="BLACK" strokeType="INSIDE" strokeWidth="0.0" width="900.0" />
</children>
</Pane>
</children>
</HBox>
</children> </children>
</VBox> </HBox>
<VBox fx:id="hpVBox" alignment="CENTER_LEFT" spacing="20.0" HBox.hgrow="NEVER">
<children>
<Pane VBox.vgrow="ALWAYS" />
<Text fx:id="playerHp" strokeType="OUTSIDE" strokeWidth="0.0" VBox.vgrow="ALWAYS">
<font>
<Font size="45.0" />
</font>
</Text>
<Text fx:id="enemyHp" strokeType="OUTSIDE" strokeWidth="0.0" VBox.vgrow="ALWAYS">
<font>
<Font size="45.0" />
</font>
</Text>
</children>
</VBox>
</children> </children>
</HBox> </VBox>
</top> </top>
<left> <left>
<VBox alignment="CENTER" prefHeight="200.0" prefWidth="100.0" BorderPane.alignment="CENTER"> <VBox alignment="CENTER" prefHeight="200.0" prefWidth="100.0" BorderPane.alignment="CENTER">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment