Hinzufügen FormatingClass
This commit is contained in:
parent
a348fb03a5
commit
e2457886c8
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,239 @@
|
||||
package com.example.happy_bird;
|
||||
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.Slider;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.scene.text.TextAlignment;
|
||||
|
||||
public class FormatingClass {
|
||||
/***
|
||||
* leerer Konstruktor
|
||||
*/
|
||||
public FormatingClass() { }
|
||||
|
||||
/***
|
||||
* Formatiert alle Buttons und fügt sie der Pane hinzu
|
||||
* @param buttons ButtonArray mit allen Arrays
|
||||
* @param pane Pane, auf der die Buttons angezeigt werden
|
||||
*/
|
||||
public void buttonsFormating(Button[] buttons, Pane pane) {
|
||||
for (Button button : buttons) {
|
||||
button.setPrefSize(200, 50);
|
||||
|
||||
button.setStyle("-fx-background-color: #e86000; " +
|
||||
"-fx-text-fill: #FFFFFF; " +
|
||||
"-fx-font-size: 20px; " +
|
||||
"-fx-border-width: 5px;" +
|
||||
"-fx-border-color: #FFFFFF;" +
|
||||
"-fx-font-weight: bold;" +
|
||||
"-fx-border-radius: 15px;" +
|
||||
"-fx-background-radius: 20px;");
|
||||
|
||||
pane.getChildren().add(button);
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* Formatiert alle kleinen Labels (keine Überschrift) und fügt sie der Pane hinzu
|
||||
* @param labels LabelArray mit allen Labels
|
||||
* @param pane Pane, auf der die Labels angezeigt werden
|
||||
*/
|
||||
public void labelsFormating(Label[] labels, Pane pane) {
|
||||
for (Label label : labels) {
|
||||
label.setPrefSize(250, 50);
|
||||
|
||||
label.setStyle("-fx-background-color: #DED894; " +
|
||||
"-fx-text-fill: #000000; " +
|
||||
"-fx-font-size: 20px; " +
|
||||
"-fx-border-width: 5px;" +
|
||||
"-fx-border-color: #543847;" +
|
||||
"-fx-font-weight: bold;" +
|
||||
"-fx-alignment: center;" +
|
||||
"-fx-background-radius: 20px;" +
|
||||
"-fx-border-radius: 15px;");
|
||||
|
||||
pane.getChildren().add(label);
|
||||
|
||||
label.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* Formatiert alle Überschriften-Labels und fügt sie der Pane hinzu
|
||||
* @param labels LabelArray mit Überschriften-Labels
|
||||
* @param pane Pane, auf der die Labels angezeigt werden
|
||||
*/
|
||||
public void headlineFormating(Label[] labels, Pane pane) {
|
||||
for (Label label : labels) {
|
||||
label.setPrefSize(300, 75);
|
||||
label.setTextAlignment(TextAlignment.CENTER);
|
||||
|
||||
label.setStyle("-fx-background-color: #DED894; " +
|
||||
"-fx-text-fill: #000000; " +
|
||||
"-fx-font-size: 35px; " +
|
||||
"-fx-border-width: 5px;" +
|
||||
"-fx-border-color: #543847;" +
|
||||
"-fx-font-weight: bold;" +
|
||||
"-fx-alignment: center;" +
|
||||
"-fx-background-radius: 20px;" +
|
||||
"-fx-border-radius: 15px;");
|
||||
|
||||
pane.getChildren().add(label);
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* Formatiert alle Textfelder und fügt sie der Pane hinzu
|
||||
* @param textfields TextFieldArray mit allen Textfeldern
|
||||
* @param pane Pane, auf der die Textfelder angezeigt werden
|
||||
*/
|
||||
public void textfieldsFormating(TextField[] textfields, Pane pane) {
|
||||
for (TextField field : textfields) {
|
||||
field.setPrefSize(250, 50);
|
||||
field.setStyle("-fx-font-size: 20px;" +
|
||||
"-fx-font-weight: bold;");
|
||||
|
||||
pane.getChildren().add(field);
|
||||
|
||||
field.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* Formatiert den soundSlider und fügt ihn der Pane hinzu
|
||||
* @param slider SoundSlider
|
||||
* @param pane Pane, auf der der Slider angezeigt wird
|
||||
*/
|
||||
public void soundSliderFormating(Slider slider, Pane pane) {
|
||||
slider.setPrefSize(200, 5);
|
||||
slider.setLayoutX(300);
|
||||
slider.setLayoutY(295);
|
||||
|
||||
pane.getChildren().add(slider);
|
||||
|
||||
slider.setVisible(false);
|
||||
}
|
||||
|
||||
/***
|
||||
* Formatiert den PauseScreen
|
||||
*/
|
||||
public void pauseScreenFormating(Pane pause, Label pauseMenuLabel, Label soundLabelPause) {
|
||||
/*pause-Pane formatieren*/
|
||||
pause.setPrefSize(400, 400);
|
||||
pause.setLayoutX(200);
|
||||
pause.setLayoutY(150);
|
||||
pause.setStyle("-fx-background-color: #DED894; " +
|
||||
"-fx-border-width: 5px;" +
|
||||
"-fx-border-color: #543847;" +
|
||||
"-fx-border-radius: 15px;" +
|
||||
"-fx-background-radius: 20px;");
|
||||
|
||||
/*pauseMenuLabel formatieren*/
|
||||
pauseMenuLabel.setPrefSize(300,50);
|
||||
pauseMenuLabel.setLayoutX(50);
|
||||
pauseMenuLabel.setLayoutY(10);
|
||||
pauseMenuLabel.setStyle("-fx-background-color: #DED894; " +
|
||||
"-fx-text-fill: #000000; " +
|
||||
"-fx-font-size: 35px; " +
|
||||
"-fx-font-weight: bold;" +
|
||||
"-fx-alignment: center;");
|
||||
|
||||
/*soundLabelPause formatieren*/
|
||||
soundLabelPause.setPrefSize(100, 50);
|
||||
soundLabelPause.setLayoutX(150);
|
||||
soundLabelPause.setLayoutY(100);
|
||||
soundLabelPause.setStyle("-fx-background-color: #DED894; " +
|
||||
"-fx-text-fill: #000000; " +
|
||||
"-fx-font-size: 20px; " +
|
||||
"-fx-font-weight: bold;" +
|
||||
"-fx-alignment: center;");
|
||||
}
|
||||
|
||||
/***
|
||||
* formatiert den End-Screen
|
||||
*/
|
||||
public void endScreenFormating(Pane endScreen, Pane pause, Label endScreenHeadline, Label currentScoreEndscreenLabel) {
|
||||
/*Endscreen-Pane formatieren*/
|
||||
endScreen.setPrefSize(400, 500);
|
||||
pause.setLayoutX(200);
|
||||
pause.setLayoutY(100);
|
||||
pause.setStyle("-fx-background-color: #DED894; " +
|
||||
"-fx-border-width: 5px;" +
|
||||
"-fx-border-color: #543847;" +
|
||||
"-fx-border-radius: 15px;" +
|
||||
"-fx-background-radius: 20px;");
|
||||
|
||||
endScreenHeadline.setPrefSize(300,50);
|
||||
endScreenHeadline.setLayoutX(50);
|
||||
endScreenHeadline.setLayoutY(10);
|
||||
endScreenHeadline.setStyle("-fx-background-color: #DED894; " +
|
||||
"-fx-text-fill: #000000; " +
|
||||
"-fx-font-size: 35px; " +
|
||||
"-fx-font-weight: bold;" +
|
||||
"-fx-alignment: center;");
|
||||
|
||||
currentScoreEndscreenLabel.setPrefSize(250,50);
|
||||
currentScoreEndscreenLabel.setLayoutX(75);
|
||||
currentScoreEndscreenLabel.setLayoutY(100);
|
||||
currentScoreEndscreenLabel.setStyle("-fx-background-color: #DED894; " +
|
||||
"-fx-text-fill: #000000; " +
|
||||
"-fx-font-size: 35px; " +
|
||||
"-fx-font-weight: bold;" +
|
||||
"-fx-alignment: center;");
|
||||
}
|
||||
|
||||
/***
|
||||
* Erstellt ein neues BackgroundImage aus einer Source für ein .png
|
||||
* @param img Source eines .png
|
||||
* @return backgroundImage
|
||||
*/
|
||||
public BackgroundImage backgroundFormating(String img) {
|
||||
/*Bild für Hintergrund erstellen:*/
|
||||
Image image = new Image(img);
|
||||
|
||||
/*Hintergrund erstellen:*/
|
||||
BackgroundImage backgroundImage = new BackgroundImage(
|
||||
image,
|
||||
BackgroundRepeat.NO_REPEAT,
|
||||
BackgroundRepeat.NO_REPEAT,
|
||||
BackgroundPosition.DEFAULT,
|
||||
BackgroundSize.DEFAULT
|
||||
);
|
||||
|
||||
return backgroundImage;
|
||||
}
|
||||
|
||||
/***
|
||||
* Formatiert die Buttons, mit denen man das Hintergrundbild ändern kann
|
||||
* @param backgroundButtons Array der Buttons
|
||||
* @param pane Pane, auf der die Buttons angezeigt werden sollen
|
||||
*/
|
||||
public void backgroundButtonsFormating(Button[] backgroundButtons, Pane pane) {
|
||||
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;
|
||||
|
||||
/*Source als String*/
|
||||
String img = "file:src/main/resources/com/example/happy_bird/pics/Background"+i+"button.png";
|
||||
|
||||
/*Hintergrund zu Pane hinzufügen:*/
|
||||
Background background = new Background(backgroundFormating(img));
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.example.happy_bird;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Random;
|
||||
|
||||
public class GameObject {
|
||||
int x, y, width, height;
|
||||
Rectangle topPipe, bottomPipe;
|
||||
int distance = 105;
|
||||
boolean isPassedOn = false;
|
||||
|
||||
// Objekt Initialisierung
|
||||
public GameObject(int x, int y, int width, int height) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
topPipe = new Rectangle(x, y, width, height);
|
||||
bottomPipe = new Rectangle(x, height + distance, width, height);
|
||||
}
|
||||
|
||||
// Auf Anfangs Position setzen
|
||||
public void resetToNewPosition(int newX) {
|
||||
topPipe.x = newX;
|
||||
bottomPipe.x = newX;
|
||||
x = newX;
|
||||
topPipe.y = -(new Random().nextInt(140) + 100);
|
||||
bottomPipe.y = topPipe.y + height + distance;
|
||||
isPassedOn = false;
|
||||
}
|
||||
|
||||
// Prüfung ob Rectangle true oder false ist
|
||||
public boolean intersect(Rectangle rectangle) {
|
||||
return rectangle.intersects(topPipe) || rectangle.intersects(bottomPipe);
|
||||
}
|
||||
|
||||
// Röhren Counter → Check, wenn Röhre durchflogen ist
|
||||
public boolean passedOn(Rectangle rectangle) {
|
||||
return rectangle.x > x + width && !isPassedOn;
|
||||
}
|
||||
|
||||
// Bei Bewegung der X Koordinate werden Röhren generiert
|
||||
public void moveX(int dx) {
|
||||
x -= dx;
|
||||
topPipe.x -= dx;
|
||||
bottomPipe.x -= dx;
|
||||
}
|
||||
}
|
@ -7,28 +7,30 @@ import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.scene.text.TextAlignment;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
|
||||
public class HappyBirdMain extends Application {
|
||||
/* Formatierungsklasse */
|
||||
private final FormatingClass formatingClass = new FormatingClass();
|
||||
|
||||
/* Testen des Endscreens */
|
||||
private final Button endscreenTest = new Button("Endscreentest");
|
||||
|
||||
/*Datenbank einlesen*/
|
||||
MariaDB datenbank = new MariaDB();
|
||||
/* Datenbank einlesen */
|
||||
private final MariaDB datenbank = new MariaDB();
|
||||
|
||||
/*Panes erstellen und zuweisen*/
|
||||
/* Panes erstellen und zuweisen */
|
||||
private final Pane pane = new Pane();
|
||||
private final Pane pause = new Pane();
|
||||
private final Pane endScreen = new Pane();
|
||||
|
||||
/*Scene erstellen und zuweisen*/
|
||||
/* Scene erstellen und zuweisen */
|
||||
private final Scene scene = new Scene(pane, 800, 700);
|
||||
|
||||
/*Labels erstellen und zuweisen*/
|
||||
/* Labels erstellen und zuweisen */
|
||||
private final Label nameLabel = new Label("NAME");
|
||||
private final Label acronymLabel = new Label("KÜRZEL");
|
||||
private final Label headline = new Label("HAPPY BIRD");
|
||||
@ -38,7 +40,6 @@ public class HappyBirdMain extends Application {
|
||||
private final Label pauseMenuLabel = new Label("PAUSE");
|
||||
private final Label soundLabelPause = new Label("SOUND");
|
||||
private final Label highscoreMenuLabel = new Label();
|
||||
|
||||
private final Label currentScoreEndscreenLabel = new Label("YOUR SCORE: ");
|
||||
private final Label endScreenHeadline = new Label("GAME OVER");
|
||||
|
||||
@ -49,7 +50,6 @@ public class HappyBirdMain extends Application {
|
||||
/*Buttons erstellen und zuweisen*/
|
||||
private final Button startButton = new Button("START");
|
||||
private final Button highscoresButton = new Button("HIGHSCORES");
|
||||
|
||||
private final Button settingsButton = new Button("EINSTELLUNGEN");
|
||||
private final Button startGameButton = new Button("SPIEL STARTEN");
|
||||
private final Button menuButton = new Button("ZURÜCK");
|
||||
@ -60,7 +60,6 @@ public class HappyBirdMain extends Application {
|
||||
private final Button backButtonPause = new Button("ZURÜCK");
|
||||
private final Button background1 = new Button();
|
||||
private final Button background2 = new Button();
|
||||
|
||||
private final Button backMenuButton = new Button();
|
||||
private final Button restartGameButton = new Button();
|
||||
private final Button personalHighscoresButton = new Button ("YOUR SCORES");
|
||||
@ -95,8 +94,6 @@ public class HappyBirdMain extends Application {
|
||||
//gameRunning: das Spiel läuft/ GameScreen ist aufgerufen
|
||||
private boolean gameRunning;
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
@ -106,7 +103,6 @@ public class HappyBirdMain extends Application {
|
||||
|
||||
stage.setTitle("Happy Bird");
|
||||
stage.setScene(scene);
|
||||
|
||||
generateMenueScene();
|
||||
|
||||
/*ClickEvents:*/
|
||||
@ -131,25 +127,19 @@ public class HappyBirdMain extends Application {
|
||||
dataQuery();
|
||||
menuScreenRunning = true;
|
||||
|
||||
/*Bild für Hintergrund erstellen:*/
|
||||
Image image = new Image("file:src/main/resources/com/example/happy_bird/pics/Background0.png");
|
||||
/*Source als String*/
|
||||
String img = "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
|
||||
);
|
||||
/*Bild zu Hintergrund */
|
||||
BackgroundImage backgroundImage = formatingClass.backgroundFormating(img);
|
||||
|
||||
/*Hintergrund zu Pane hinzufügen:*/
|
||||
Background background = new Background(backgroundImage);
|
||||
pane.setBackground(background);
|
||||
|
||||
/*Labels formatieren:*/
|
||||
labelsFormating(labels, pane);
|
||||
headlineFormating(headlineLabels, pane);
|
||||
formatingClass.labelsFormating(labels, pane);
|
||||
formatingClass.headlineFormating(headlineLabels, pane);
|
||||
|
||||
/*Überschrift umbenennen, falls aus anderem Screen*/
|
||||
headline.setText("HAPPY BIRD");
|
||||
@ -171,7 +161,7 @@ public class HappyBirdMain extends Application {
|
||||
soundLabel.setLayoutY(225);
|
||||
|
||||
/*Buttons formatieren:*/
|
||||
buttonsFormating(buttons, pane);
|
||||
formatingClass.buttonsFormating(buttons, pane);
|
||||
|
||||
/*alle Buttons an ihre Stelle:*/
|
||||
int yPositionButtons = 225;
|
||||
@ -197,14 +187,14 @@ public class HappyBirdMain extends Application {
|
||||
settingsButtonPause.setVisible(false);
|
||||
|
||||
/*Buttons für Hintergründe*/
|
||||
backgroundButtonsFormating();
|
||||
formatingClass.backgroundButtonsFormating(backgroundButtons, pane);
|
||||
|
||||
/*Background-Buttons unsichtbar*/
|
||||
background1.setVisible(false);
|
||||
background2.setVisible(false);
|
||||
|
||||
/*Textfelder formatieren:*/
|
||||
textfieldsFormating(inputFields, pane);
|
||||
formatingClass.textfieldsFormating(inputFields, pane);
|
||||
|
||||
/*Textfelder an ihre Position:*/
|
||||
int yPositionInputFields = 290;
|
||||
@ -215,7 +205,7 @@ public class HappyBirdMain extends Application {
|
||||
}
|
||||
|
||||
/*SoundSlicer anpassen:*/
|
||||
soundSliderFormating(soundSlider, pane);
|
||||
formatingClass.soundSliderFormating(soundSlider, pane);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -282,194 +272,6 @@ public class HappyBirdMain extends Application {
|
||||
lowerPipeView.setLayoutY(430);
|
||||
}
|
||||
|
||||
/***
|
||||
* Formatiert alle Buttons und fügt sie der Pane hinzu
|
||||
* @param buttons ButtonArray mit allen Arrays
|
||||
* @param pane Pane, auf der die Buttons angezeigt werden
|
||||
*/
|
||||
public void buttonsFormating(Button[] buttons, Pane pane) {
|
||||
for (Button button : buttons) {
|
||||
button.setPrefSize(200, 50);
|
||||
|
||||
button.setStyle("-fx-background-color: #e86000; " +
|
||||
"-fx-text-fill: #FFFFFF; " +
|
||||
"-fx-font-size: 20px; " +
|
||||
"-fx-border-width: 5px;" +
|
||||
"-fx-border-color: #FFFFFF;" +
|
||||
"-fx-font-weight: bold;" +
|
||||
"-fx-border-radius: 15px;" +
|
||||
"-fx-background-radius: 20px;");
|
||||
|
||||
pane.getChildren().add(button);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
* @param labels LabelArray mit allen Labels
|
||||
* @param pane Pane, auf der die Labels angezeigt werden
|
||||
*/
|
||||
public void labelsFormating(Label[] labels, Pane pane) {
|
||||
for (Label label : labels) {
|
||||
label.setPrefSize(250, 50);
|
||||
|
||||
label.setStyle("-fx-background-color: #DED894; " +
|
||||
"-fx-text-fill: #000000; " +
|
||||
"-fx-font-size: 20px; " +
|
||||
"-fx-border-width: 5px;" +
|
||||
"-fx-border-color: #543847;" +
|
||||
"-fx-font-weight: bold;" +
|
||||
"-fx-alignment: center;" +
|
||||
"-fx-background-radius: 20px;" +
|
||||
"-fx-border-radius: 15px;");
|
||||
|
||||
pane.getChildren().add(label);
|
||||
|
||||
label.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* Formatiert alle Überschriften-Labels und fügt sie der Pane hinzu
|
||||
* @param labels LabelArray mit Überschriften-Labels
|
||||
* @param pane Pane, auf der die Labels angezeigt werden
|
||||
*/
|
||||
public void headlineFormating(Label[] labels, Pane pane) {
|
||||
for (Label label : labels) {
|
||||
label.setPrefSize(300, 75);
|
||||
label.setTextAlignment(TextAlignment.CENTER);
|
||||
|
||||
label.setStyle("-fx-background-color: #DED894; " +
|
||||
"-fx-text-fill: #000000; " +
|
||||
"-fx-font-size: 35px; " +
|
||||
"-fx-border-width: 5px;" +
|
||||
"-fx-border-color: #543847;" +
|
||||
"-fx-font-weight: bold;" +
|
||||
"-fx-alignment: center;" +
|
||||
"-fx-background-radius: 20px;" +
|
||||
"-fx-border-radius: 15px;");
|
||||
|
||||
pane.getChildren().add(label);
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* Formatiert alle Textfelder und fügt sie der Pane hinzu
|
||||
* @param textfields TextFieldArray mit allen Textfeldern
|
||||
* @param pane Pane, auf der die Textfelder angezeigt werden
|
||||
*/
|
||||
public void textfieldsFormating(TextField[] textfields, Pane pane) {
|
||||
for (TextField field : textfields) {
|
||||
field.setPrefSize(250, 50);
|
||||
field.setStyle("-fx-font-size: 20px;" +
|
||||
"-fx-font-weight: bold;");
|
||||
|
||||
pane.getChildren().add(field);
|
||||
|
||||
field.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* Formatiert den soundSlider und fügt ihn der Pane hinzu
|
||||
* @param slider SoundSlider
|
||||
* @param pane Pane, auf der der Slider angezeigt wird
|
||||
*/
|
||||
public void soundSliderFormating(Slider slider, Pane pane) {
|
||||
slider.setPrefSize(200, 5);
|
||||
slider.setLayoutX(300);
|
||||
slider.setLayoutY(295);
|
||||
|
||||
pane.getChildren().add(slider);
|
||||
|
||||
slider.setVisible(false);
|
||||
}
|
||||
|
||||
/***
|
||||
* Formatiert den PauseScreen
|
||||
*/
|
||||
public void pauseScreenFormating() {
|
||||
/*pause-Pane formatieren*/
|
||||
pause.setPrefSize(400, 400);
|
||||
pause.setLayoutX(200);
|
||||
pause.setLayoutY(150);
|
||||
pause.setStyle("-fx-background-color: #DED894; " +
|
||||
"-fx-border-width: 5px;" +
|
||||
"-fx-border-color: #543847;" +
|
||||
"-fx-border-radius: 15px;" +
|
||||
"-fx-background-radius: 20px;");
|
||||
|
||||
/*pauseMenuLabel formatieren*/
|
||||
pauseMenuLabel.setPrefSize(300,50);
|
||||
pauseMenuLabel.setLayoutX(50);
|
||||
pauseMenuLabel.setLayoutY(10);
|
||||
pauseMenuLabel.setStyle("-fx-background-color: #DED894; " +
|
||||
"-fx-text-fill: #000000; " +
|
||||
"-fx-font-size: 35px; " +
|
||||
"-fx-font-weight: bold;" +
|
||||
"-fx-alignment: center;");
|
||||
|
||||
/*soundLabelPause formatieren*/
|
||||
soundLabelPause.setPrefSize(100, 50);
|
||||
soundLabelPause.setLayoutX(150);
|
||||
soundLabelPause.setLayoutY(100);
|
||||
soundLabelPause.setStyle("-fx-background-color: #DED894; " +
|
||||
"-fx-text-fill: #000000; " +
|
||||
"-fx-font-size: 20px; " +
|
||||
"-fx-font-weight: bold;" +
|
||||
"-fx-alignment: center;");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/***
|
||||
* Hauptmenü wird ausgeblendet, Nameneingabe folgt
|
||||
*/
|
||||
@ -507,7 +309,6 @@ public class HappyBirdMain extends Application {
|
||||
startGameButton.setOnAction(event -> startGameButtonClick());
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* Hauptmenü wird ausgeblendet, Einstellungen folgen
|
||||
*/
|
||||
@ -526,40 +327,21 @@ public class HappyBirdMain extends Application {
|
||||
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
|
||||
);
|
||||
/*Source als String*/
|
||||
String img = "file:src/main/resources/com/example/happy_bird/pics/Background0.png";
|
||||
|
||||
/*Hintergrund zu Pane hinzufügen:*/
|
||||
Background background = new Background(backgroundImage);
|
||||
Background background = new Background(formatingClass.backgroundFormating(img));
|
||||
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
|
||||
);
|
||||
/*Source als String*/
|
||||
String img = "file:src/main/resources/com/example/happy_bird/pics/Background1.png";
|
||||
|
||||
/*Hintergrund zu Pane hinzufügen:*/
|
||||
Background background = new Background(backgroundImage);
|
||||
Background background = new Background(formatingClass.backgroundFormating(img));
|
||||
pane.setBackground(background);
|
||||
});
|
||||
}
|
||||
@ -731,7 +513,7 @@ public class HappyBirdMain extends Application {
|
||||
* Ruft das Pause-Menü im Spiel auf oder blendet es wieder aus
|
||||
*/
|
||||
public void pauseButtonClick(Boolean gameRuns) {
|
||||
pauseScreenFormating();
|
||||
formatingClass.pauseScreenFormating(pause, pauseMenuLabel, soundLabelPause);
|
||||
|
||||
/*PauseScreen aufrufen, wenn das Spiel läuft, sonst wieder ausblenden*/
|
||||
if(!gameRuns) {
|
||||
@ -842,7 +624,7 @@ public class HappyBirdMain extends Application {
|
||||
try (ResultSet rs = datenbank.st.executeQuery(sql)) {
|
||||
while (rs.next())
|
||||
{
|
||||
bestFiveHighscores+= rs.getString(4) + "\t" + rs.getString(3)+"\n";
|
||||
bestFiveHighscores += rs.getString(4) + "\t" + rs.getString(3)+"\n";
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -865,7 +647,7 @@ public class HappyBirdMain extends Application {
|
||||
try (ResultSet rs = datenbank.st.executeQuery(sql)) {
|
||||
while (rs.next())
|
||||
{
|
||||
bestFiveHighscores+= rs.getString(4) + "\t" + rs.getString(3)+"\n";
|
||||
bestFiveHighscores += rs.getString(4) + "\t" + rs.getString(3)+"\n";
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -948,38 +730,7 @@ public class HappyBirdMain extends Application {
|
||||
return true;
|
||||
}
|
||||
|
||||
/***
|
||||
* formatiert den End-Screen
|
||||
*/
|
||||
public void endScreenFormating() {
|
||||
/*Endscreen-Pane formatieren*/
|
||||
endScreen.setPrefSize(400, 500);
|
||||
pause.setLayoutX(200);
|
||||
pause.setLayoutY(100);
|
||||
pause.setStyle("-fx-background-color: #DED894; " +
|
||||
"-fx-border-width: 5px;" +
|
||||
"-fx-border-color: #543847;" +
|
||||
"-fx-border-radius: 15px;" +
|
||||
"-fx-background-radius: 20px;");
|
||||
|
||||
endScreenHeadline.setPrefSize(300,50);
|
||||
endScreenHeadline.setLayoutX(50);
|
||||
endScreenHeadline.setLayoutY(10);
|
||||
endScreenHeadline.setStyle("-fx-background-color: #DED894; " +
|
||||
"-fx-text-fill: #000000; " +
|
||||
"-fx-font-size: 35px; " +
|
||||
"-fx-font-weight: bold;" +
|
||||
"-fx-alignment: center;");
|
||||
|
||||
currentScoreEndscreenLabel.setPrefSize(250,50);
|
||||
currentScoreEndscreenLabel.setLayoutX(75);
|
||||
currentScoreEndscreenLabel.setLayoutY(100);
|
||||
currentScoreEndscreenLabel.setStyle("-fx-background-color: #DED894; " +
|
||||
"-fx-text-fill: #000000; " +
|
||||
"-fx-font-size: 35px; " +
|
||||
"-fx-font-weight: bold;" +
|
||||
"-fx-alignment: center;");
|
||||
}
|
||||
|
||||
/***
|
||||
* public void generateEndScreen() generiert den Endscreen - sobald das Spiel beendet ist
|
||||
@ -989,7 +740,7 @@ public class HappyBirdMain extends Application {
|
||||
* sich seine persänlichen Highscores anzeigen zu lassen
|
||||
*/
|
||||
public void generateEndScreen() {
|
||||
endScreenFormating();
|
||||
formatingClass.endScreenFormating(endScreen, pause, endScreenHeadline, currentScoreEndscreenLabel);
|
||||
/*Name und Highscores ausblenden, Pause-Button ausblenden*/
|
||||
nameLabel.setVisible(false);
|
||||
highscoreLabel.setVisible(false);
|
||||
|
@ -0,0 +1,7 @@
|
||||
package com.example.happy_bird;
|
||||
|
||||
public enum Movement {
|
||||
Up,
|
||||
Down,
|
||||
None
|
||||
}
|
Loading…
Reference in New Issue
Block a user