Skip to content
Snippets Groups Projects
Commit 048427a6 authored by roguecomp's avatar roguecomp
Browse files

Implementing win and lose screens

parent 864ddd93
No related branches found
No related tags found
No related merge requests found
......@@ -12,9 +12,12 @@ public class ShadowFlap extends AbstractGame {
private Image Background;
private Bird bird;
private Pipe pipe;
private static String gameState = "mainMenu";
private int score = 0;
private String gameState = "mainMenu", temp = "";
private final String startString = "PRESS SPACE TO START";
private final String outOfBounds = "Out Of Bounds";
private final String outOfBounds = "GAME OVER!";
private final String finalScore = "Final Score: ";
private final String winFont = "CONGRATULATIONS!";
private final Font font = new Font("res/slkscr.ttf", 48);
public ShadowFlap() {
......@@ -53,13 +56,39 @@ public class ShadowFlap extends AbstractGame {
bird.Render();
Point birdPos = new Point(bird.x, bird.y);
pipe.Render(bird.birdWingDown.getBoundingBoxAt(birdPos));
temp = pipe.Render(bird.birdWingDown.getBoundingBoxAt(birdPos));
if(temp == null) {
temp = "";
}
else {
gameState = temp;
}
if(bird.x > pipe.pos) {
this.score = 1;
}
if(pipe.pos <= 0) {
this.gameState = "win";
}
}
else if (gameState == "outOfBounds") {
Background.draw(Window.getWidth() / 2.0, Window.getHeight() / 2.0);
font.drawString(outOfBounds,
(Window.getWidth() / 2.0) - (font.getWidth(outOfBounds) / 2.0),
Window.getHeight() / 2.0);
font.drawString(finalScore + String.valueOf(this.score),
(Window.getWidth() / 2.0) - (font.getWidth(finalScore + String.valueOf(this.score)) / 2.0),
(Window.getHeight() / 2.0) + 75);
}
else if (gameState == "win") {
Background.draw(Window.getWidth() / 2.0, Window.getHeight() / 2.0);
font.drawString(winFont,
(Window.getWidth() / 2.0) - (font.getWidth(winFont) / 2.0),
Window.getHeight() / 2.0);
font.drawString(finalScore + String.valueOf(this.score),
(Window.getWidth() / 2.0) - (font.getWidth(finalScore + String.valueOf(this.score)) / 2.0),
(Window.getHeight() / 2.0) + 75);
}
else {
/* loading screen */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment