diff --git a/bin/Game.class b/bin/Game.class index 5917123..510f264 100644 Binary files a/bin/Game.class and b/bin/Game.class differ diff --git a/bin/Ghost.class b/bin/Ghost.class index d7ec4e1..57429bd 100644 Binary files a/bin/Ghost.class and b/bin/Ghost.class differ diff --git a/src/Game.java b/src/Game.java index d638797..a07f8ff 100644 --- a/src/Game.java +++ b/src/Game.java @@ -157,7 +157,6 @@ public class Game { ghosts[i].setIsDead(false); ghosts[i].setPos('x', Map.ghost_posX[i]); ghosts[i].setPos('y', Map.ghost_posY[i]); - } } @@ -219,16 +218,16 @@ public class Game { // int minn = 10000; - if (ghosts[i].up == true) { + if (ghosts[i].dire == 2) { HCost[3] = 10000; } - if (ghosts[i].down == true) { + if (ghosts[i].dire == 3) { HCost[2] = 10000; } - if (ghosts[i].left == true) { + if (ghosts[i].dire == 1) { HCost[0] = 10000; } - if (ghosts[i].right == true) { + if (ghosts[i].dire == 0) { HCost[1] = 10000; } @@ -247,33 +246,39 @@ public class Game { // HCost[3]); for (int j = 0; j < 4; j++) { if (HCost[j] == minn) { - if (j == 0) { - ghosts[i].right = true; - ghosts[i].left = false; - ghosts[i].down = false; - ghosts[i].up = false; - break; - } - if (j == 1) { - ghosts[i].left = true; - ghosts[i].right = false; - ghosts[i].down = false; - ghosts[i].up = false; - break; - } - if (j == 2) { - ghosts[i].up = true; - ghosts[i].right = false; - ghosts[i].left = false; - ghosts[i].down = false; - break; - } - if (j == 3) { - ghosts[i].down = true; - ghosts[i].right = false; - ghosts[i].left = false; - ghosts[i].up = false; - break; + if (frames % 4 == 0) { + if (j == 0) { + ghosts[i].right = true; + ghosts[i].left = false; + ghosts[i].down = false; + ghosts[i].up = false; + ghosts[i].dire = 0; + break; + } + if (j == 1) { + ghosts[i].left = true; + ghosts[i].right = false; + ghosts[i].down = false; + ghosts[i].up = false; + ghosts[i].dire = 1; + break; + } + if (j == 2) { + ghosts[i].up = true; + ghosts[i].right = false; + ghosts[i].left = false; + ghosts[i].down = false; + ghosts[i].dire = 2; + break; + } + if (j == 3) { + ghosts[i].down = true; + ghosts[i].right = false; + ghosts[i].left = false; + ghosts[i].up = false; + ghosts[i].dire = 3; + break; + } } } } @@ -393,7 +398,7 @@ public class Game { ghosts[i].setPos('x', -100); ghosts[i].setPos('y', -100); score += 1000; - System.out.println("Geist"+ i + " ist gestorben" + ghosts[i].getIsDead()); + System.out.println("Geist" + i + " ist gestorben" + ghosts[i].getIsDead()); } else { player.lives--; diff --git a/src/Ghost.java b/src/Ghost.java index deeffa8..c2ca89d 100644 --- a/src/Ghost.java +++ b/src/Ghost.java @@ -6,11 +6,13 @@ public class Ghost extends Picture { // Die public float xPos; public float yPos; - + public boolean up; public boolean down; public boolean left; public boolean right; + + public int dire; public boolean feared; public static int fearedTimer; @@ -60,8 +62,8 @@ public class Ghost extends Picture { // Die .sqrt(Math.pow((((xPos - 10) / 20) + mod_x) - ((player.getPos('x', 0) - 10 + 80) / 20), 2) + Math.pow((((yPos - 10) / 20) + mod_y) - ((player.getPos('y', 0) - 10) / 20), 2)); } else if (type == 2) { - HCost = (int) Math.sqrt(Math.pow((((xPos - 10) / 20) + mod_x) - ((250 - 10 + 80) / 20), 2) - + Math.pow((((yPos - 10) / 20) + mod_y) - ((100 - 10) / 20), 2)); + HCost = (int) Math.sqrt(Math.pow((((xPos - 10) / 20) + mod_x) - ((200 - 10 + 80) / 20), 2) + + Math.pow((((yPos - 10) / 20) + mod_y) - ((200 - 10) / 20), 2)); } else if (type == 3) { HCost = (int) Math.sqrt(Math.pow((((xPos - 10) / 20) + mod_x) - ((player.getPos('x', 0) - 10) / 20), 2) + Math.pow((((yPos - 10) / 20) + mod_y) - ((player.getPos('y', 0) + 100 - 10) / 20), 2));