Namen in die Kommentare
This commit is contained in:
parent
88b0ba5d05
commit
d707be3e4c
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.
@ -1,21 +0,0 @@
|
||||
package com.example.happy_bird;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.ImageObserver;
|
||||
|
||||
public class Bird extends SpielObjekt {
|
||||
|
||||
public Bird(int xWert, int yWert) {
|
||||
super(xWert, yWert);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(Graphics2D g, ImageObserver obs) {
|
||||
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ public class FormatingClass {
|
||||
*/
|
||||
public FormatingClass() { }
|
||||
|
||||
/***
|
||||
/*** Alteköster
|
||||
* 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
|
||||
@ -36,7 +36,7 @@ public class FormatingClass {
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
/*** Alteköster
|
||||
* 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
|
||||
@ -61,7 +61,7 @@ public class FormatingClass {
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
/*** Alteköster
|
||||
* 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
|
||||
@ -85,7 +85,7 @@ public class FormatingClass {
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
/*** Alteköster
|
||||
* 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
|
||||
@ -102,7 +102,7 @@ public class FormatingClass {
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
/*** Alteköster
|
||||
* Formatiert den soundSlider und fügt ihn der Pane hinzu
|
||||
* @param slider SoundSlider
|
||||
* @param pane Pane, auf der der Slider angezeigt wird
|
||||
@ -117,7 +117,7 @@ public class FormatingClass {
|
||||
slider.setVisible(false);
|
||||
}
|
||||
|
||||
/***
|
||||
/*** Alteköster
|
||||
* Formatiert den PauseScreen
|
||||
*/
|
||||
public void pauseScreenFormating(Pane pause, Label pauseMenuLabel, Label soundLabelPause) {
|
||||
@ -152,7 +152,7 @@ public class FormatingClass {
|
||||
"-fx-alignment: center;");
|
||||
}
|
||||
|
||||
/***
|
||||
/*** Pape
|
||||
* formatiert den End-Screen
|
||||
*/
|
||||
public void endScreenFormating(Pane endScreen, Label endScreenHeadline, Label currentScoreEndscreenLabel) {
|
||||
@ -185,7 +185,7 @@ public class FormatingClass {
|
||||
"-fx-alignment: center;");
|
||||
}
|
||||
|
||||
/***
|
||||
/*** Alteköster
|
||||
* Erstellt ein neues BackgroundImage aus einer Source für ein .png
|
||||
* @param img Source eines .png
|
||||
* @return backgroundImage
|
||||
@ -206,7 +206,7 @@ public class FormatingClass {
|
||||
return backgroundImage;
|
||||
}
|
||||
|
||||
/***
|
||||
/*** Alteköster
|
||||
* 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
|
||||
@ -236,9 +236,4 @@ public class FormatingClass {
|
||||
pane.getChildren().add(backgroundButtons[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void menueScreenFormating(Label[] labels, Button[] buttons) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,54 +0,0 @@
|
||||
package com.example.happy_bird;
|
||||
|
||||
|
||||
import javafx.scene.Node;
|
||||
|
||||
public abstract class GameObject extends Node {
|
||||
protected int xKoord;
|
||||
protected int yKoord;
|
||||
protected int width;
|
||||
protected int height;
|
||||
protected boolean isPassedOn = false;
|
||||
|
||||
/***
|
||||
* Konstruktor GameObject
|
||||
* Variablen werden zugewiesen
|
||||
* @param x x-Position
|
||||
* @param y y-Position
|
||||
* @param width Breite
|
||||
* @param height Höhe
|
||||
*/
|
||||
public GameObject(int x, int y, int width, int height) {
|
||||
this.xKoord = x;
|
||||
this.yKoord = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
|
||||
public abstract void setImage();
|
||||
|
||||
/***
|
||||
* Setzt ein Object auf eine neue Position
|
||||
* param newX neue x-Position
|
||||
*/
|
||||
public abstract void resetToNewPosition(int newX);
|
||||
|
||||
/*
|
||||
// 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 > xKoord + width && !isPassedOn;
|
||||
}
|
||||
|
||||
// Bei Bewegung der X Koordinate werden Röhren generiert
|
||||
public void moveX(int dx) {
|
||||
xKoord -= dx;
|
||||
topPipe.x -= dx;
|
||||
bottomPipe.x -= dx;
|
||||
}*/
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package com.example.happy_bird;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.Slider;
|
||||
import javafx.scene.image.*;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.scene.text.TextAlignment;
|
||||
import javafx.stage.Stage;
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
|
||||
public class GameScreen extends HappyBirdMain
|
||||
{
|
||||
|
||||
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package com.example.happy_bird;
|
||||
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TextField;
|
||||
|
||||
public class HappyBird extends HappyBirdMain {
|
||||
|
||||
}
|
@ -16,7 +16,6 @@ import javafx.stage.Stage;
|
||||
import javafx.scene.shape.*;
|
||||
import javafx.util.Duration;
|
||||
|
||||
//import java.awt.*;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
@ -30,6 +29,7 @@ public class HappyBirdMain extends Application {
|
||||
private int playerhighscore;
|
||||
private boolean openEndScreen = false;
|
||||
private boolean endScreenOpened = false;
|
||||
|
||||
/* Formatierungsklasse */
|
||||
private final FormatingClass formatingClass = new FormatingClass();
|
||||
|
||||
@ -114,12 +114,7 @@ public class HappyBirdMain extends Application {
|
||||
//gameRunning: das Spiel läuft/ GameScreen ist aufgerufen
|
||||
private boolean gameRunning;
|
||||
|
||||
|
||||
/*TranslateTransitions für obere und untere Pipes*/
|
||||
|
||||
//Birdview
|
||||
//ImageView birdView = new ImageView(bird);
|
||||
|
||||
private TranslateTransition top;
|
||||
private TranslateTransition bottom;
|
||||
|
||||
@ -144,6 +139,7 @@ public class HappyBirdMain extends Application {
|
||||
launch(args);
|
||||
}
|
||||
|
||||
/** alle */
|
||||
@Override
|
||||
public void start(Stage stage) {
|
||||
stage.setTitle("Happy Bird");
|
||||
@ -167,7 +163,7 @@ public class HappyBirdMain extends Application {
|
||||
stage.show();
|
||||
}
|
||||
|
||||
/***
|
||||
/*** Alteköster
|
||||
* Erstellt den Bird als Rectangle mit einem Bild.
|
||||
* @return happyBird ein Rectangle
|
||||
*/
|
||||
@ -188,7 +184,7 @@ public class HappyBirdMain extends Application {
|
||||
return happyBird;
|
||||
}
|
||||
|
||||
/***
|
||||
/*** Alteköster
|
||||
* Erstellt zwei Pipes als Rectangle und fügt ihnen eine Animation über eine Transition hinzu
|
||||
* @return pipes zwei Rectangles
|
||||
*/
|
||||
@ -252,7 +248,7 @@ public class HappyBirdMain extends Application {
|
||||
return pipes;
|
||||
}
|
||||
|
||||
/***
|
||||
/*** alle
|
||||
* Generiert den GameScreen durch Ausblenden und
|
||||
* Sichtbarmachen der richtigen Buttons, Labels, ...
|
||||
*/
|
||||
@ -342,7 +338,7 @@ public class HappyBirdMain extends Application {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
/*** alle
|
||||
* Generiert den GameScreen durch Ausblenden und
|
||||
* Sichtbarmachen der richtigen Buttons, Labels, ...
|
||||
*/
|
||||
@ -388,28 +384,7 @@ public class HappyBirdMain extends Application {
|
||||
startGameButton.setVisible(false);
|
||||
menuButton.setVisible(false);
|
||||
|
||||
|
||||
/*Vogel hinzufügen, bisher nur als Bild
|
||||
ImageView birdView = new ImageView(bird);
|
||||
|
||||
/*Vogel hinzufügen, bisher nur als Bild*/
|
||||
/*
|
||||
pane.getChildren().add(birdView);
|
||||
birdView.setLayoutY(325);
|
||||
birdView.setLayoutX(50);*/
|
||||
|
||||
/*Pipes oben, unten hinzufügen, bisher nur als Bild
|
||||
ImageView upperPipeView = new ImageView(upperPipe);
|
||||
pane.getChildren().add(upperPipeView);
|
||||
upperPipeView.setLayoutX(400);
|
||||
upperPipeView.setLayoutY(0);
|
||||
|
||||
ImageView lowerPipeView = new ImageView(lowerPipe);
|
||||
pane.getChildren().add(lowerPipeView);
|
||||
lowerPipeView.setLayoutX(400);
|
||||
lowerPipeView.setLayoutY(430);*/
|
||||
|
||||
|
||||
/** Alteköster */
|
||||
/*Timeline: alle 2 Sekunden spawnt eine neue Pipe am rechten Rand*/
|
||||
timeline = new Timeline(new KeyFrame(Duration.seconds(1.5), e ->{
|
||||
/*Pipes erstellen*/
|
||||
@ -419,20 +394,11 @@ public class HappyBirdMain extends Application {
|
||||
for(Rectangle pipe : pipesTopBottom) {
|
||||
pane.getChildren().add(pipe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*Transitions abspielen*/
|
||||
top.play();
|
||||
bottom.play();
|
||||
}));
|
||||
|
||||
/*timelineBird = new Timeline(new KeyFrame(Duration.seconds(50), e -> {
|
||||
Rectangle happyBird = createBird();
|
||||
pane.getChildren().add(happyBird);
|
||||
birdTransition.play();
|
||||
}));*/
|
||||
|
||||
happyBird = createBird();
|
||||
pane.getChildren().add(happyBird);
|
||||
|
||||
@ -441,6 +407,7 @@ public class HappyBirdMain extends Application {
|
||||
|
||||
System.out.println("tl: "+timeline.getStatus());
|
||||
|
||||
/** Alteköster, Bickmann, Pape*/
|
||||
collisionChecker = new AnimationTimer() {
|
||||
@Override
|
||||
public void handle(long timestamp) {
|
||||
@ -465,7 +432,7 @@ public class HappyBirdMain extends Application {
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
/*** Bickmann, Alteköster
|
||||
* Überprüft, ob eine Pipe mit dem Bird kollidiert
|
||||
* @param happyBird Rechteck mit dem Bird
|
||||
* @param pipe Rechteck mit einer Pipe
|
||||
@ -509,7 +476,7 @@ public class HappyBirdMain extends Application {
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
/*** alle
|
||||
* Hauptmenü wird ausgeblendet, Nameneingabe folgt
|
||||
*/
|
||||
public void startButtonClick() {
|
||||
@ -556,7 +523,7 @@ public class HappyBirdMain extends Application {
|
||||
startGameButton.setOnAction(event -> startGameButtonClick());
|
||||
}
|
||||
|
||||
/***
|
||||
/*** alle
|
||||
* Hauptmenü wird ausgeblendet, Einstellungen folgen
|
||||
*/
|
||||
public void settingsButtonClick() {
|
||||
@ -593,7 +560,7 @@ public class HappyBirdMain extends Application {
|
||||
});
|
||||
}
|
||||
|
||||
/***
|
||||
/*** alle
|
||||
* Hauptmenü wird ausgeblendet, Einstellungen folgen
|
||||
*/
|
||||
public void settingsButtonPauseClick() {
|
||||
@ -635,7 +602,7 @@ public class HappyBirdMain extends Application {
|
||||
});
|
||||
}
|
||||
|
||||
/***
|
||||
/*** Pape
|
||||
* Hauptmenü wird ausgeblendet, Highscores folgen
|
||||
*/
|
||||
public void highscoresButtonClick() {
|
||||
@ -659,7 +626,7 @@ public class HappyBirdMain extends Application {
|
||||
menuButton.setVisible(true);
|
||||
}
|
||||
|
||||
/***
|
||||
/*** alle
|
||||
* Nameneingabe, Einstellungen und Highscores werden ausgeblendet
|
||||
* Erneutes Anzeigen des Hauptmenüs
|
||||
*/
|
||||
@ -681,9 +648,6 @@ public class HappyBirdMain extends Application {
|
||||
/*soundSlider ausblenden*/
|
||||
soundSlider.setVisible(false);
|
||||
|
||||
/*soundLabel ausblenden*/
|
||||
//soundLabel.setVisible(false);
|
||||
|
||||
/*Textfelder ausblenden*/
|
||||
for(TextField feld : inputFields) {
|
||||
feld.setVisible(false);
|
||||
@ -695,18 +659,7 @@ public class HappyBirdMain extends Application {
|
||||
}
|
||||
}
|
||||
|
||||
public void keyPressed(KeyEvent e) {
|
||||
scene.setOnKeyPressed(event -> {
|
||||
if (event.getCode() == KeyCode.W) {
|
||||
moveBirdUp();
|
||||
}
|
||||
|
||||
if (event.getCode() == KeyCode.S) {
|
||||
moveBirdDown();
|
||||
}
|
||||
});
|
||||
};
|
||||
/***
|
||||
/*** Pape
|
||||
* Startet Spiel nach Namenseingabe
|
||||
*/
|
||||
|
||||
@ -771,7 +724,7 @@ public class HappyBirdMain extends Application {
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
/*** alle
|
||||
* Zurück zum Spiel aus dem PauseScreen heraus
|
||||
*/
|
||||
public void continueButtonClick() {
|
||||
@ -788,7 +741,7 @@ public class HappyBirdMain extends Application {
|
||||
/*Pausieren der Transitions/ Pipes*/
|
||||
for(Transition transition : transitions) {
|
||||
transition.play();
|
||||
System.out.println(transition.toString());
|
||||
//System.out.println(transition.toString());
|
||||
}
|
||||
|
||||
/*Pausieren der Timeline, sodass keine neuen Pipes spawnen*/
|
||||
@ -798,7 +751,7 @@ public class HappyBirdMain extends Application {
|
||||
gameRunning = false;
|
||||
}
|
||||
|
||||
/***
|
||||
/*** alle
|
||||
* alles vom pane entfernen, da als nächstes zum Hauptmenü
|
||||
*/
|
||||
private void menuButtonPauseClick() {
|
||||
@ -814,7 +767,7 @@ public class HappyBirdMain extends Application {
|
||||
gameRunning = false;
|
||||
}
|
||||
|
||||
/***
|
||||
/*** Alteköster
|
||||
* Ruft das Pause-Menü im Spiel auf oder blendet es wieder aus
|
||||
*/
|
||||
public void pauseButtonClick(Boolean gameRuns) {
|
||||
@ -894,7 +847,7 @@ public class HappyBirdMain extends Application {
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
/*** Pape
|
||||
* Erste Datenabfrage als Test - wird später gelöscht
|
||||
*/
|
||||
public void dataQuery() {
|
||||
@ -912,7 +865,7 @@ public class HappyBirdMain extends Application {
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
/*** Pape
|
||||
* getPlayerHighscore() berechnet den höchsten erreichten Wert des aktuellen Spielers
|
||||
* (nicht den gesamt höchsten Highscore)
|
||||
*
|
||||
@ -936,7 +889,7 @@ public class HappyBirdMain extends Application {
|
||||
return highscore;
|
||||
}
|
||||
|
||||
/***
|
||||
/*** Pape
|
||||
* calculateHighscores() gibt die Highscores aus ( die 5 höchsten Werte, die bis jetzt gespielt wurden )
|
||||
*
|
||||
* @return die 5 höchsten erreichten Scores
|
||||
@ -958,7 +911,7 @@ public class HappyBirdMain extends Application {
|
||||
return bestFiveHighscores;
|
||||
}
|
||||
|
||||
/***
|
||||
/*** Pape
|
||||
* calculatePersonalHighscores() berechnet die 5 höchsten erreichten Scores des aktuellen Spielers
|
||||
*
|
||||
* @return die 5 höchsten erreichten Scores des aktuellen Spielers
|
||||
@ -982,7 +935,7 @@ public class HappyBirdMain extends Application {
|
||||
return bestFiveHighscores;
|
||||
}
|
||||
|
||||
/***
|
||||
/*** Pape
|
||||
* Fügt die erreichte Punktzahl des Spielers für den Spieler mit seinem Namen und Kürzel in die Datenbank ein
|
||||
*
|
||||
*/
|
||||
@ -1005,7 +958,7 @@ public class HappyBirdMain extends Application {
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
/*** Pape
|
||||
* Überprüft, ob der eingegebene Name den Vorgaben entspricht
|
||||
* (Erlaubte Zeichen: Groß- und Kleinbuchstaben, Umlaute und Leerzeichen
|
||||
*
|
||||
@ -1037,7 +990,7 @@ public class HappyBirdMain extends Application {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/***
|
||||
/*** Pape
|
||||
* Überprüft, ob das eingegebene Akronym den Vorgaben entspricht
|
||||
* ( >= 3 Zeichen, <= 12 Zeichen, Groß- und Kleinbuchstaben, Zahlen 0-9 -- keine Sonderzeichen)
|
||||
* @return 0, wenn ja,
|
||||
@ -1061,7 +1014,7 @@ public class HappyBirdMain extends Application {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/***
|
||||
/*** Pape, Bickmann, Ekmen
|
||||
* public void generateEndScreen() generiert den Endscreen - sobald das Spiel beendet ist
|
||||
* (man verloren hat). Es werden die Punkte des Spielers angezeigt, und es bestehen die Möglichkeiten,
|
||||
* das Spiel neu zu starten
|
||||
@ -1076,9 +1029,6 @@ public class HappyBirdMain extends Application {
|
||||
pauseButton.setVisible(false);
|
||||
currentScoreLabel.setVisible(false);
|
||||
|
||||
/**/
|
||||
|
||||
|
||||
endScreen.getChildren().add(endScreenHeadline);
|
||||
endScreenHeadline.setVisible(true);
|
||||
|
||||
@ -1103,7 +1053,7 @@ public class HappyBirdMain extends Application {
|
||||
restartGameButton.setOnAction(event -> restartGameButtonClick());
|
||||
}
|
||||
|
||||
/***
|
||||
/*** Pape, Bickmann, Ekmen
|
||||
* die Funktion restartGameButtonClick() startet das Spiel neu
|
||||
*/
|
||||
private void restartGameButtonClick() {
|
||||
@ -1121,7 +1071,7 @@ public class HappyBirdMain extends Application {
|
||||
startGameButtonClick();
|
||||
}
|
||||
|
||||
/***
|
||||
/*** Pape
|
||||
* personalHighscoresButtonClick() zeigt bei Drücken des Highscore-Buttons im Endscreen
|
||||
* die persänlichen besten 5 Scores an
|
||||
*/
|
||||
@ -1166,7 +1116,7 @@ public class HappyBirdMain extends Application {
|
||||
});
|
||||
}
|
||||
|
||||
/***
|
||||
/*** Pape, Bickmann, Ekmen
|
||||
* backMenuButtonClick() ruft aus dem Endscreen das Hauptmenü auf
|
||||
*/
|
||||
private void backMenuButtonClick() {
|
||||
@ -1184,7 +1134,9 @@ public class HappyBirdMain extends Application {
|
||||
generateMenueScreen();
|
||||
}
|
||||
|
||||
// Aufstieg dauert immer länger
|
||||
/*** Bickmann
|
||||
* Aufstieg dauert immer länger
|
||||
*/
|
||||
private void moveBirdUp() {
|
||||
velocity = (float) -4.5;
|
||||
var pos = velocity += gravity;
|
||||
@ -1192,7 +1144,9 @@ public class HappyBirdMain extends Application {
|
||||
happyBird.setLayoutY(birdPositionMovedBy);
|
||||
}
|
||||
|
||||
// Fall geht schneller
|
||||
/*** Bickmann
|
||||
* Fall geht schneller
|
||||
*/
|
||||
private void moveBirdDown() {
|
||||
var pos = velocity -= gravity;
|
||||
birdPositionMovedBy -= pos;
|
||||
|
@ -1,23 +0,0 @@
|
||||
package com.example.happy_bird;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class HelloApplication extends Application {
|
||||
@Override
|
||||
public void start(Stage stage) throws IOException {
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("hello-view.fxml"));
|
||||
Scene scene = new Scene(fxmlLoader.load(), 320, 240);
|
||||
stage.setTitle("Hello!");
|
||||
stage.setScene(scene);
|
||||
stage.show();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch();
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package com.example.happy_bird;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Label;
|
||||
|
||||
public class HelloController {
|
||||
@FXML
|
||||
private Label welcomeText;
|
||||
|
||||
@FXML
|
||||
protected void onHelloButtonClick() {
|
||||
welcomeText.setText("Welcome to JavaFX Application!");
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.example.happy_bird;
|
||||
|
||||
/** Pape */
|
||||
import java.sql.*;
|
||||
public class MariaDB
|
||||
{
|
||||
|
@ -1,7 +0,0 @@
|
||||
package com.example.happy_bird;
|
||||
|
||||
public enum Movement {
|
||||
Up,
|
||||
Down,
|
||||
None
|
||||
}
|
@ -1,104 +0,0 @@
|
||||
package com.example.happy_bird;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ImageObserver;
|
||||
|
||||
public class Pipe extends SpielObjekt {
|
||||
|
||||
private java.awt.Image lowerPipe;
|
||||
// private java.awt.Image lowerPipe = new java.awt.Image("file:src/main/resources/com/example/happy_bird/pics/PipeUnten.png", 86, 300, false, false);
|
||||
private int xWert = 0, yWert = 0;
|
||||
|
||||
public Pipe(int xWert, int yWert) {
|
||||
super(xWert, yWert);
|
||||
lowerPipe = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("com/example/happy_bird/"));
|
||||
//scale lowerPipe(initialWidth, initialHeight)
|
||||
}
|
||||
|
||||
public void scaleTopPipe(int width, int height) {
|
||||
lowerPipe = lowerPipe.getScaledInstance(width, height, Image.SCALE_SMOOTH);
|
||||
}
|
||||
|
||||
public Image getPipe() {
|
||||
return getPipe();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method um die Breite des BottomPipe-Objekts zu erhalten
|
||||
* @return int
|
||||
*/
|
||||
public int getWidth(int width) {
|
||||
return lowerPipe.getWidth(null);
|
||||
}
|
||||
/**
|
||||
* Methode um die Höhe des BottomPipe-Objekts zu erhalten
|
||||
* @return int
|
||||
*/
|
||||
public int getHeight(int height) {
|
||||
return lowerPipe.getHeight(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Methode zum Festlegen der x-Position des BottomPipe-Objekts
|
||||
* @param x
|
||||
*/
|
||||
public void setX(int x) {
|
||||
xWert = x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Methode zum Abrufen der x-Position des BottomPipe-Objekts
|
||||
* @return int
|
||||
*/
|
||||
public int getX() {
|
||||
return xWert;
|
||||
}
|
||||
|
||||
/**
|
||||
* Methode zum Festlegen der y-Position des BottomPipe-Objekts
|
||||
* @param y
|
||||
*/
|
||||
public void setY(int y) {
|
||||
yWert = y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Methode zum Abrufen der y-Position des BottomPipe-Objekts
|
||||
* @return int
|
||||
*/
|
||||
public int getY() {
|
||||
return yWert;
|
||||
}
|
||||
|
||||
/**
|
||||
* Methode zum Erfassen eines Rechtecks, das das Bild des BottomPipe umreißt
|
||||
* @return Rechteck, das die Position des BottomPipe auf dem Bildschirm umreißt
|
||||
*/
|
||||
public Rectangle getRectangle() {
|
||||
return (new Rectangle(xWert, yWert, lowerPipe.getWidth(null), lowerPipe.getHeight(null)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Methode zum Erfassen eines BufferedImage, das das Bildobjekt der TopPipe darstellt
|
||||
* @return TopPipe's BufferedImage-Objekt
|
||||
*/
|
||||
public BufferedImage getBI() {
|
||||
BufferedImage bi = new BufferedImage(lowerPipe.getWidth(null), lowerPipe.getHeight(null), BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics g = bi.getGraphics();
|
||||
g.drawImage(lowerPipe, 0, 0, null);
|
||||
g.dispose();
|
||||
return bi;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(Graphics2D g, ImageObserver obs) {
|
||||
|
||||
}
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
package com.example.happy_bird;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public class PipeTop {
|
||||
//global variables
|
||||
private Image topPipe;
|
||||
private int xLoc = 0, yLoc = 0;
|
||||
|
||||
public PipeTop(int initialWidth, int initialHeight) {
|
||||
topPipe = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("resources/tube_top.png"));
|
||||
scaleTopPipe(initialWidth, initialHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Methode zum Skalieren des topPipe-Sprites in die gewünschten Dimensionen
|
||||
* @param width Die gewünschte Breite der topPipe
|
||||
* @param height Die gewünschte Höhe der topPipe
|
||||
*/
|
||||
public void scaleTopPipe(int width, int height) {
|
||||
topPipe = topPipe.getScaledInstance(width, height, Image.SCALE_SMOOTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter-Methode für das TopPipe-Objekt.
|
||||
* @return-Image
|
||||
*/
|
||||
public Image getPipe() {
|
||||
return topPipe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Methode zum Abrufen der Breite des TopPipe-Objekts
|
||||
* @return int
|
||||
*/
|
||||
public int getWidth() {
|
||||
return topPipe.getWidth(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Methode, um die Höhe des TopPipe-Objekts zu erhalten
|
||||
* @return int
|
||||
*/
|
||||
public int getHeight() {
|
||||
return topPipe.getHeight(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Methode zum Festlegen der x-Position des TopPipe-Objekts
|
||||
* @param x
|
||||
*/
|
||||
public void setX(int x) {
|
||||
xLoc = x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Methode zum Abrufen der x-Position des TopPipe-Objekts
|
||||
* @return int
|
||||
*/
|
||||
public int getX() {
|
||||
return xLoc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Methode zum Festlegen der y-Position des TopPipe-Objekts
|
||||
* @param y
|
||||
*/
|
||||
public void setY(int y) {
|
||||
yLoc = y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Methode zum Abrufen der y-Position des TopPipe-Objekts
|
||||
* @return int
|
||||
*/
|
||||
public int getY() {
|
||||
return yLoc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Methode zum Erfassen eines Rechtecks, das das Bild der TopPipe umreißt
|
||||
* @return Rechteck, das die Position der TopPipe auf dem Bildschirm umreißt
|
||||
*/
|
||||
public Rectangle getRectangle() {
|
||||
return (new Rectangle(xLoc, yLoc, topPipe.getWidth(null), topPipe.getHeight(null)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Methode zum Erfassen eines BufferedImage, das das Bildobjekt der TopPipe darstellt
|
||||
* @return BufferedImage-Objekt von TopPipe
|
||||
*/
|
||||
public BufferedImage getBI() {
|
||||
BufferedImage bi = new BufferedImage(topPipe.getWidth(null), topPipe.getHeight(null), BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics g = bi.getGraphics();
|
||||
g.drawImage(topPipe, 0, 0, null);
|
||||
g.dispose();
|
||||
return bi;
|
||||
}
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
package com.example.happy_bird;
|
||||
|
||||
import javafx.animation.AnimationTimer;
|
||||
import javafx.animation.Transition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.paint.ImagePattern;
|
||||
import javafx.scene.shape.Rectangle;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.util.Duration;
|
||||
|
||||
public class Pipes extends Rectangle {
|
||||
private int y;
|
||||
private Rectangle topPipe;
|
||||
private Rectangle bottomPipe;
|
||||
private int distanceBeweenPipes = 250;
|
||||
private boolean isPassedOn = false;
|
||||
/***
|
||||
* Konstruktor GameObject
|
||||
* Variablen werden zugewiesen
|
||||
* param x x-Position
|
||||
* param y y-Position
|
||||
* param width Breite
|
||||
* param height Höhe
|
||||
*/
|
||||
public Pipes(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Rectangle[] createPipes(Transition top, Transition bottom, Pane pane) {
|
||||
int y = (int) (Math.random() * (200))-300;
|
||||
Rectangle topPipe = new Rectangle(1000, y, 91, 500);
|
||||
Rectangle bottomPipe = new Rectangle(1000, y + 400 + 250, 91, 500);
|
||||
|
||||
|
||||
Image img = new Image("file:src/main/resources/com/example/happy_bird/pics/PipeTop.png");
|
||||
topPipe.setFill(new ImagePattern(img));
|
||||
|
||||
img = new Image("file:src/main/resources/com/example/happy_bird/pics/PipeBottom.png");
|
||||
bottomPipe.setFill(new ImagePattern(img));
|
||||
|
||||
top = new TranslateTransition();
|
||||
bottom = new TranslateTransition();
|
||||
|
||||
((TranslateTransition) top).setNode(topPipe);
|
||||
((TranslateTransition) top).setDuration(Duration.seconds(5));
|
||||
((TranslateTransition) top).setToX(-1200);
|
||||
top.setOnFinished(e -> {
|
||||
pane.getChildren().remove(topPipe);
|
||||
});
|
||||
|
||||
((TranslateTransition) bottom).setNode(bottomPipe);
|
||||
((TranslateTransition) bottom).setDuration(Duration.seconds(5));
|
||||
((TranslateTransition) bottom).setToX(-1200);
|
||||
bottom.setOnFinished(e -> {
|
||||
pane.getChildren().remove(bottomPipe);
|
||||
});
|
||||
|
||||
Rectangle[] pipes = {topPipe, bottomPipe};
|
||||
return pipes;
|
||||
}
|
||||
|
||||
public void destroy(Pane pane) {
|
||||
|
||||
pane.getChildren().remove(topPipe);
|
||||
pane.getChildren().remove(bottomPipe);
|
||||
}
|
||||
|
||||
/***
|
||||
* Setzt für die beiden Rechtecke der Pipes das Hintergrundbild
|
||||
*/
|
||||
public void setImage() {
|
||||
Image img = new Image("file:src/main/resources/com/example/happy_bird/pics/PipeTop.png");
|
||||
topPipe.setFill(new ImagePattern(img));
|
||||
|
||||
img = new Image("file:src/main/resources/com/example/happy_bird/pics/PipeBottom.png");
|
||||
bottomPipe.setFill(new ImagePattern(img));
|
||||
}
|
||||
|
||||
/***
|
||||
* Setzt ein Object auf eine neue Position
|
||||
* param newX neue x-Position
|
||||
*/
|
||||
public void resetToNewPosition(int newX) {
|
||||
topPipe.setX(newX);
|
||||
bottomPipe.setX(newX);
|
||||
//xKoord = newX;
|
||||
}
|
||||
|
||||
/*
|
||||
// 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 > xKoord + width && !isPassedOn;
|
||||
}
|
||||
|
||||
// Bei Bewegung der X Koordinate werden Röhren generiert
|
||||
public void moveX(int dx) {
|
||||
xKoord -= dx;
|
||||
topPipe.x -= dx;
|
||||
bottomPipe.x -= dx;
|
||||
}*/
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
package com.example.happy_bird;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.ImageObserver;
|
||||
|
||||
public abstract class SpielObjekt {
|
||||
private int xWert;
|
||||
private int yWert;
|
||||
private int fxWert;
|
||||
private int fyWert;
|
||||
private int breite;
|
||||
private int hoehe;
|
||||
private Image bild;
|
||||
|
||||
public SpielObjekt(int xWert, int yWert) {
|
||||
this.xWert = xWert;
|
||||
this.yWert = yWert;
|
||||
}
|
||||
|
||||
public int getyWert() {
|
||||
return yWert;
|
||||
}
|
||||
|
||||
public void setyWert(int yWert) {
|
||||
this.yWert = yWert;
|
||||
}
|
||||
|
||||
public int getxWert() {
|
||||
return xWert;
|
||||
}
|
||||
|
||||
public void setxWert(int xWert) {
|
||||
this.xWert = xWert;
|
||||
}
|
||||
|
||||
public int getFxWert() {
|
||||
return fxWert;
|
||||
}
|
||||
|
||||
public void setFxWert(int fxWert) {
|
||||
this.fxWert = fxWert;
|
||||
}
|
||||
|
||||
public int getFyWert() {
|
||||
return fyWert;
|
||||
}
|
||||
|
||||
public void setFyWert(int fyWert) {
|
||||
this.fyWert = fyWert;
|
||||
}
|
||||
|
||||
public int getBreite() {
|
||||
return breite;
|
||||
}
|
||||
|
||||
public void setBreite(int breite) {
|
||||
this.breite = breite;
|
||||
}
|
||||
|
||||
public int getHoehe() {
|
||||
return hoehe;
|
||||
}
|
||||
|
||||
public void setHoehe(int hoehe) {
|
||||
this.hoehe = hoehe;
|
||||
}
|
||||
|
||||
public Image getBild() {
|
||||
return bild;
|
||||
}
|
||||
|
||||
public void setBild(Image bild) {
|
||||
this.bild = bild;
|
||||
}
|
||||
|
||||
|
||||
public abstract void tick();
|
||||
|
||||
public abstract void render(Graphics2D g, ImageObserver obs);
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package com.example.happy_bird;
|
||||
|
||||
public class TopClass {
|
||||
|
||||
private static final int PIPE_GAP = 0;
|
||||
private static final int PIPE_WIDTH = 0;
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
|
||||
<?import javafx.scene.control.Button?>
|
||||
<VBox alignment="CENTER" spacing="20.0" xmlns:fx="http://javafx.com/fxml"
|
||||
fx:controller="com.example.happy_bird.HelloController">
|
||||
<padding>
|
||||
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0"/>
|
||||
</padding>
|
||||
|
||||
<Label fx:id="welcomeText"/>
|
||||
<Button text="Hello!" onAction="#onHelloButtonClick"/>
|
||||
</VBox>
|
Binary file not shown.
Before Width: | Height: | Size: 126 KiB |
Loading…
Reference in New Issue
Block a user