fix von ghost pathing

master
leventius imperatus 2020-06-07 16:12:00 +02:00
parent d910b4a191
commit 534748e313
4 changed files with 43 additions and 36 deletions

Binary file not shown.

Binary file not shown.

View File

@ -158,7 +158,6 @@ public class Game {
ghosts[i].setPos('x', Map.ghost_posX[i]); ghosts[i].setPos('x', Map.ghost_posX[i]);
ghosts[i].setPos('y', Map.ghost_posY[i]); ghosts[i].setPos('y', Map.ghost_posY[i]);
} }
} }
} }
@ -219,16 +218,16 @@ public class Game {
// //
int minn = 10000; int minn = 10000;
if (ghosts[i].up == true) { if (ghosts[i].dire == 2) {
HCost[3] = 10000; HCost[3] = 10000;
} }
if (ghosts[i].down == true) { if (ghosts[i].dire == 3) {
HCost[2] = 10000; HCost[2] = 10000;
} }
if (ghosts[i].left == true) { if (ghosts[i].dire == 1) {
HCost[0] = 10000; HCost[0] = 10000;
} }
if (ghosts[i].right == true) { if (ghosts[i].dire == 0) {
HCost[1] = 10000; HCost[1] = 10000;
} }
@ -247,11 +246,13 @@ public class Game {
// HCost[3]); // HCost[3]);
for (int j = 0; j < 4; j++) { for (int j = 0; j < 4; j++) {
if (HCost[j] == minn) { if (HCost[j] == minn) {
if (frames % 4 == 0) {
if (j == 0) { if (j == 0) {
ghosts[i].right = true; ghosts[i].right = true;
ghosts[i].left = false; ghosts[i].left = false;
ghosts[i].down = false; ghosts[i].down = false;
ghosts[i].up = false; ghosts[i].up = false;
ghosts[i].dire = 0;
break; break;
} }
if (j == 1) { if (j == 1) {
@ -259,6 +260,7 @@ public class Game {
ghosts[i].right = false; ghosts[i].right = false;
ghosts[i].down = false; ghosts[i].down = false;
ghosts[i].up = false; ghosts[i].up = false;
ghosts[i].dire = 1;
break; break;
} }
if (j == 2) { if (j == 2) {
@ -266,6 +268,7 @@ public class Game {
ghosts[i].right = false; ghosts[i].right = false;
ghosts[i].left = false; ghosts[i].left = false;
ghosts[i].down = false; ghosts[i].down = false;
ghosts[i].dire = 2;
break; break;
} }
if (j == 3) { if (j == 3) {
@ -273,10 +276,12 @@ public class Game {
ghosts[i].right = false; ghosts[i].right = false;
ghosts[i].left = false; ghosts[i].left = false;
ghosts[i].up = false; ghosts[i].up = false;
ghosts[i].dire = 3;
break; break;
} }
} }
} }
}
} }
} }

View File

@ -12,6 +12,8 @@ public class Ghost extends Picture { // Die
public boolean left; public boolean left;
public boolean right; public boolean right;
public int dire;
public boolean feared; public boolean feared;
public static int fearedTimer; public static int fearedTimer;
private int deathTimer; private int deathTimer;
@ -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) .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)); + Math.pow((((yPos - 10) / 20) + mod_y) - ((player.getPos('y', 0) - 10) / 20), 2));
} else if (type == 2) { } else if (type == 2) {
HCost = (int) Math.sqrt(Math.pow((((xPos - 10) / 20) + mod_x) - ((250 - 10 + 80) / 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) - ((100 - 10) / 20), 2)); + Math.pow((((yPos - 10) / 20) + mod_y) - ((200 - 10) / 20), 2));
} else if (type == 3) { } else if (type == 3) {
HCost = (int) Math.sqrt(Math.pow((((xPos - 10) / 20) + mod_x) - ((player.getPos('x', 0) - 10) / 20), 2) 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)); + Math.pow((((yPos - 10) / 20) + mod_y) - ((player.getPos('y', 0) + 100 - 10) / 20), 2));