diff --git a/assets/Neuer Ordner/brick.png b/assets/Neuer Ordner/brick.png new file mode 100644 index 0000000..15db204 Binary files /dev/null and b/assets/Neuer Ordner/brick.png differ diff --git a/assets/Pacman_full.png b/assets/Pacman_full.png deleted file mode 100644 index dcbf6c5..0000000 Binary files a/assets/Pacman_full.png and /dev/null differ diff --git a/assets/brick.png b/assets/brick.png index 15db204..4d5996a 100644 Binary files a/assets/brick.png and b/assets/brick.png differ diff --git a/bin/Game.class b/bin/Game.class index f48f306..4c4db84 100644 Binary files a/bin/Game.class and b/bin/Game.class differ diff --git a/src/Game.java b/src/Game.java index 1f9315f..89746be 100644 --- a/src/Game.java +++ b/src/Game.java @@ -26,7 +26,7 @@ public class Game { private int score = 0; private JLabel scoreLabel; - + private JLabel fpsLabel; private JLabel liveLabels[]; private int delaytimer = 4; @@ -65,7 +65,7 @@ public class Game { for (int i = 0; i < liveLabels.length; i++) { liveLabels[i] = new Lives(); panel.add(liveLabels[i]); - liveLabels[i].setBounds(710, 30 + 20 * i, 20, 20); + liveLabels[i].setBounds(710 + 20 * i, 35 , 20, 20); } scoreLabel = new JLabel(Integer.toString(score)); @@ -74,7 +74,14 @@ public class Game { scoreLabel.setBounds(710, 0, 500, 50); Font f = new Font("Consolas", Font.BOLD, 24); scoreLabel.setFont(f); - + + fpsLabel = new JLabel(Integer.toString(score)); + panel.add(fpsLabel); + fpsLabel.setForeground(Color.WHITE); + fpsLabel.setBounds(710, 45, 500, 50); + + fpsLabel.setFont(f); + panel.add(player); // Pac-Man wird dem Panel hinzugefügt frame.addKeyListener(player); // KeyListener wird hinzugefügt, man kann nun Pac-Maan mit der tastatur steuern @@ -153,23 +160,7 @@ public class Game { // ----------------------------------------------------------------------------------------------------------------------------------------------------- while (true) { // Hauptschleife - - - for (int i = 0; i < ghosts.length; i++) { - if (ghosts[i].getIsDead()) { - if (ghosts[i].getDeathTimer() != 0) { - ghosts[i].setDeathTimer(ghosts[i].getDeathTimer() - 1); - } else { - ghosts[i].setIsDead(false); - ghosts[i].setPos('x', Map.ghost_posX[i]); - ghosts[i].setPos('y', Map.ghost_posY[i]); - - } - } - } - - frames++; if (ghosts[0].feared == true) { if (Ghost.fearedTimer != 0) { Ghost.fearedTimer--; @@ -395,9 +386,23 @@ public class Game { } } - player.calcDir(0); // Berechnen wo Pac-Man als nächstes hin soll - + + + // Geister LOOP for (int i = 0; i < ghosts.length; i++) { + // + if (ghosts[i].getIsDead()) { + if (ghosts[i].getDeathTimer() != 0) { + ghosts[i].setDeathTimer(ghosts[i].getDeathTimer() - 1); + + } else { + ghosts[i].setIsDead(false); + ghosts[i].setPos('x', Map.ghost_posX[i]); + ghosts[i].setPos('y', Map.ghost_posY[i]); + + } + } + ghosts[i].setLocation(ghosts[i].getPos('x', dt), ghosts[i].getPos('y', dt)); if (player.getPos('x', 0) < ghosts[i].getPos('x', 0) + 18 && player.getPos('x', 0) > ghosts[i].getPos('x', 0) - 18 @@ -430,11 +435,13 @@ public class Game { player.right = false; player.left = false; } + + // Geister LOOP } + // + - fps = 1000000000 / dt; - - delay(delaytimer); // Ein delay zum Ende der Hauptschleife + // Ein delay zum Ende der Hauptschleife if (frames % 100 == 0) { boolean empty = true; @@ -455,10 +462,18 @@ public class Game { if (empty) { scoreLabel.setText("YOU WON"); delay(1000); - System.exit(0); + System.exit(0); // HIER DEN HIGHSCORE IMPLEMENTIEREN } } + player.calcDir(0); // Berechnen wo Pac-Man als nächstes hin soll + fps = 1000000000 / dt; + fpsLabel.setText("fps: " + Integer.toString((int) fps)); + frames++; // FRAMES WIRD HOCHGESETZT + delay(delaytimer); + // } + // ENDE DER WHILE-SCHLEIFE + } // Methode zum verzögern (warten) in ms