Gravitation & Velocity Jump Fix
This commit is contained in:
parent
d835ec3460
commit
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.
@ -21,6 +21,10 @@ import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class HappyBirdMain extends Application {
|
||||
Thread thread;
|
||||
|
||||
private float velocity = 0f;
|
||||
private float gravity = 0.25f;
|
||||
private int birdPositionMovedBy = 0;
|
||||
private int collectedPoints;
|
||||
private int playerhighscore;
|
||||
@ -505,6 +509,7 @@ public class HappyBirdMain extends Application {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* Hauptmenü wird ausgeblendet, Nameneingabe folgt
|
||||
*/
|
||||
@ -694,18 +699,19 @@ public class HappyBirdMain extends Application {
|
||||
/***
|
||||
* 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 +723,37 @@ 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 +1191,16 @@ public class HappyBirdMain extends Application {
|
||||
}
|
||||
|
||||
private void moveBirdUp() {
|
||||
birdPositionMovedBy = birdPositionMovedBy - 10;
|
||||
velocity = (float) -1.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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user