diff --git a/assets/Maps/Flocke.txt b/assets/Maps/Flocke.txt new file mode 100644 index 0000000..ff1b231 --- /dev/null +++ b/assets/Maps/Flocke.txt @@ -0,0 +1,27 @@ +########################### +############# ############# +############ ############ +########### # ########### +####0 ## ### ## 1#### +#### ## ### # ### ## #### +#### ## #.## ##.# ## #### +#### ### ### #### +####### # #,# #,# # ####### +######. ### ### .###### +#### #### ## ## #### #### +### ##,# #,## ### +## # #### #.# #### # ## +#L ### # ### R# +## # #### #P# #### # ## +### ##,# #,## ### +#### #### ## ## #### #### +######. ### ### .###### +####### # #,# #,# # ####### +#### ### ### #### +#### ## #.## ##.# ## #### +#### ## ### # ### ## #### +####2 ## ### ## 3#### +########### # ########### +############ ############ +############# ############# +########################### \ No newline at end of file diff --git a/assets/Pacman_Down1.png b/assets/Pacman_Down1.png new file mode 100644 index 0000000..10f3cbf Binary files /dev/null and b/assets/Pacman_Down1.png differ diff --git a/assets/Pacman_Down3.png b/assets/Pacman_Down3.png new file mode 100644 index 0000000..dcbf6c5 Binary files /dev/null and b/assets/Pacman_Down3.png differ diff --git a/assets/Pacman_Left1.png b/assets/Pacman_Left1.png new file mode 100644 index 0000000..d8def92 Binary files /dev/null and b/assets/Pacman_Left1.png differ diff --git a/assets/Pacman_Left3.png b/assets/Pacman_Left3.png new file mode 100644 index 0000000..5377f77 Binary files /dev/null and b/assets/Pacman_Left3.png differ diff --git a/assets/Pacman_Right1.png b/assets/Pacman_Right1.png new file mode 100644 index 0000000..7c8905f Binary files /dev/null and b/assets/Pacman_Right1.png differ diff --git a/assets/Pacman_Right3.png b/assets/Pacman_Right3.png new file mode 100644 index 0000000..697f6b9 Binary files /dev/null and b/assets/Pacman_Right3.png differ diff --git a/assets/Pacman_Up1.png b/assets/Pacman_Up1.png new file mode 100644 index 0000000..e9d2840 Binary files /dev/null and b/assets/Pacman_Up1.png differ diff --git a/assets/Pacman_Up3.png b/assets/Pacman_Up3.png new file mode 100644 index 0000000..8bec83d Binary files /dev/null and b/assets/Pacman_Up3.png differ diff --git a/assets/Pacman_full.png b/assets/Pacman_full.png new file mode 100644 index 0000000..dcbf6c5 Binary files /dev/null and b/assets/Pacman_full.png differ diff --git a/assets/feared.png b/assets/feared.png index c68d520..de1074d 100644 Binary files a/assets/feared.png and b/assets/feared.png differ diff --git a/bin/Game.class b/bin/Game.class index 5844c8f..c39be55 100644 Binary files a/bin/Game.class and b/bin/Game.class differ diff --git a/bin/Player.class b/bin/Player.class index 56c9ae4..f259955 100644 Binary files a/bin/Player.class and b/bin/Player.class differ diff --git a/src/Game.java b/src/Game.java index b29831e..2eca0a9 100644 --- a/src/Game.java +++ b/src/Game.java @@ -153,7 +153,8 @@ public class Game { // ----------------------------------------------------------------------------------------------------------------------------------------------------- while (true) { // Hauptschleife - + + for (int i = 0; i < ghosts.length; i++) { if (ghosts[i].getIsDead()) { if (ghosts[i].getDeathTimer() != 0) { diff --git a/src/Player.java b/src/Player.java index 113b02e..5eaf338 100644 --- a/src/Player.java +++ b/src/Player.java @@ -35,7 +35,9 @@ public class Player extends Picture implements KeyListener { // extends Picture public boolean pressed_down; public boolean hui; // Boolean zur Abfrage, ob gerade ein Brick im Weg ist, um den aktuellen - // Richtungsbefehl durchzuführen. + + private int movingTicks; + // Richtungsbefehl durchzuführen. public Player() { // Erstellen des Konstruktors @@ -77,8 +79,8 @@ public class Player extends Picture implements KeyListener { // extends Picture pressed_up = false; pressed_down = false; - // und Pac-Man schaut jetzt nach links - this.changeSauce("Pacman_Left"); + + } else { // ansonsten: // soll Pac-Man sich sobald er kann nach links bewegen @@ -115,7 +117,10 @@ public class Player extends Picture implements KeyListener { // extends Picture pressed_right = false; pressed_up = false; pressed_down = false; - this.changeSauce("Pacman_Right"); + + + + } else { pressed_left = false; pressed_right = true; @@ -146,7 +151,7 @@ public class Player extends Picture implements KeyListener { // extends Picture pressed_right = false; pressed_up = false; pressed_down = false; - this.changeSauce("Pacman_Up"); + } else { pressed_left = false; pressed_right = false; @@ -177,7 +182,7 @@ public class Player extends Picture implements KeyListener { // extends Picture pressed_right = false; pressed_up = false; pressed_down = false; - this.changeSauce("Pacman_Down"); + } else { pressed_left = false; pressed_right = false; @@ -216,15 +221,19 @@ public class Player extends Picture implements KeyListener { // extends Picture if (coordinate == 'x') { // Auslesen der 'x' - Koordinate: if (left && dt != 0) { xPos -= speed * dt; + animate("Left"); } else if (right && dt != 0) { xPos += speed * dt; + animate("Right"); } return (int) xPos; } else if (coordinate == 'y') { // Auslesen der 'y' - Koordinate: if (down && dt != 0) { yPos += speed * dt; + animate("Down"); } else if (up && dt != 0) { yPos -= speed * dt; + animate("Up"); } return (int) yPos; } else { @@ -243,4 +252,60 @@ public class Player extends Picture implements KeyListener { // extends Picture } -} \ No newline at end of file + private void animate(String Dir) { + this.movingTicks++; + int aniFrames; + aniFrames = ((this.movingTicks + 1) % 125 / 25); + + if (Dir == "Left") { + if (aniFrames == 1 || aniFrames == 5) { + this.changeSauce("Pacman_Left1"); + + } else if (aniFrames == 2 || aniFrames == 4) { + this.changeSauce("Pacman_Left"); + + } else if (aniFrames == 3) { + this.changeSauce("Pacman_Left3"); + + } + + }if (Dir == "Right") { + if (aniFrames == 1 || aniFrames == 5) { + this.changeSauce("Pacman_Right1"); + + } else if (aniFrames == 2 || aniFrames == 4) { + this.changeSauce("Pacman_Right"); + + } else if (aniFrames == 3) { + this.changeSauce("Pacman_Right3"); + + } + + }if (Dir == "Up") { + if (aniFrames == 1 || aniFrames == 5) { + this.changeSauce("Pacman_Up1"); + + } else if (aniFrames == 2 || aniFrames == 4) { + this.changeSauce("Pacman_Up"); + + } else if (aniFrames == 3) { + this.changeSauce("Pacman_Up3"); + + } + + }if (Dir == "Down") { + if (aniFrames == 1 || aniFrames == 5) { + this.changeSauce("Pacman_Down1"); + + } else if (aniFrames == 2 || aniFrames == 4) { + this.changeSauce("Pacman_Down"); + + } else if (aniFrames == 3) { + this.changeSauce("Pacman_Down3"); + + } + + } + + } +}