animationen für pacman
|
@ -0,0 +1,27 @@
|
||||||
|
###########################
|
||||||
|
############# #############
|
||||||
|
############ ############
|
||||||
|
########### # ###########
|
||||||
|
####0 ## ### ## 1####
|
||||||
|
#### ## ### # ### ## ####
|
||||||
|
#### ## #.## ##.# ## ####
|
||||||
|
#### ### ### ####
|
||||||
|
####### # #,# #,# # #######
|
||||||
|
######. ### ### .######
|
||||||
|
#### #### ## ## #### ####
|
||||||
|
### ##,# #,## ###
|
||||||
|
## # #### #.# #### # ##
|
||||||
|
#L ### # ### R#
|
||||||
|
## # #### #P# #### # ##
|
||||||
|
### ##,# #,## ###
|
||||||
|
#### #### ## ## #### ####
|
||||||
|
######. ### ### .######
|
||||||
|
####### # #,# #,# # #######
|
||||||
|
#### ### ### ####
|
||||||
|
#### ## #.## ##.# ## ####
|
||||||
|
#### ## ### # ### ## ####
|
||||||
|
####2 ## ### ## 3####
|
||||||
|
########### # ###########
|
||||||
|
############ ############
|
||||||
|
############# #############
|
||||||
|
###########################
|
After Width: | Height: | Size: 257 B |
After Width: | Height: | Size: 227 B |
After Width: | Height: | Size: 255 B |
After Width: | Height: | Size: 225 B |
After Width: | Height: | Size: 250 B |
After Width: | Height: | Size: 226 B |
After Width: | Height: | Size: 257 B |
After Width: | Height: | Size: 230 B |
After Width: | Height: | Size: 227 B |
Before Width: | Height: | Size: 505 B After Width: | Height: | Size: 517 B |
BIN
bin/Game.class
BIN
bin/Player.class
|
@ -153,7 +153,8 @@ public class Game {
|
||||||
// -----------------------------------------------------------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
while (true) { // Hauptschleife
|
while (true) { // Hauptschleife
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < ghosts.length; i++) {
|
for (int i = 0; i < ghosts.length; i++) {
|
||||||
if (ghosts[i].getIsDead()) {
|
if (ghosts[i].getIsDead()) {
|
||||||
if (ghosts[i].getDeathTimer() != 0) {
|
if (ghosts[i].getDeathTimer() != 0) {
|
||||||
|
|
|
@ -35,7 +35,9 @@ public class Player extends Picture implements KeyListener { // extends Picture
|
||||||
public boolean pressed_down;
|
public boolean pressed_down;
|
||||||
|
|
||||||
public boolean hui; // Boolean zur Abfrage, ob gerade ein Brick im Weg ist, um den aktuellen
|
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
|
public Player() { // Erstellen des Konstruktors
|
||||||
|
|
||||||
|
@ -77,8 +79,8 @@ public class Player extends Picture implements KeyListener { // extends Picture
|
||||||
pressed_up = false;
|
pressed_up = false;
|
||||||
pressed_down = false;
|
pressed_down = false;
|
||||||
|
|
||||||
// und Pac-Man schaut jetzt nach links
|
|
||||||
this.changeSauce("Pacman_Left");
|
|
||||||
} else { // ansonsten:
|
} else { // ansonsten:
|
||||||
|
|
||||||
// soll Pac-Man sich sobald er kann nach links bewegen
|
// 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_right = false;
|
||||||
pressed_up = false;
|
pressed_up = false;
|
||||||
pressed_down = false;
|
pressed_down = false;
|
||||||
this.changeSauce("Pacman_Right");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
pressed_left = false;
|
pressed_left = false;
|
||||||
pressed_right = true;
|
pressed_right = true;
|
||||||
|
@ -146,7 +151,7 @@ public class Player extends Picture implements KeyListener { // extends Picture
|
||||||
pressed_right = false;
|
pressed_right = false;
|
||||||
pressed_up = false;
|
pressed_up = false;
|
||||||
pressed_down = false;
|
pressed_down = false;
|
||||||
this.changeSauce("Pacman_Up");
|
|
||||||
} else {
|
} else {
|
||||||
pressed_left = false;
|
pressed_left = false;
|
||||||
pressed_right = false;
|
pressed_right = false;
|
||||||
|
@ -177,7 +182,7 @@ public class Player extends Picture implements KeyListener { // extends Picture
|
||||||
pressed_right = false;
|
pressed_right = false;
|
||||||
pressed_up = false;
|
pressed_up = false;
|
||||||
pressed_down = false;
|
pressed_down = false;
|
||||||
this.changeSauce("Pacman_Down");
|
|
||||||
} else {
|
} else {
|
||||||
pressed_left = false;
|
pressed_left = false;
|
||||||
pressed_right = 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 (coordinate == 'x') { // Auslesen der 'x' - Koordinate:
|
||||||
if (left && dt != 0) {
|
if (left && dt != 0) {
|
||||||
xPos -= speed * dt;
|
xPos -= speed * dt;
|
||||||
|
animate("Left");
|
||||||
} else if (right && dt != 0) {
|
} else if (right && dt != 0) {
|
||||||
xPos += speed * dt;
|
xPos += speed * dt;
|
||||||
|
animate("Right");
|
||||||
}
|
}
|
||||||
return (int) xPos;
|
return (int) xPos;
|
||||||
} else if (coordinate == 'y') { // Auslesen der 'y' - Koordinate:
|
} else if (coordinate == 'y') { // Auslesen der 'y' - Koordinate:
|
||||||
if (down && dt != 0) {
|
if (down && dt != 0) {
|
||||||
yPos += speed * dt;
|
yPos += speed * dt;
|
||||||
|
animate("Down");
|
||||||
} else if (up && dt != 0) {
|
} else if (up && dt != 0) {
|
||||||
yPos -= speed * dt;
|
yPos -= speed * dt;
|
||||||
|
animate("Up");
|
||||||
}
|
}
|
||||||
return (int) yPos;
|
return (int) yPos;
|
||||||
} else {
|
} else {
|
||||||
|
@ -243,4 +252,60 @@ public class Player extends Picture implements KeyListener { // extends Picture
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
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");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|