Highscores einfügen & Score im Spiel

This commit is contained in:
Mats Pape 2022-01-11 13:38:37 +01:00
commit ac4ab16654
12 changed files with 105 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@ -50,10 +50,13 @@ public class HappyBirdMain extends Application {
private final Button settingsButtonPause = new Button("EINSTELLUNGEN"); private final Button settingsButtonPause = new Button("EINSTELLUNGEN");
private final Button menuButtonPause = new Button("HAUPTMENÜ"); private final Button menuButtonPause = new Button("HAUPTMENÜ");
private final Button backButtonPause = new Button("ZURÜCK"); private final Button backButtonPause = new Button("ZURÜCK");
private final Button background1 = new Button();
private final Button background2 = new Button();
/*Buttons in Arrays speichern*/ /*Buttons in Arrays speichern*/
private final Button[] buttons = {startButton, highscoresButton, settingsButton, startGameButton, menuButton, pauseButton, continueButton, settingsButtonPause, menuButtonPause, backButtonPause}; private final Button[] buttons = {startButton, highscoresButton, settingsButton, startGameButton, menuButton, pauseButton, continueButton, settingsButtonPause, menuButtonPause, backButtonPause};
private final Button[] pauseButtons = {continueButton, settingsButtonPause, menuButtonPause, backButtonPause}; private final Button[] pauseButtons = {continueButton, settingsButtonPause, menuButtonPause, backButtonPause};
private final Button[] backgroundButtons = {background1, background2};
/*Textfelder erstellen und zuweisen*/ /*Textfelder erstellen und zuweisen*/
private final TextField name = new TextField(); private final TextField name = new TextField();
@ -115,7 +118,7 @@ public class HappyBirdMain extends Application {
menuScreenRunning = true; menuScreenRunning = true;
/*Bild für Hintergrund erstellen:*/ /*Bild für Hintergrund erstellen:*/
Image image = new Image("file:src/main/resources/com/example/happy_bird/pics/Background.png"); Image image = new Image("file:src/main/resources/com/example/happy_bird/pics/Background0.png");
/*Hintergrund erstellen:*/ /*Hintergrund erstellen:*/
BackgroundImage backgroundImage = new BackgroundImage( BackgroundImage backgroundImage = new BackgroundImage(
@ -179,6 +182,13 @@ public class HappyBirdMain extends Application {
/*settingsButtonPause unsichtbar*/ /*settingsButtonPause unsichtbar*/
settingsButtonPause.setVisible(false); settingsButtonPause.setVisible(false);
/*Buttons für Hintergründe*/
backgroundButtonsFormating();
/*Background-Buttons unsichtbar*/
background1.setVisible(false);
background2.setVisible(false);
/*Textfelder formatieren:*/ /*Textfelder formatieren:*/
textfieldsFormating(inputFields, pane); textfieldsFormating(inputFields, pane);
@ -280,6 +290,53 @@ public class HappyBirdMain extends Application {
} }
} }
public void backgroundButtonsFormating() {
int xPosition = 150;
for(int i=0; i<backgroundButtons.length; i++) {
backgroundButtons[i].setPrefSize(200, 175);
backgroundButtons[i].setLayoutY(400);
backgroundButtons[i].setLayoutX(xPosition);
xPosition += 300;
/*Bild für Hintergrund erstellen:*/
Image image = new Image("file:src/main/resources/com/example/happy_bird/pics/Background"+i+"button.png");
/*Hintergrund erstellen:*/
BackgroundImage backgroundImage = new BackgroundImage(
image,
BackgroundRepeat.NO_REPEAT,
BackgroundRepeat.NO_REPEAT,
BackgroundPosition.DEFAULT,
BackgroundSize.DEFAULT
);
/*Hintergrund zu Pane hinzufügen:*/
Background background = new Background(backgroundImage);
backgroundButtons[i].setBackground(background);
backgroundButtons[i].setStyle("-fx-border-width: 7px;" +
"-fx-border-insets: -7;" +
"-fx-border-color: #FFFFFF;" +
"-fx-border-radius: 15px;");
pane.getChildren().add(backgroundButtons[i]);
}
/*
for(Button button : backgroundButtons) {
button.setPrefSize(200,150);
button.setLayoutY(400);
button.setLayoutX(xPosition);
xPosition += 300;
pane.getChildren().add(button);
}*/
}
/*** /***
* Formatiert alle kleinen Labels (keine Überschrift) und fügt sie der Pane hinzu * Formatiert alle kleinen Labels (keine Überschrift) und fügt sie der Pane hinzu
* @param labels LabelArray mit allen Labels * @param labels LabelArray mit allen Labels
@ -447,6 +504,46 @@ public class HappyBirdMain extends Application {
menuButton.setVisible(true); menuButton.setVisible(true);
soundSlider.setVisible(true); soundSlider.setVisible(true);
soundLabel.setVisible(true); soundLabel.setVisible(true);
background1.setVisible(true);
background2.setVisible(true);
background1.setOnAction(event -> {
/*Bild für Hintergrund erstellen:*/
Image image = new Image("file:src/main/resources/com/example/happy_bird/pics/Background0.png");
/*Hintergrund erstellen:*/
BackgroundImage backgroundImage = new BackgroundImage(
image,
BackgroundRepeat.NO_REPEAT,
BackgroundRepeat.NO_REPEAT,
BackgroundPosition.DEFAULT,
BackgroundSize.DEFAULT
);
/*Hintergrund zu Pane hinzufügen:*/
Background background = new Background(backgroundImage);
pane.setBackground(background);
});
background2.setOnAction(event -> {
/*Bild für Hintergrund erstellen:*/
Image image = new Image("file:src/main/resources/com/example/happy_bird/pics/Background1.png");
/*Hintergrund erstellen:*/
BackgroundImage backgroundImage = new BackgroundImage(
image,
BackgroundRepeat.NO_REPEAT,
BackgroundRepeat.NO_REPEAT,
BackgroundPosition.DEFAULT,
BackgroundSize.DEFAULT
);
/*Hintergrund zu Pane hinzufügen:*/
Background background = new Background(backgroundImage);
pane.setBackground(background);
});
} }
/*** /***
@ -529,7 +626,14 @@ public class HappyBirdMain extends Application {
settingsButton.setVisible(true); settingsButton.setVisible(true);
menuButton.setVisible(false); menuButton.setVisible(false);
startGameButton.setVisible(false); startGameButton.setVisible(false);
<<<<<<< HEAD
highscoreMenuLabel.setVisible(false); highscoreMenuLabel.setVisible(false);
=======
background1.setVisible(false);
background2.setVisible(false);
>>>>>>> 7f359cb01fb2872353dbcf5aa715e11820a54013
/*soundSlider ausblenden*/ /*soundSlider ausblenden*/
soundSlider.setVisible(false); soundSlider.setVisible(false);

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB