Compare commits
4 Commits
d835ec3460
...
4f2eeb5040
Author | SHA1 | Date | |
---|---|---|---|
4f2eeb5040 | |||
a60eb17230 | |||
0f2352e003 | |||
e21b4c0f2d |
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.
2
Happy_Bird/.idea/Happy_Bird.iml
generated
2
Happy_Bird/.idea/Happy_Bird.iml
generated
@ -1,2 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4" />
|
5
Happy_Bird/.idea/compiler.xml
generated
5
Happy_Bird/.idea/compiler.xml
generated
@ -3,4 +3,9 @@
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="15" />
|
||||
</component>
|
||||
<component name="JavacSettings">
|
||||
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
||||
<module name="Happy_Bird.main" options="--add-exports java.base/jdk.internal.module=com.example.happy_bird" />
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
10
Happy_Bird/.idea/runConfigurations.xml
generated
10
Happy_Bird/.idea/runConfigurations.xml
generated
@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RunConfigurationProducerService">
|
||||
<option name="ignoredProducers">
|
||||
<set>
|
||||
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 6.5 KiB |
Binary file not shown.
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 65 KiB |
Binary file not shown.
@ -9,6 +9,7 @@ import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.scene.paint.ImagePattern;
|
||||
import javafx.stage.Stage;
|
||||
@ -21,6 +22,9 @@ import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class HappyBirdMain extends Application {
|
||||
|
||||
private float velocity = 0f;
|
||||
private float gravity = 0.25f;
|
||||
private int birdPositionMovedBy = 0;
|
||||
private int collectedPoints;
|
||||
private int playerhighscore;
|
||||
@ -99,8 +103,7 @@ public class HappyBirdMain extends Application {
|
||||
private final Slider soundSliderPause = new Slider();
|
||||
|
||||
/*Bilder*/
|
||||
private final Image bird = new Image("file:src/main/resources/com/example/happy_bird/pics/bird.png",
|
||||
45, 30, false, false);
|
||||
private final Image bird = new Image("file:src/main/resources/com/example/happy_bird/pics/bird.png");
|
||||
|
||||
private final Image pipeTop = new Image("file:src/main/resources/com/example/happy_bird/pics/PipeTop.png");
|
||||
private final Image pipeBottom = new Image("file:src/main/resources/com/example/happy_bird/pics/PipeBottom.png");
|
||||
@ -408,7 +411,7 @@ public class HappyBirdMain extends Application {
|
||||
|
||||
|
||||
/*Timeline: alle 2 Sekunden spawnt eine neue Pipe am rechten Rand*/
|
||||
timeline = new Timeline(new KeyFrame(Duration.seconds(2), e ->{
|
||||
timeline = new Timeline(new KeyFrame(Duration.seconds(1.5), e ->{
|
||||
/*Pipes erstellen*/
|
||||
Rectangle[] pipesTopBottom = createPipes();
|
||||
|
||||
@ -505,6 +508,7 @@ public class HappyBirdMain extends Application {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* Hauptmenü wird ausgeblendet, Nameneingabe folgt
|
||||
*/
|
||||
@ -691,21 +695,33 @@ 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();
|
||||
}
|
||||
});
|
||||
};
|
||||
/***
|
||||
* Startet Spiel nach Namenseingabe
|
||||
*/
|
||||
|
||||
public void startGameButtonClick() {
|
||||
if (correctName() == 0 && correctAcronym() == 0)
|
||||
{
|
||||
generateGameScreen();
|
||||
System.out.println(gameRunning);
|
||||
System.out.println(this.gameRunning);
|
||||
pauseButton.setDefaultButton(false);
|
||||
|
||||
/*Klick auf den Pause-Button, um das Pause-Menü aufzurufen*/
|
||||
pauseButton.setOnAction(event -> {
|
||||
if (!menuScreenRunning) {
|
||||
pauseButtonClick(gameRunning);
|
||||
gameRunning = !gameRunning;
|
||||
pauseButtonClick(this.gameRunning);
|
||||
this.gameRunning = !this.gameRunning;
|
||||
}
|
||||
});
|
||||
|
||||
@ -717,20 +733,36 @@ public class HappyBirdMain extends Application {
|
||||
*/
|
||||
birdPositionMovedBy = 0;
|
||||
scene.setOnKeyPressed(event -> {
|
||||
if (event.getCode() == KeyCode.S) {
|
||||
moveBirdDown();
|
||||
System.out.println(birdPositionMovedBy);
|
||||
}
|
||||
/*if (event.getCode() == KeyCode.S) {
|
||||
moveBirdDown();
|
||||
System.out.println(birdPositionMovedBy);
|
||||
}*/
|
||||
|
||||
|
||||
// FUNKTIONIERT
|
||||
// aktuelle birdPositionMovedBy rausfid
|
||||
|
||||
|
||||
/*if (event.getCode() == KeyCode.W) {
|
||||
moveBirdUp();
|
||||
}
|
||||
if (event.getCode() == KeyCode.S) {
|
||||
moveBirdDown();
|
||||
}*/
|
||||
|
||||
if (event.getCode() == KeyCode.W) {
|
||||
moveBirdUp();
|
||||
System.out.println(birdPositionMovedBy);
|
||||
}
|
||||
else {
|
||||
moveBirdDown();
|
||||
}
|
||||
if (event.getCode() == KeyCode.ESCAPE && !menuScreenRunning) {
|
||||
pauseButtonClick(gameRunning);
|
||||
gameRunning = !gameRunning;
|
||||
pauseButtonClick(this.gameRunning);
|
||||
this.gameRunning = !this.gameRunning;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
} else {
|
||||
checkNameLabel.setVisible(false);
|
||||
checkAcronymLabel.setVisible(false);
|
||||
@ -1168,12 +1200,16 @@ public class HappyBirdMain extends Application {
|
||||
}
|
||||
|
||||
private void moveBirdUp() {
|
||||
birdPositionMovedBy = birdPositionMovedBy - 10;
|
||||
velocity = (float) -4.5;
|
||||
var pos = velocity += gravity;
|
||||
birdPositionMovedBy += pos;
|
||||
happyBird.setLayoutY(birdPositionMovedBy);
|
||||
}
|
||||
|
||||
// Soll Automatisch runter fallen
|
||||
private void moveBirdDown() {
|
||||
birdPositionMovedBy = birdPositionMovedBy + 10;
|
||||
var pos = velocity -= gravity;
|
||||
birdPositionMovedBy -= pos;
|
||||
happyBird.setLayoutY(birdPositionMovedBy);
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 65 KiB |
Loading…
x
Reference in New Issue
Block a user