diff --git a/bin/Game.class b/bin/Game.class index 77f5f51..8bceb04 100644 Binary files a/bin/Game.class and b/bin/Game.class differ diff --git a/bin/Player.class b/bin/Player.class index cdeb01b..976a4c1 100644 Binary files a/bin/Player.class and b/bin/Player.class differ diff --git a/src/Game.java b/src/Game.java index 0e3e19c..3fbf8a7 100644 --- a/src/Game.java +++ b/src/Game.java @@ -146,9 +146,15 @@ public class Game { frame.setVisible(true); while (player.lives > 0) { // Main-Loop - + dt = System.nanoTime() - lastT; // delta time lastT = System.nanoTime(); // delta time + + while(player.pause) { + delay(100); + dt = System.nanoTime() - lastT; + lastT = System.nanoTime(); + } player.setLocation(player.getPos('x', dt), player.getPos('y', dt)); diff --git a/src/Player.java b/src/Player.java index e96eae9..81e81ed 100644 --- a/src/Player.java +++ b/src/Player.java @@ -39,6 +39,8 @@ public class Player extends Picture implements KeyListener { // extends Picture private int movingTicks; // Richtungsbefehl durchzuführen. + public boolean pause; + public Player() { // Erstellen des Konstruktors super("Pac-Man/Pacman_Right"); // Aufrufen der übergeordneten Klasse (Picture) @@ -197,6 +199,13 @@ public class Player extends Picture implements KeyListener { // extends Picture calcDir(e.getKeyCode()); // aufrufen von der Methode calcDir mit der Eingabe e.getKeyCode() --> zuletzt // angeschlagene Taste + if (e.getKeyCode() == 80 || e.getKeyCode() == 27) { + if (pause) { + pause = false; + } else { + pause = true; + } + } } // Die folgenden 2 Methoden sind zwar leer, müssen jedoch trotzdem existieren,