diff --git a/bin/.gitignore b/bin/.gitignore index 66d1c8e..7cf58ac 100644 --- a/bin/.gitignore +++ b/bin/.gitignore @@ -1,7 +1 @@ -/Brick.class -/Game.class -/Ghost.class -/Main.class -/Map.class -/Picture.class -/Player.class +/assets/ diff --git a/bin/Brick.class b/bin/Brick.class index ab70c40..50ef0ed 100644 Binary files a/bin/Brick.class and b/bin/Brick.class differ diff --git a/bin/Game.class b/bin/Game.class index 4708f0b..9625daa 100644 Binary files a/bin/Game.class and b/bin/Game.class differ diff --git a/bin/Ghost.class b/bin/Ghost.class index 7370743..8a1f87d 100644 Binary files a/bin/Ghost.class and b/bin/Ghost.class differ diff --git a/bin/Main.class b/bin/Main.class index 49bb040..1a83356 100644 Binary files a/bin/Main.class and b/bin/Main.class differ diff --git a/bin/Map.class b/bin/Map.class index 6751556..bba0248 100644 Binary files a/bin/Map.class and b/bin/Map.class differ diff --git a/bin/Picture.class b/bin/Picture.class index a4b2415..f720bca 100644 Binary files a/bin/Picture.class and b/bin/Picture.class differ diff --git a/bin/Player.class b/bin/Player.class index 0b774a0..b5fa448 100644 Binary files a/bin/Player.class and b/bin/Player.class differ diff --git a/src/Game.java b/src/Game.java index 0ea4bf0..d579ff6 100644 --- a/src/Game.java +++ b/src/Game.java @@ -98,7 +98,7 @@ public class Game { ghosts[i].setLocation(ghosts[i].getPos('x', dt), ghosts[i].getPos('y', dt)); } - player.calcDir(0); // Berechnen wo Pac-Man als nächstes hin soll + // Kollision von Pac-Man mit Bricks: for (int i = 0; i < 35; i++) { // für jeden Brick @@ -110,15 +110,19 @@ public class Game { && player.getPos('y', 0) > Map.bricks[j][i].yPos - 20) { if (player.left) { player.setPos('x', Map.bricks[j][i].xPos + 20); + player.setPos('y', Map.bricks[j][i].yPos); player.left = false; } else if (player.right) { player.setPos('x', Map.bricks[j][i].xPos - 20); + player.setPos('y', Map.bricks[j][i].yPos); player.right = false; } else if (player.up) { player.setPos('y', Map.bricks[j][i].yPos + 20); + player.setPos('x', Map.bricks[j][i].xPos); player.up = false; } else if (player.down) { player.setPos('y', Map.bricks[j][i].yPos - 20); + player.setPos('x', Map.bricks[j][i].xPos); player.down = false; } @@ -126,6 +130,8 @@ public class Game { } } } + + player.calcDir(0); // Berechnen wo Pac-Man als nächstes hin soll for (int i = 0; i < ghosts.length; i++) { if (player.getPos('x', 0) < ghosts[i].getPos('x', 0) + 20 diff --git a/src/Player.java b/src/Player.java index 6b0879f..12b7618 100644 --- a/src/Player.java +++ b/src/Player.java @@ -53,7 +53,7 @@ public class Player extends Picture implements KeyListener { // extends Picture if (keyCode == 37 || pressed_left && System.currentTimeMillis() - timer <= blob) { for (int i = 0; i < 35; i++) { // für jeden Brick - for (int j = 0; j < 35; j++) { // für jeden Bick + for (int j = 0; j < 35; j++) { // für jeden Brick if (Map.bricks[j][i] != null) { // Damit kein Fehler auftritt wegen nicht vorhandenen Bricks if (Map.bricks[j][i].xPos + 20 == (int) xPos && (int) yPos < Map.bricks[j][i].yPos + 20 && (int) yPos > Map.bricks[j][i].yPos - 20) { // wenn Pac-Man gerade rechts an einem