diff --git a/assets/Map.txt b/assets/Map.txt index a873f86..7851a67 100644 --- a/assets/Map.txt +++ b/assets/Map.txt @@ -1,8 +1,8 @@ -###############################0### -# # ## -# # ############### ############### +############################# ##### +# # # # 0 # +# # ############### ######### ##### # # # ## ### ##### -# # # ########## ### ##### ##### +# # # ########## ### ########## # # # ################# ##### ##### # # # # #### #### # # # # #################### ###### diff --git a/bin/Game.class b/bin/Game.class index 79eeb98..9cea366 100644 Binary files a/bin/Game.class and b/bin/Game.class differ diff --git a/bin/Ghost.class b/bin/Ghost.class index 8a1f87d..6a4645c 100644 Binary files a/bin/Ghost.class and b/bin/Ghost.class differ diff --git a/src/Game.java b/src/Game.java index 3238259..9b3a999 100644 --- a/src/Game.java +++ b/src/Game.java @@ -19,9 +19,9 @@ public class Game { // Delta time: siehe https://en.wikipedia.org/wiki/Delta_timing private long dt; private long lastT; - + private int delaytimer = 9; - + @SuppressWarnings("unused") private long fps = 60; @@ -41,7 +41,12 @@ public class Game { panel = new JPanel(); // darauf werden alle sichtbaren Elemente gespeichert - ghosts = new Ghost[4]; // 4 Geister + ghosts = new Ghost[1]; // 4 Geister + + boolean[] ghost_up_possible = new boolean[ghosts.length]; + boolean[] ghost_down_possible = new boolean[ghosts.length]; + boolean[] ghost_left_possible = new boolean[ghosts.length]; + boolean[] ghost_right_possible = new boolean[ghosts.length]; player = new Player(); // Pac-Man @@ -103,7 +108,36 @@ public class Game { ghosts[i].setLocation(ghosts[i].getPos('x', dt), ghosts[i].getPos('y', dt)); } - + for (int i = 0; i < ghosts.length; i++) { + + if (Map.bricks[((ghosts[i].getPos('y', 0) - 10) / 20) - 1][(ghosts[i].getPos('x', 0) - 10) + / 20] == null) { + ghost_up_possible[i] = true; + } + if (Map.bricks[((ghosts[i].getPos('y', 0) - 10) / 20) + 1][(ghosts[i].getPos('x', 0) - 10) + / 20] == null) { + ghost_down_possible[i] = true; + } + if (Map.bricks[(ghosts[i].getPos('y', 0) - 10) / 20][((ghosts[i].getPos('x', 0) - 10) / 20) + - 1] == null) { + ghost_left_possible[i] = true; + } + if (Map.bricks[(ghosts[i].getPos('y', 0) - 10) / 20][((ghosts[i].getPos('x', 0) - 10) / 20) + + 1] == null) { + ghost_right_possible[i] = true; + } + + System.out.println("up: " + ghost_up_possible[i] + " | down: " + ghost_down_possible[i] + " | left: " + + ghost_left_possible[i] + " | right: " + ghost_right_possible[i]); + + // System.out.println((ghosts[i].getPos('y', 0) - 10) / 20); + + ghost_up_possible[i] = false; + ghost_down_possible[i] = false; + ghost_left_possible[i] = false; + ghost_right_possible[i] = false; + + } // Kollision von Pac-Man mit Bricks: for (int i = 0; i < 35; i++) { // für jeden Brick @@ -135,7 +169,7 @@ public class Game { } } } - + player.calcDir(0); // Berechnen wo Pac-Man als nächstes hin soll for (int i = 0; i < ghosts.length; i++) { @@ -150,11 +184,11 @@ public class Game { } } fps = 1000000000 / dt; - + // System.out.println("fps: " + fps + " | delaytimer: " + delaytimer); - + delay(delaytimer); // Ein delay zum Ende der Hauptschleife - + } } diff --git a/src/Ghost.java b/src/Ghost.java index 69b0050..8d2b66b 100644 --- a/src/Ghost.java +++ b/src/Ghost.java @@ -6,6 +6,10 @@ public class Ghost extends Picture { // Die private int xPos; private int yPos; + + private int HCost; + private int GCost; + private int FCost; public Ghost(int index) { @@ -39,5 +43,26 @@ public class Ghost extends Picture { // Die yPos = newPos; } } + + public void moveUp() { + } + + public void moveDown() { + + } + + public void moveRight() { + + } + + public void moveLeft() { + + } + + public int getHCost() { + + + return HCost; + } }