From 2ac42aaa1071132c03a7fd88997acc50ce90fd79 Mon Sep 17 00:00:00 2001 From: Lenz Date: Sun, 10 May 2020 14:25:46 +0200 Subject: [PATCH] Essentieller Bugfix: Richtung wurde vor Blockkollision berechnet --- bin/.gitignore | 8 +------- bin/Brick.class | Bin 450 -> 450 bytes bin/Game.class | Bin 3615 -> 3707 bytes bin/Ghost.class | Bin 884 -> 884 bytes bin/Main.class | Bin 558 -> 558 bytes bin/Map.class | Bin 1968 -> 1968 bytes bin/Picture.class | Bin 1415 -> 1415 bytes bin/Player.class | Bin 3510 -> 3510 bytes src/Game.java | 8 +++++++- src/Player.java | 2 +- 10 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bin/.gitignore b/bin/.gitignore index 66d1c8e..7cf58ac 100644 --- a/bin/.gitignore +++ b/bin/.gitignore @@ -1,7 +1 @@ -/Brick.class -/Game.class -/Ghost.class -/Main.class -/Map.class -/Picture.class -/Player.class +/assets/ diff --git a/bin/Brick.class b/bin/Brick.class index ab70c40bd0c0b52d543c4a64f05cd6c6829b86d7..50ef0edbf9e3ab3e130be745f874a171441c4509 100644 GIT binary patch delta 17 ZcmX@ae2AIj)W2Q(7#J8VH*)M^1OPzQ27mwn delta 17 ZcmX@ae2AIj)W2Q(7#JALH*)M^1OPzG27Ukl diff --git a/bin/Game.class b/bin/Game.class index 4708f0bf7c1e3d506fc7722f6021ad859f3c3f48..9625daac4228185ac5dd8dc39548ce0735268843 100644 GIT binary patch delta 778 zcmaKq-%C?r7{|Zw`<(ss96Fdr=&6W;eh>!3h^!U#(=Ln=Vc?bKtgWV7+sv7(5o)*$ z3r+}9I<@IhvzBe`!i%7&LEQy)+lA17&_!g7&T+baFuHo5_xnDd@ArA(Nhr&T^+SH~ z6@UW^)-$G<4GttkjAMd9@U>kGGq5JRE8RH2O6WGe*BD z=)L3#8_JxBCx*g11IG2Kh-WK?Zhu#YVfI|a0vZ`Ctu4OR&>*5{bjzx1?*ShRr8uHk>g z=-*hwBgOFe@9mA^-je?*9XL70C- zCs}Zf)}f0OM96_|I)UrdfF5c>lmfUxy|_t(@X`Z#XcV_;3IjBUIOTAMmM}wL!O1z*b!Bh_EswF7T#e!7~jf5$mta)O+6<$Wa%da fwv3e1S;v3CTCNUDN2G@^;Sp>Yg@lBVripEjZIBb``8q1 zDpt_VU?m`}sgG%EYT71d;i8~u7A^!4SAupU=t^|iNO1nfC%8NJobNv1R*Wgb^|Jb8 z8NjYZ*AaO{fr%*=F~?1)XBIl&i^&7ir~`A=5~_t$nkM%Koq8an%5wEGV_Ya>)ca}H{)DBc6VrsQnw zs73hJIPppTYufyzkG8zkv7QuG!5RK-Q^!2mZf$o&}N9T?^Z z5#>Qd_;Fn3r!dNgk>(Q^<4d^0U*Rf$hjIQ1*Z3DFui(1G8gLBHoTHAyB|c=uv=(nO zYsCw!2O~f8q3kH)C#?m|)V<#!u?lVn0zO)WOR>Ib9okLEn1CC%pdn-JX=wieHK(d7 diff --git a/bin/Ghost.class b/bin/Ghost.class index 7370743746f2b3708a815e4afa8793a836113878..8a1f87db94d95317c6dc4b3e7f7073146a82e0f0 100644 GIT binary patch delta 17 Zcmeyu_Jxh()W2Q(7#J8VH*(}K0{}+V2A%)_ delta 17 Zcmeyu_Jxh()W2Q(7#JALH*(}K0{}+L2Alu@ diff --git a/bin/Main.class b/bin/Main.class index 49bb040df2259487927094198c88d25036d4aa75..1a833566a526260096197e0752201ee1225efe0a 100644 GIT binary patch delta 17 ZcmZ3-vW|u0)W2Q(7#J8VH*%;k0RTNr1;+pY delta 17 ZcmZ3-vW|u0)W2Q(7#JALH*%;k0RTNh1;qdW diff --git a/bin/Map.class b/bin/Map.class index 6751556aa4c313167a57050d266c710a7cd8daf3..bba024803145b8b86e7fdc8432ce5ca91f14b54e 100644 GIT binary patch delta 17 ZcmdnMzk#3Q)W2Q(7#J8VH*&0C2LM0c250~P delta 17 ZcmdnMzk#3Q)W2Q(7#JALH*&0C2LM0S24(;N diff --git a/bin/Picture.class b/bin/Picture.class index a4b2415ffb7d46524ae90fabac2d10bd2a48127d..f720bca0ebe0c6c5649446ce9cce8fd8400937c9 100644 GIT binary patch delta 17 YcmZqYZs+DW^>5cc1_lPpjU4r?06Fso;{X5v delta 17 YcmZqYZs+DW^>5cc1_lQ6jU4r?06FOe;Q#;t diff --git a/bin/Player.class b/bin/Player.class index 0b774a0a1a2df55521c4233622183ca94bfbde63..b5fa448688f1fdefe0426cbeedbba754639ffa0f 100644 GIT binary patch delta 17 Zcmdlcy-k|q)W2Q(7#J8VH*&1w1pq=B2ABW< delta 17 Zcmdlcy-k|q)W2Q(7#JALH*&1w1pq=129^K- diff --git a/src/Game.java b/src/Game.java index 0ea4bf0..d579ff6 100644 --- a/src/Game.java +++ b/src/Game.java @@ -98,7 +98,7 @@ public class Game { ghosts[i].setLocation(ghosts[i].getPos('x', dt), ghosts[i].getPos('y', dt)); } - player.calcDir(0); // Berechnen wo Pac-Man als nächstes hin soll + // Kollision von Pac-Man mit Bricks: for (int i = 0; i < 35; i++) { // für jeden Brick @@ -110,15 +110,19 @@ public class Game { && player.getPos('y', 0) > Map.bricks[j][i].yPos - 20) { if (player.left) { player.setPos('x', Map.bricks[j][i].xPos + 20); + player.setPos('y', Map.bricks[j][i].yPos); player.left = false; } else if (player.right) { player.setPos('x', Map.bricks[j][i].xPos - 20); + player.setPos('y', Map.bricks[j][i].yPos); player.right = false; } else if (player.up) { player.setPos('y', Map.bricks[j][i].yPos + 20); + player.setPos('x', Map.bricks[j][i].xPos); player.up = false; } else if (player.down) { player.setPos('y', Map.bricks[j][i].yPos - 20); + player.setPos('x', Map.bricks[j][i].xPos); player.down = false; } @@ -126,6 +130,8 @@ public class Game { } } } + + player.calcDir(0); // Berechnen wo Pac-Man als nächstes hin soll for (int i = 0; i < ghosts.length; i++) { if (player.getPos('x', 0) < ghosts[i].getPos('x', 0) + 20 diff --git a/src/Player.java b/src/Player.java index 6b0879f..12b7618 100644 --- a/src/Player.java +++ b/src/Player.java @@ -53,7 +53,7 @@ public class Player extends Picture implements KeyListener { // extends Picture if (keyCode == 37 || pressed_left && System.currentTimeMillis() - timer <= blob) { for (int i = 0; i < 35; i++) { // für jeden Brick - for (int j = 0; j < 35; j++) { // für jeden Bick + for (int j = 0; j < 35; j++) { // für jeden Brick if (Map.bricks[j][i] != null) { // Damit kein Fehler auftritt wegen nicht vorhandenen Bricks if (Map.bricks[j][i].xPos + 20 == (int) xPos && (int) yPos < Map.bricks[j][i].yPos + 20 && (int) yPos > Map.bricks[j][i].yPos - 20) { // wenn Pac-Man gerade rechts an einem