pause funktion hinzugefügt: ESC / P
parent
07a7b02819
commit
0bb77d4ac3
BIN
bin/Game.class
BIN
bin/Game.class
Binary file not shown.
BIN
bin/Player.class
BIN
bin/Player.class
Binary file not shown.
|
@ -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));
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue