End-Screen - anfang des Eingbindens des Spiel-Neustarts & Persönliche Highscores

This commit is contained in:
Mats Pape 2022-01-25 12:45:32 +01:00
parent 98bcfec0fd
commit 3610c3fb7a
9 changed files with 16 additions and 7 deletions

View File

@ -25,6 +25,7 @@ public class HappyBirdMain extends Application {
private int collectedPoints; private int collectedPoints;
private int playerhighscore; private int playerhighscore;
private boolean openEndScreen = false; private boolean openEndScreen = false;
private boolean endScreenOpened = false;
/* Formatierungsklasse */ /* Formatierungsklasse */
private final FormatingClass formatingClass = new FormatingClass(); private final FormatingClass formatingClass = new FormatingClass();
@ -445,8 +446,9 @@ public class HappyBirdMain extends Application {
for (Rectangle rectangle : pipesToRemove) { for (Rectangle rectangle : pipesToRemove) {
pipesArrayList.remove(rectangle); pipesArrayList.remove(rectangle);
} }
} else { } else if (endScreenOpened == false) {
generateEndScreen(); generateEndScreen();
endScreenOpened = true;
} }
} }
}; };
@ -895,9 +897,10 @@ public class HappyBirdMain extends Application {
*/ */
public String calculatePersonalHighscores() { public String calculatePersonalHighscores() {
String bestFiveHighscores = "PLAYER\t\tSCORE\n\n"; String bestFiveHighscores = "PLAYER\t\tSCORE\n\n";
String currentPlayer = acronymLabel.getText(); String currentPlayer = acronym.getText();
int i = 0; int i = 0;
String sql = "SELECT * FROM happybirddb WHERE kuerzel = '" + currentPlayer + "' ORDER BY punkte DESC LIMIT 5;"; String sql = "SELECT * FROM happybirddb WHERE kuerzel = '" + currentPlayer + "' ORDER BY punkte DESC LIMIT 5;";
System.out.println(sql);
try (ResultSet rs = datenbank.st.executeQuery(sql)) { try (ResultSet rs = datenbank.st.executeQuery(sql)) {
while (rs.next()) while (rs.next())
{ {
@ -1035,6 +1038,11 @@ public class HappyBirdMain extends Application {
*/ */
private void restartGameButtonClick() { private void restartGameButtonClick() {
pane.getChildren().remove(endScreen); pane.getChildren().remove(endScreen);
pane.getChildren().remove(happyBird);
for (Rectangle pipe : pipesArrayList) {
pane.getChildren().remove(pipe);
}
collectedPoints = 0;
startGameButtonClick(); startGameButtonClick();
} }
@ -1044,6 +1052,7 @@ public class HappyBirdMain extends Application {
*/ */
private void personalHighscoresButtonClick() { private void personalHighscoresButtonClick() {
/* alle Buttons ausblenden */ /* alle Buttons ausblenden */
System.out.println("Highscore-Button");
for(Button button : endscreenButtons) { for(Button button : endscreenButtons) {
button.setVisible(false); button.setVisible(false);
} }
@ -1057,12 +1066,11 @@ public class HappyBirdMain extends Application {
currentScoreEndscreenLabel.setVisible(false); currentScoreEndscreenLabel.setVisible(false);
/* Highscore-Label (Hintergrund) formatieren und einfügen */ /* Highscore-Label (Hintergrund) formatieren und einfügen */
highscoreMenuLabel.setLayoutX(275); highscoreMenuLabel.setLayoutX(75);
highscoreMenuLabel.setLayoutY(225); highscoreMenuLabel.setLayoutY(150);
highscoreMenuLabel.setPrefHeight(300); highscoreMenuLabel.setPrefSize(250, 300);
highscoreMenuLabel.setPrefSize(250, 250);
highscoreMenuLabel.setVisible(true);
endScreen.getChildren().add(highscoreMenuLabel); endScreen.getChildren().add(highscoreMenuLabel);
highscoreMenuLabel.setVisible(true);
/* Highscores des Spielers einfügen */ /* Highscores des Spielers einfügen */
String personalBestScores = calculatePersonalHighscores(); String personalBestScores = calculatePersonalHighscores();
@ -1078,6 +1086,7 @@ public class HappyBirdMain extends Application {
currentScoreEndscreenLabel.setVisible(true); currentScoreEndscreenLabel.setVisible(true);
highscoreMenuLabel.setVisible(false); highscoreMenuLabel.setVisible(false);
backEndscreenButton.setVisible(false); backEndscreenButton.setVisible(false);
endScreen.getChildren().remove(highscoreMenuLabel);
}); });
} }