From d910b4a191730bf036518001240de17073757463 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 7 Jun 2020 15:42:46 +0200 Subject: [PATCH] =?UTF-8?q?geister=20t=C3=B6ten=20mit=20respawn=20zeit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/Map.txt | 4 +- bin/.gitignore | 10 --- bin/BigPoint.class | Bin 462 -> 462 bytes bin/Brick.class | Bin 450 -> 450 bytes bin/Game.class | Bin 9141 -> 9488 bytes bin/Ghost.class | Bin 2254 -> 2665 bytes bin/Lives.class | Bin 336 -> 336 bytes bin/Main.class | Bin 558 -> 558 bytes bin/Map.class | Bin 2579 -> 2579 bytes bin/Picture.class | Bin 1415 -> 1415 bytes bin/Player.class | Bin 3510 -> 3510 bytes bin/Point.class | Bin 450 -> 450 bytes src/Game.java | 212 +++++++++++++++++++++++++-------------------- src/Ghost.java | 22 ++++- 14 files changed, 142 insertions(+), 106 deletions(-) delete mode 100644 bin/.gitignore diff --git a/assets/Map.txt b/assets/Map.txt index 7e17f76..b30ecb7 100644 --- a/assets/Map.txt +++ b/assets/Map.txt @@ -5,7 +5,7 @@ # # # #### ## ######## ## #### # # #### ## ######## ## #### # -# ## ## ## # +# ##. ## .## # ###### ##### ## ##### ###### ,,,,,# ##### ## ##### #,,,,, ,,,,,# ## ## #,,,,, @@ -23,7 +23,7 @@ #. ## P ## .# ### ## ## ######## ## ## ### ### ## ## ######## ## ## ### -# ## ## ## # +# ## .##. ## # # ########## ## ########## # # ########## ## ########## # # # diff --git a/bin/.gitignore b/bin/.gitignore deleted file mode 100644 index 0007eb6..0000000 --- a/bin/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/BigPoint.class -/Brick.class -/Game.class -/Ghost.class -/Lives.class -/Main.class -/Map.class -/Picture.class -/Player.class -/Point.class diff --git a/bin/BigPoint.class b/bin/BigPoint.class index b34987faece3c7e4d3c11036fc1337611a71e15a..c92c3e06eeaec83925b7199c7c584bffba0ffa5e 100644 GIT binary patch delta 17 ZcmX@de2$sp)W2Q(7#J8#HgX(e1OP%*2A==` delta 17 ZcmX@de2$sp)W2Q(7#J8VH*y?f1OP&92BZK0 diff --git a/bin/Brick.class b/bin/Brick.class index 50ef0edbf9e3ab3e130be745f874a171441c4509..98f1c69aeacb64cc67c5adfd0911ce8b54b732c9 100644 GIT binary patch delta 17 ZcmX@ae2AIj)W2Q(7#J8#HgfD@1OPz1273Si delta 17 ZcmX@ae2AIj)W2Q(7#J8VH*)M^1OPzQ27mwn diff --git a/bin/Game.class b/bin/Game.class index fee8ec6ba16bce5864bb25463097b12ed6eb661d..5917123d7282829ace9d332e5413a9291f729f43 100644 GIT binary patch delta 4314 zcma)9d3aRS6+gduZ{C~t=FQ85B*ZL0!XimnBGH2ECWIv*2q6swR5Hm7NiZZK2@tF} zicwGykyn-=3i{DTL9jwHB2ns65K*yM{j8L_wE8JU#f4fymYzE^NhX!guk**7bAI>y z&bjy8bGO!s>n7_*FC92YMAu={v-(&^u}=B)AA^3Rb0DqESD#mx>+^U)Qd;^P(e{%; z7w96$#ckYDUtUnL&{rF5&lByJ4G`_%_PWS+jn2SkK!R))YCRn~6gX6<*3J4=eodIG zHMJF0^_5lZ0!{-4ZRYUoA{1VumtY!*qEwJxR$g6KKd+{`ZniLvHqZ?*Acc*mSJ#2; zY2)(J3k4(2K=-bUB8`Bn4C+ZS8gmm3B*CA|jXRFI*dKQ=Zgtxv1MUh*l*<=Z7e}mpf8atYxb7O{q0T>99ORKAv@L$@5^gLlT z*r0cjCTDLZl4G({_?x|*NQAi7z;*bQ^|hmyf0%*m!JV@$t`VFO21W{1_Es;g62NE! zV}d}XZ+^W1ZZME70DEmkSve!KF`D~@Xd&GoKEuRkgig0$l7T$R<&kjK3VaRq4kU@_ zHyW5KU}tH$XMRsgVR*%sVvQ{sAXfaRLlg$FYqk!WLA2r$}(rx^Bk7t zEUu{Z`f45cHTPtqucEGAM?Q_?4`v%E!W>Swr>4eN#pzB?%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AAYiqiB*x6$n5ImKSF1w|1&y%m*~C~oPQNP zdVO26(GND=TLiH#AvgzLy$bO!YR^yqtwS%NUr)p^*~}FGQ&+7yc9n1w57&6F?tIR0 zB7u{f&r{sT(>TF7%TnIK8JPSlyvqsw0)6p{6_gFE{G8NMGpqV z1m$fEifMj2KgEz(qkMw2nze*GF`Kg{p5Z2L$yuXzTg{r(?oew`Q@0bo=g^eAl@0 z<7{1)^-N+EH~4RG6GgVc#uPq-jz`F235A!Iba}IJSbnjj%P0}iUD6=@@ebeN4*A)f JXD$!Qe*w}ys-6G< diff --git a/bin/Lives.class b/bin/Lives.class index a774fe7227a5093795f4bdc097b27c0758fd5aac..f55526beed0d1cfeb5643b0c06597ee68f27791c 100644 GIT binary patch delta 17 Zcmcb>bb*QE)W2Q(7#J8#Hgb3{0sujJ1|t9f delta 17 Zcmcb>bb*QE)W2Q(7#J8VH*$C|0suji1}Fdk diff --git a/bin/Main.class b/bin/Main.class index 1a833566a526260096197e0752201ee1225efe0a..ef3f06657c480cca5388e7e157aa4fac9de8cadb 100644 GIT binary patch delta 17 ZcmZ3-vW|u0)W2Q(7#J8#Hgc#j0RTNS1;PLT delta 17 ZcmZ3-vW|u0)W2Q(7#J8VH*%;k0RTNr1;+pY diff --git a/bin/Map.class b/bin/Map.class index a288e72498e3c92c120a0bba09a85d96296c96d5..6541853c6cdb6e9ef6d43c5252a331c0aa8d7a4a 100644 GIT binary patch delta 17 ZcmbO%GFgP<)W2Q(7#J8#Hga%t0RTIN1(^T< delta 17 ZcmbO%GFgP<)W2Q(7#J8VH*#=u0RTIm1)cx^ diff --git a/bin/Picture.class b/bin/Picture.class index f720bca0ebe0c6c5649446ce9cce8fd8400937c9..3737254b48ab4d6c68bbddd077d0d3181feadfaa 100644 GIT binary patch delta 17 YcmZqYZs+DW^>5cc1_lO`jU4r?06E$P-T(jq delta 17 YcmZqYZs+DW^>5cc1_lPpjU4r?06Fso;{X5v diff --git a/bin/Player.class b/bin/Player.class index daa323be927ba65b345a866a938d35138a59061d..56c9ae4972f3b46b05750493d0c09f33c2d20359 100644 GIT binary patch delta 17 Zcmdlcy-k|q)W2Q(7#J8#Hgc@v1pq<-29p2) delta 17 Zcmdlcy-k|q)W2Q(7#J8VH*&1w1pq=B2ABW< diff --git a/bin/Point.class b/bin/Point.class index 8431eb4f27183e89c735743c2bdefd60096aaf98..b8638393998373e6a872051e8c999c230e39952b 100644 GIT binary patch delta 17 ZcmX@ae2AIj)W2Q(7#J8#HgfD@1OPz1273Si delta 17 ZcmX@ae2AIj)W2Q(7#J8VH*)M^1OPzQ27mwn diff --git a/src/Game.java b/src/Game.java index c845e2d..d638797 100644 --- a/src/Game.java +++ b/src/Game.java @@ -133,12 +133,36 @@ public class Game { } } } - + delay(30); lastT = System.nanoTime(); // delta time - + frame.setVisible(true); + + // ----------------------------------------------------------------------------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------------------------------------------------------------- + while (true) { // Hauptschleife + + for (int i = 0; i < ghosts.length; i++) { + if (ghosts[i].getIsDead()) { + if (ghosts[i].getDeathTimer() != 0) { + ghosts[i].setDeathTimer(ghosts[i].getDeathTimer() - 1); + System.out.println(ghosts[i].getDeathTimer()); + } else { + ghosts[i].setIsDead(false); + ghosts[i].setPos('x', Map.ghost_posX[i]); + ghosts[i].setPos('y', Map.ghost_posY[i]); + + + } + } + } + frames++; if (ghosts[0].feared == true) { if (Ghost.fearedTimer != 0) { @@ -159,102 +183,103 @@ public class Game { player.setLocation(player.getPos('x', dt), player.getPos('y', dt)); for (int i = 0; i < ghosts.length; i++) { + if (!ghosts[i].getIsDead()) { + ghost_possible[i][0] = false; + ghost_possible[i][1] = false; + ghost_possible[i][2] = false; + ghost_possible[i][3] = false; - ghost_possible[i][0] = false; - ghost_possible[i][1] = false; - ghost_possible[i][2] = false; - ghost_possible[i][3] = false; + if ((Map.bricks[conv(ghosts[i].yPos)][conv(ghosts[i].xPos) + 1] == null + && Map.bricks[conv(ghosts[i].yPos + 19)][conv(ghosts[i].xPos) + 1] == null) + || (ghosts[i].xPos + 10) % 20 != 0) { + ghost_possible[i][0] = true; - if ((Map.bricks[conv(ghosts[i].yPos)][conv(ghosts[i].xPos) + 1] == null - && Map.bricks[conv(ghosts[i].yPos + 19)][conv(ghosts[i].xPos) + 1] == null) - || (ghosts[i].xPos + 10) % 20 != 0) { - ghost_possible[i][0] = true; - - } - if ((Map.bricks[conv(ghosts[i].yPos)][conv(ghosts[i].xPos) - 1] == null - && Map.bricks[conv(ghosts[i].yPos + 19)][conv(ghosts[i].xPos) - 1] == null) - || (ghosts[i].xPos + 10) % 20 != 0) { - ghost_possible[i][1] = true; - - } - if ((Map.bricks[conv(ghosts[i].yPos) - 1][conv(ghosts[i].xPos)] == null - && Map.bricks[conv(ghosts[i].yPos) - 1][conv(ghosts[i].xPos + 19)] == null) - || (ghosts[i].yPos + 10) % 20 != 0) { - ghost_possible[i][2] = true; - } - if ((Map.bricks[conv(ghosts[i].yPos) + 1][conv(ghosts[i].xPos)] == null - && Map.bricks[conv(ghosts[i].yPos) + 1][conv(ghosts[i].xPos + 19)] == null) - || (ghosts[i].yPos + 10) % 20 != 0) { - ghost_possible[i][3] = true; - } - - HCost[0] = ghosts[i].getHCost(player, 1, 0); - HCost[1] = ghosts[i].getHCost(player, -1, 0); - HCost[2] = ghosts[i].getHCost(player, 0, -1); - HCost[3] = ghosts[i].getHCost(player, 0, 1); - // - int minn = 10000; - - if (ghosts[i].up == true) { - HCost[3] = 10000; - } - if (ghosts[i].down == true) { - HCost[2] = 10000; - } - if (ghosts[i].left == true) { - HCost[0] = 10000; - } - if (ghosts[i].right == true) { - HCost[1] = 10000; - } - - for (int j = 0; j < 4; j++) { - if (ghost_possible[i][j] == false) { - HCost[j] = 10500; } - } + if ((Map.bricks[conv(ghosts[i].yPos)][conv(ghosts[i].xPos) - 1] == null + && Map.bricks[conv(ghosts[i].yPos + 19)][conv(ghosts[i].xPos) - 1] == null) + || (ghosts[i].xPos + 10) % 20 != 0) { + ghost_possible[i][1] = true; - for (int j = 0; j < 4; j++) { - if (minn > HCost[j]) { - minn = HCost[j]; } - } - System.out.println(HCost[0]+ " "+HCost[1]+ " "+ HCost[2] + " "+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 ((Map.bricks[conv(ghosts[i].yPos) - 1][conv(ghosts[i].xPos)] == null + && Map.bricks[conv(ghosts[i].yPos) - 1][conv(ghosts[i].xPos + 19)] == null) + || (ghosts[i].yPos + 10) % 20 != 0) { + ghost_possible[i][2] = true; + } + if ((Map.bricks[conv(ghosts[i].yPos) + 1][conv(ghosts[i].xPos)] == null + && Map.bricks[conv(ghosts[i].yPos) + 1][conv(ghosts[i].xPos + 19)] == null) + || (ghosts[i].yPos + 10) % 20 != 0) { + ghost_possible[i][3] = true; + } + + HCost[0] = ghosts[i].getHCost(player, 1, 0); + HCost[1] = ghosts[i].getHCost(player, -1, 0); + HCost[2] = ghosts[i].getHCost(player, 0, -1); + HCost[3] = ghosts[i].getHCost(player, 0, 1); + // + int minn = 10000; + + if (ghosts[i].up == true) { + HCost[3] = 10000; + } + if (ghosts[i].down == true) { + HCost[2] = 10000; + } + if (ghosts[i].left == true) { + HCost[0] = 10000; + } + if (ghosts[i].right == true) { + HCost[1] = 10000; + } + + for (int j = 0; j < 4; j++) { + if (ghost_possible[i][j] == false) { + HCost[j] = 10500; } } - } + for (int j = 0; j < 4; j++) { + if (minn > HCost[j]) { + minn = HCost[j]; + } + } + // System.out.println(HCost[0] + " " + HCost[1] + " " + HCost[2] + " " + + // 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; + } + } + } + + } } - // Kollision von Pac-Man mit Bricks: for (int i = 0; i < 35; i++) { // für jeden Brick for (int j = 0; j < 35; j++) { // für jeden Brick @@ -363,10 +388,13 @@ public class Game { && player.getPos('y', 0) < ghosts[i].getPos('y', 0) + 20 && player.getPos('y', 0) > ghosts[i].getPos('y', 0) - 20) if (ghosts[0].feared) { - - ghosts[i].setPos('x', Map.ghost_posX[i]); - ghosts[i].setPos('y', Map.ghost_posY[i]); + ghosts[i].setIsDead(true); + ghosts[i].setDeathTimer(1000); + ghosts[i].setPos('x', -100); + ghosts[i].setPos('y', -100); score += 1000; + System.out.println("Geist"+ i + " ist gestorben" + ghosts[i].getIsDead()); + } else { player.lives--; diff --git a/src/Ghost.java b/src/Ghost.java index 829aaaa..deeffa8 100644 --- a/src/Ghost.java +++ b/src/Ghost.java @@ -12,8 +12,10 @@ public class Ghost extends Picture { // Die public boolean left; public boolean right; - public boolean feared = false; + public boolean feared; public static int fearedTimer; + private int deathTimer; + private boolean isDead; private double HCost; private int type; @@ -36,7 +38,7 @@ public class Ghost extends Picture { // Die } else if (type == 1) { this.changeSauce("Pinky"); } - + } public void setPos(char coordinate, int newPos) { @@ -74,6 +76,22 @@ public class Ghost extends Picture { // Die } + public void setDeathTimer(int amount) { + this.deathTimer = amount; + } + + public int getDeathTimer() { + return (int) this.deathTimer; + } + + public void setIsDead(boolean b) { + this.isDead = b; + } + + public boolean getIsDead() { + return this.isDead; + } + public int getPos(char coordinate, long dt) { // Hier kommt die zuvor erwähnte delta time ins Spiel if (coordinate == 'x') { // Auslesen der 'x' - Koordinate: