From ff70f1d8f21454779a355ea35eee42ea8048dccb Mon Sep 17 00:00:00 2001 From: Lenz Date: Sat, 6 Jun 2020 14:00:19 +0200 Subject: [PATCH] bug gefixt, dass nach tod von pacman die punkte nicht mehr funktioniert haben --- bin/Game.class | Bin 5809 -> 6065 bytes bin/Map.class | Bin 2091 -> 2406 bytes src/Game.java | 31 +++++++++++++------------------ src/Map.java | 20 ++++++++++++++++++-- 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/bin/Game.class b/bin/Game.class index a1e5f92af3024477133c25ba0c1580d8d0950b11..e0fcf3d861c2301f2e3a97d31f4117e414654640 100644 GIT binary patch delta 1413 zcmY*ZeN2^Q6#t#~eV+Gu-pd8<niPV}Ve}kZN98 zU`=Bgchl6Bu~;OzCI~k)WfZW8NIqQTf*?)&Kokg8d$l_P|6>UjJz&Qmf(bHn%hs6$i~QS;;k(HMuA~ujxJju7u20>b?2Z$O#x#*2 zxQj(dIBBG-MzYe9lQRkIk#&!5vJodC$Z)rc`!$m85ix1=&w~L~%iMHwTsovi3*C0- zD!S-?-Wg5}?l+v_u47S^SnbF)Jt$HrHX?ck?{f-)Ybj< zGJK@BV!u9ykC`8em=g!s!#K!d@Cn<1Lo69bSSmhc+4zj@!sl!+ikTZoj;ElWXQF{;;YXf}M*bdt;)Q792k|p6Ml&zLIbMbq?y5v9uR$Ac zL_2TCdH$;s>P8OlLnj|V7azeNdxMF;R zt42Mp8NcDW(StstA2)=Cei4eBA`-Vm6b3{b2E|4Ui9~dXBy@^&jJm{I7!x@d7kQWv zhcPKm;`N?>)%Qwki7E*vbMh@vAr>vtO*+jvz zg+gQxg~|cCM@~?fDQJ!vNOR3Fy4RdX;pRdLHlHNZTuJlIXUO%Sxe@93SG@}lf~+mT zD8`hRC?_zEIJI2e*nkNHL!(s0`_Oi*!KC7Js=dQC%yQaheZTh{OQmegwa&3x%$vzz z?9wda48O1QlDwbP{VfqbL|NX_A_E7!oYu4Fn|_=(-N4p z6#n$Y%y8y=vwg!+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j0T2VxweyG2RR*b3uzt>K&yCy8yG z$Zn%A+uXl}lUo?tz({bsCiKL&7}>;`nc&5mxG~VZiSyCeI(na@wQIP08xz@RB-+wl zyf3$|;{7dL%GAUWFEPE2HA0~+@L=-CCh=K)51Kxhwuo?U>X2hi4W^f@}*&dg;0+nHOL z8X89%9tA~rH1_q2jYmRsN#m;;4yB$Wy^XnS^V?f^r+*Xko4B`$g=d`Cagi4$3Y^kI z@iF(HE1<{JEN}!Z+&j_BHO9Ff!w}aL;>hyrY$Aa*^y4uG@B}CE6iIAh5I-^N7o5Vc z7{(tM5h_lLPMi__I4dsToVd;_o5!eFMoc*95f3pTKH*pN5iW^OF)2Rh{sqrp;OZ;DeW%;ZvN<8BcVK;<8U?ZMpu diff --git a/src/Game.java b/src/Game.java index 0da0e2e..011d1de 100644 --- a/src/Game.java +++ b/src/Game.java @@ -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; diff --git a/src/Map.java b/src/Map.java index d7872c8..94fa77d 100644 --- a/src/Map.java +++ b/src/Map.java @@ -7,15 +7,21 @@ import java.io.FileReader; 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]; + 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); }