bug gefixt, dass nach tod von pacman die punkte nicht mehr funktioniert haben

master
Lenz Wiechers 2020-06-06 14:00:19 +02:00
parent 63b85260fd
commit ff70f1d8f2
4 changed files with 31 additions and 20 deletions

Binary file not shown.

Binary file not shown.

View File

@ -115,10 +115,6 @@ public class Game {
// gesetzt:
player.setLocation(player.getPos('x', dt), player.getPos('y', dt));
// Aktualiesieren der Positionen der Geister:
// for (int i = 0; i < ghosts.length; i++) {
// ghosts[i].setLocation(ghosts[i].getPos('x', dt), ghosts[i].getPos('y', dt));
// }
for (int i = 0; i < ghosts.length; i++) {
@ -150,8 +146,6 @@ public class Game {
ghost_possible[i][3] = true;
}
// System.out.println(HCost[0] + " " + HCost[1] + " " + HCost[2] + " " +
// HCost[3]);
HCost[0] = ghosts[i].getHCost(player, 1, 0);
HCost[1] = ghosts[i].getHCost(player, -1, 0);
@ -185,9 +179,7 @@ public class Game {
}
}
// System.out.println(minn);
//
for (int j = 0; j < 4; j++) {
if (HCost[j] == minn) {
if (j == 0) {
@ -267,14 +259,6 @@ public class Game {
}
}
/*
* if ((player.getPos('x', 0) - 10) % 20 == 0 && (player.getPos('y', 0) - 10) %
* 20 == 0 && Map.points[conv(player.getPos('y', 0))][conv(player.getPos('x',
* 0))] != null) { Map.points[conv(player.yPos)][conv(player.xPos)].setBounds(0,
* 0, 0, 0);
*
* }
*/
player.calcDir(0); // Berechnen wo Pac-Man als nächstes hin soll
@ -287,7 +271,18 @@ public class Game {
player.lives--;
System.out.println(player.lives);
map.mapping();
delay(200);
for(int j = 0; j < ghosts.length; j++) {
ghosts[j].setPos('x', Map.ghost_posX[j]);
ghosts[j].setPos('y', Map.ghost_posY[j]);
player.setPos('x', Map.pac_posX);
player.setPos('y', Map.pac_posY);
player.up = false;
player.down = false;
player.right = false;
player.left = false;
}
}
}
fps = 1000000000 / dt;

View File

@ -9,13 +9,19 @@ public class Map {
public static Brick bricks[][] = new Brick[35][35]; // Zweidimensionales Array für alle Bricks
public static Point points[][] = new Point[35][35];
// Zweidimensionale Arrays siehe
// https://de.wikipedia.org/wiki/Feld_(Datentyp)#Mehrdimensional_/_in-sich-mehrdimensional
// https://de.wikipedia.org/wiki/Feld_(Datentyp)#Mehrdimensional_/_in-sich-mehrdimensional
BufferedReader reader; // reader zum Einlesen der Text Datei
Player player;
Ghost ghosts[];
public static int ghost_posX[] = new int[4];
public static int ghost_posY[] = new int[4];
public static int pac_posX;
public static int pac_posY;
String line; // String in dem eingelsene Zeilen der Datei gespeichert werden
public Map(Player player, Ghost ghosts[]) { // Erstellen des Konstruktors
@ -40,18 +46,28 @@ public class Map {
} else if (line.charAt(j) == 'P') {
player.setPos('x', 10 + 20 * j);
player.setPos('y', 10 + 20 * i);
pac_posX = 10 + 20 * j;
pac_posY = 10 + 20 * i;
} else if (line.charAt(j) == '0') {
ghosts[0].setPos('x', 10 + 20 * j);
ghosts[0].setPos('y', 10 + 20 * i);
ghost_posX[0] = 10 + 20 * j;
ghost_posY[0] = 10 + 20 * i;
} else if (line.charAt(j) == '1') {
ghosts[1].setPos('x', 10 + 20 * j);
ghosts[1].setPos('y', 10 + 20 * i);
ghost_posX[1] = 10 + 20 * j;
ghost_posY[1] = 10 + 20 * i;
} else if (line.charAt(j) == '2') {
ghosts[2].setPos('x', 10 + 20 * j);
ghosts[2].setPos('y', 10 + 20 * i);
ghost_posX[2] = 10 + 20 * j;
ghost_posY[2] = 10 + 20 * i;
} else if (line.charAt(j) == '3') {
ghosts[3].setPos('x', 10 + 20 * j);
ghosts[3].setPos('y', 10 + 20 * i);
ghost_posX[3] = 10 + 20 * j;
ghost_posY[3] = 10 + 20 * i;
} else if (line.charAt(j) == ' ') {
points[i][j] = new Point(10 + 20 * j, 10 + 20 * i);
}