Current Score Zähler einbauen
This commit is contained in:
@@ -21,7 +21,8 @@ import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class HappyBirdMain extends Application {
|
||||
private int currentBirdPosition = 0;
|
||||
private int birdPositionMovedBy = 0;
|
||||
private int collectedPoints;
|
||||
/* Formatierungsklasse */
|
||||
private final FormatingClass formatingClass = new FormatingClass();
|
||||
|
||||
@@ -44,7 +45,7 @@ public class HappyBirdMain extends Application {
|
||||
private final Label acronymLabel = new Label("KÜRZEL");
|
||||
private final Label headline = new Label("HAPPY BIRD");
|
||||
private final Label soundLabel = new Label("SOUND");
|
||||
private final Label currentScoreLabel = new Label("SCORE: ");
|
||||
private final Label currentScoreLabel = new Label("SCORE: " + collectedPoints);
|
||||
private final Label highscoreLabel = new Label("HIGHSCORE: ");
|
||||
private final Label pauseMenuLabel = new Label("PAUSE");
|
||||
private final Label soundLabelPause = new Label("SOUND");
|
||||
@@ -464,6 +465,12 @@ public class HappyBirdMain extends Application {
|
||||
timeline.stop();
|
||||
gameRunning = false;
|
||||
}
|
||||
if(happyBird.getBoundsInParent().getMaxX() > pipe.getBoundsInParent().getMaxX()) {
|
||||
collectedPoints++;
|
||||
int pointstoset = collectedPoints / 2;
|
||||
currentScoreLabel.setText("SCORE: " + pointstoset);
|
||||
pipesArrayList.remove(pipe);
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
@@ -668,15 +675,15 @@ public class HappyBirdMain extends Application {
|
||||
}
|
||||
});
|
||||
|
||||
currentBirdPosition = 0;
|
||||
birdPositionMovedBy = 0;
|
||||
scene.setOnKeyPressed(event -> {
|
||||
if (event.getCode() == KeyCode.S) {
|
||||
moveBirdDown();
|
||||
System.out.println(currentBirdPosition);
|
||||
System.out.println(birdPositionMovedBy);
|
||||
}
|
||||
if (event.getCode() == KeyCode.W) {
|
||||
moveBirdUp();
|
||||
System.out.println(currentBirdPosition);
|
||||
System.out.println(birdPositionMovedBy);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1080,12 +1087,12 @@ public class HappyBirdMain extends Application {
|
||||
}
|
||||
|
||||
private void moveBirdUp() {
|
||||
currentBirdPosition = currentBirdPosition - 10;
|
||||
happyBird.setLayoutY(currentBirdPosition);
|
||||
birdPositionMovedBy = birdPositionMovedBy - 10;
|
||||
happyBird.setLayoutY(birdPositionMovedBy);
|
||||
}
|
||||
|
||||
private void moveBirdDown() {
|
||||
currentBirdPosition = currentBirdPosition + 10;
|
||||
happyBird.setLayoutY(currentBirdPosition);
|
||||
birdPositionMovedBy = birdPositionMovedBy + 10;
|
||||
happyBird.setLayoutY(birdPositionMovedBy);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user