Code Cleaning

This commit is contained in:
Gregor Bickmann 2022-02-10 08:47:16 +01:00
parent 4f2eeb5040
commit 88b0ba5d05
10 changed files with 7 additions and 21 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

View File

@ -733,32 +733,17 @@ public class HappyBirdMain extends Application {
*/ */
birdPositionMovedBy = 0; birdPositionMovedBy = 0;
scene.setOnKeyPressed(event -> { scene.setOnKeyPressed(event -> {
/*if (event.getCode() == KeyCode.S) {
moveBirdDown();
System.out.println(birdPositionMovedBy);
}*/
if (event.getCode() == KeyCode.W) {
// FUNKTIONIERT
// aktuelle birdPositionMovedBy rausfid
/*if (event.getCode() == KeyCode.W) {
moveBirdUp(); moveBirdUp();
} }
if (event.getCode() == KeyCode.S) { if (event.getCode() == KeyCode.S) {
moveBirdDown(); moveBirdDown();
}*/ }
if (event.getCode() == KeyCode.W) { if (event.getCode() == KeyCode.ESCAPE && !menuScreenRunning) {
moveBirdUp(); pauseButtonClick(this.gameRunning);
} this.gameRunning = !this.gameRunning;
else {
moveBirdDown();
}
if (event.getCode() == KeyCode.ESCAPE && !menuScreenRunning) {
pauseButtonClick(this.gameRunning);
this.gameRunning = !this.gameRunning;
} }
}); });
@ -1199,6 +1184,7 @@ public class HappyBirdMain extends Application {
generateMenueScreen(); generateMenueScreen();
} }
// Aufstieg dauert immer länger
private void moveBirdUp() { private void moveBirdUp() {
velocity = (float) -4.5; velocity = (float) -4.5;
var pos = velocity += gravity; var pos = velocity += gravity;
@ -1206,7 +1192,7 @@ public class HappyBirdMain extends Application {
happyBird.setLayoutY(birdPositionMovedBy); happyBird.setLayoutY(birdPositionMovedBy);
} }
// Soll Automatisch runter fallen // Fall geht schneller
private void moveBirdDown() { private void moveBirdDown() {
var pos = velocity -= gravity; var pos = velocity -= gravity;
birdPositionMovedBy -= pos; birdPositionMovedBy -= pos;