game wird neugestartet, nachdem man gestorben ist

master
Lenz Wiechers 2020-06-09 18:58:43 +02:00
parent 8f5ebb93b1
commit 07a7b02819
17 changed files with 40 additions and 34 deletions

14
bin/.gitignore vendored
View File

@ -1,14 +0,0 @@
/BigPoint.class
/Brick.class
/Game.class
/Ghost.class
/Hintergrund.class
/Lives.class
/Main.class
/Map.class
/MapMenu$1.class
/MapMenu.class
/Picture.class
/Player.class
/Point.class
/Portal.class

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.

BIN
bin/MapMenu$1.class Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -145,7 +145,7 @@ public class Game {
delay(1000); delay(1000);
frame.setVisible(true); frame.setVisible(true);
while (true) { // Main-Loop while (player.lives > 0) { // Main-Loop
dt = System.nanoTime() - lastT; // delta time dt = System.nanoTime() - lastT; // delta time
lastT = System.nanoTime(); // delta time lastT = System.nanoTime(); // delta time
@ -403,7 +403,8 @@ public class Game {
liveLabels[player.lives].setBounds(0, 0, 0, 0); // Das herz wird "entfernt" liveLabels[player.lives].setBounds(0, 0, 0, 0); // Das herz wird "entfernt"
if (player.lives == 0) { // Wenn der Spieler keine Leben mehr übrig hat if (player.lives == 0) { // Wenn der Spieler keine Leben mehr übrig hat
System.exit(0); // Das Programm wird beendet fpsLabel.setText("YOU LOST");
delay(3000);
} }
delay(200); // Damit nicht sofort wieder alle losgeht delay(200); // Damit nicht sofort wieder alle losgeht
@ -444,7 +445,6 @@ public class Game {
if (empty) { if (empty) {
fpsLabel.setText("YOU WON"); fpsLabel.setText("YOU WON");
delay(5000); delay(5000);
System.exit(0); // Das Programm wird beendet
// HIER DEN HIGHSCORE IMPLEMENTIEREN // HIER DEN HIGHSCORE IMPLEMENTIEREN
} }
} }
@ -472,7 +472,7 @@ public class Game {
} }
// Methode zum verzögern (warten) in ms // Methode zum verzögern (warten) in ms
public void delay(int time) { private void delay(int time) {
try { try {
Thread.sleep(time); Thread.sleep(time);

View File

@ -3,29 +3,49 @@
// Muss ausgeführt werden zum Starten // Muss ausgeführt werden zum Starten
public class Main { public class Main {
static
@SuppressWarnings("unused") // Die "unused" - Warnungen werden in dieser Datei nicht mehr angezeigt MapMenu menu;
static Game game;
public static void main(String[] args) { public static void main(String[] args) {
System.setProperty("sun.java2d.opengl", "true"); System.setProperty("sun.java2d.opengl", "true");
MapMenu menu = new MapMenu(); menu = new MapMenu();
while(!menu.rdy) { while (!menu.rdy) {
delay(1); delay(100);
} }
Game game = new Game(menu.selectedMap + ".txt"); game = new Game(menu.selectedMap + ".txt");
} while (true) {
// Methode zum verzögern (warten) in ms game.frame.dispose();
public static void delay(int time) {
try { menu = null;
Thread.sleep(time); game = null;
} catch (InterruptedException e) {
e.printStackTrace(); menu = new MapMenu();
while (!menu.rdy) {
delay(100);
} }
game = new Game(menu.selectedMap + ".txt");
} }
}
// Methode zum verzögern (warten) in ms
public static void delay(int time) {
try {
Thread.sleep(time);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
} }