diff --git a/src/main/java/de/hdm_stuttgart/battlearena/Controller/GameSceneController.java b/src/main/java/de/hdm_stuttgart/battlearena/Controller/GameSceneController.java index f0867a12a55675f930f5f3ba739a5eb6f5ba4cb2..b461f4d7e40818daf7a8f2f05cb8ae9e28f702aa 100644 --- a/src/main/java/de/hdm_stuttgart/battlearena/Controller/GameSceneController.java +++ b/src/main/java/de/hdm_stuttgart/battlearena/Controller/GameSceneController.java @@ -85,6 +85,8 @@ public class GameSceneController implements Initializable { int diffTileCount = 30; int scaledTileSize = 48; private final Biom biom = runtimeInfo.getMapBiom(); + private final long targetFrameTime = 1_000_000_000 / 80; // sets the target frame time to 12.5 ms (80fps) + private long lastFrame = 0; @Override public void initialize(URL url, ResourceBundle resourceBundle) { @@ -142,11 +144,15 @@ public class GameSceneController implements Initializable { AnimationTimer gameLoop = new AnimationTimer() { @Override - public void handle(long l) { + public void handle(long now) { if (!inputHandler.isPause()) { - graphicsContext2D.clearRect(0, 0, canvas2D.getWidth(), canvas2D.getHeight()); - renderContent(graphicsContext2D); - updateContent(); + if (now - lastFrame >= targetFrameTime) { // If short frame time (high fps) it will skip updateContent(). Next Frame has higher frame time and updates the frame + graphicsContext2D.clearRect(0, 0, canvas2D.getWidth(), canvas2D.getHeight()); + renderContent(graphicsContext2D); + updateContent(); + lastFrame = now; + } +// remove blur if (wasPaused) { resume(); } diff --git a/src/main/resources/fxml/LocalCreate.fxml b/src/main/resources/fxml/LocalCreate.fxml index 1da41963855b8d1448d6ad8828763194d3c61e50..50ecdfe94ed078789b47d315fe133810e54bdc28 100644 --- a/src/main/resources/fxml/LocalCreate.fxml +++ b/src/main/resources/fxml/LocalCreate.fxml @@ -17,7 +17,7 @@ <VBox fx:id="parent" alignment="BOTTOM_CENTER" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.LocalCreateController"> <children> <Pane VBox.vgrow="ALWAYS" /> - <HBox alignment="TOP_CENTER" spacing="20.0"> + <HBox alignment="CENTER" spacing="20.0"> <children> <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Rounds:" /> <Accordion> @@ -52,7 +52,7 @@ </VBox.margin> </HBox> <Pane VBox.vgrow="ALWAYS" /> - <HBox alignment="TOP_CENTER" spacing="20.0"> + <HBox alignment="CENTER" spacing="20.0"> <children> <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Time:" /> <Accordion> diff --git a/src/main/resources/fxml/MapSelection.fxml b/src/main/resources/fxml/MapSelection.fxml index 1e30251d4dfa7c27720efbf14466425362af6208..0d975539ecdb7d9a755ef8584c8fddb424ab7459 100644 --- a/src/main/resources/fxml/MapSelection.fxml +++ b/src/main/resources/fxml/MapSelection.fxml @@ -12,70 +12,77 @@ <?import javafx.scene.layout.VBox?> <?import javafx.scene.text.Text?> -<VBox fx:id="parent" alignment="CENTER" prefHeight="400.0" prefWidth="600.0" spacing="20.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.MapSelectionController"> + +<HBox xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hdm_stuttgart.battlearena.Controller.MapSelectionController"> <children> - <Pane VBox.vgrow="ALWAYS" /> - <HBox alignment="TOP_CENTER" spacing="20.0"> + <Pane HBox.hgrow="ALWAYS" /> + <VBox fx:id="parent" alignment="CENTER" prefHeight="400.0" prefWidth="600.0" spacing="20.0"> <children> - <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Maps:" /> - <Accordion> - <panes> - <TitledPane fx:id="maps" text="Select"> - <content> - <ScrollPane minViewportHeight="200.0"> + <Pane VBox.vgrow="ALWAYS" /> + <HBox alignment="CENTER_LEFT" spacing="20.0"> + <children> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Maps:" /> + <Accordion> + <panes> + <TitledPane fx:id="maps" text="Select"> <content> - <VBox fx:id="boxBox" /> + <ScrollPane minViewportHeight="200.0"> + <content> + <VBox fx:id="boxBox" /> + </content> + </ScrollPane> </content> - </ScrollPane> - </content> - </TitledPane> - </panes> - </Accordion> - </children> - <VBox.margin> - <Insets /> - </VBox.margin> - </HBox> - <HBox alignment="TOP_CENTER" spacing="20.0"> - <children> - <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Texture pack:" /> - <Accordion> - <panes> - <TitledPane fx:id="textures" text="Select"> - <content> - <ScrollPane minViewportHeight="200.0"> + </TitledPane> + </panes> + </Accordion> + </children> + <VBox.margin> + <Insets /> + </VBox.margin> + </HBox> + <HBox alignment="CENTER_LEFT" spacing="20.0"> + <children> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Texture pack:" /> + <Accordion> + <panes> + <TitledPane fx:id="textures" text="Select"> <content> - <VBox fx:id="boxBox1" alignment="CENTER_LEFT"> - <children> - <ToggleButton mnemonicParsing="false" text="Bomberman"> - <toggleGroup> - <ToggleGroup fx:id="textureToggle" /> - </toggleGroup> - </ToggleButton> - <ToggleButton mnemonicParsing="false" text="Dark Lands" toggleGroup="$textureToggle" /> - <ToggleButton mnemonicParsing="false" text="Forrest" toggleGroup="$textureToggle" /> - <ToggleButton mnemonicParsing="false" text="Grass" toggleGroup="$textureToggle" /> - </children> - </VBox> + <ScrollPane minViewportHeight="200.0"> + <content> + <VBox fx:id="boxBox1" alignment="CENTER_LEFT"> + <children> + <ToggleButton mnemonicParsing="false" text="Bomberman"> + <toggleGroup> + <ToggleGroup fx:id="textureToggle" /> + </toggleGroup> + </ToggleButton> + <ToggleButton mnemonicParsing="false" text="Dark Lands" toggleGroup="$textureToggle" /> + <ToggleButton mnemonicParsing="false" text="Forrest" toggleGroup="$textureToggle" /> + <ToggleButton mnemonicParsing="false" text="Grass" toggleGroup="$textureToggle" /> + </children> + </VBox> + </content> + </ScrollPane> </content> - </ScrollPane> - </content> - </TitledPane> - </panes> - </Accordion> - </children> - </HBox> - <HBox alignment="TOP_CENTER" maxWidth="-Infinity" minWidth="-Infinity" prefHeight="25.0" prefWidth="213.0" spacing="20.0"> - <children> - <Text fx:id="selectedMapText" strokeType="OUTSIDE" strokeWidth="0.0" /> + </TitledPane> + </panes> + </Accordion> + </children> + </HBox> + <HBox alignment="TOP_CENTER" maxWidth="-Infinity" minWidth="-Infinity" prefHeight="25.0" prefWidth="213.0" spacing="20.0"> + <children> + <Text fx:id="selectedMapText" strokeType="OUTSIDE" strokeWidth="0.0" /> + </children> + </HBox> + <Button mnemonicParsing="false" onAction="#gameScene" text="Start" /> + <Button mnemonicParsing="false" onAction="#backButton" text="Back"> + <VBox.margin> + <Insets bottom="50.0" /> + </VBox.margin> + </Button> + <Pane VBox.vgrow="ALWAYS" /> </children> - </HBox> - <Button mnemonicParsing="false" onAction="#gameScene" text="Start" /> - <Button mnemonicParsing="false" onAction="#backButton" text="Back"> - <VBox.margin> - <Insets bottom="50.0" /> - </VBox.margin> - </Button> - <Pane VBox.vgrow="ALWAYS" /> + </VBox> + <Pane HBox.hgrow="ALWAYS" /> </children> -</VBox> +</HBox> diff --git a/src/main/resources/styles/style.css b/src/main/resources/styles/style.css index 4e07a1f05d739765d13350a095d4e3fec485efbe..44d3c8fd1f2afc5807078d86285817fba447a187 100644 --- a/src/main/resources/styles/style.css +++ b/src/main/resources/styles/style.css @@ -34,7 +34,7 @@ #mainMenu{ - -fx-background-image: url("../textures/images/background.png"); + -fx-background-image: url("../textures/images/background.jpg"); -fx-background-size: cover; } @@ -56,7 +56,7 @@ #btnLeft { -fx-skin: none; - -fx-text-fill: #949494; + -fx-text-fill: #404040; } .accordion { diff --git a/src/main/resources/textures/images/test.jpg b/src/main/resources/textures/images/background.jpg similarity index 100% rename from src/main/resources/textures/images/test.jpg rename to src/main/resources/textures/images/background.jpg diff --git a/src/main/resources/textures/images/background.png b/src/main/resources/textures/images/background.png deleted file mode 100644 index 95ddedbae000b1a92ebeee73d0dbd68038d1e53a..0000000000000000000000000000000000000000 Binary files a/src/main/resources/textures/images/background.png and /dev/null differ