change sauce und geister ki verändert

master
leventius imperatus 2020-06-07 14:09:46 +02:00
parent b909505fb1
commit 76bb289115
6 changed files with 101 additions and 62 deletions

7
bin/.gitignore vendored
View File

@ -1,3 +1,10 @@
/BigPoint.class /BigPoint.class
/Brick.class
/Game.class
/Ghost.class
/Lives.class /Lives.class
/Main.class
/Map.class
/Picture.class
/Player.class
/Point.class /Point.class

Binary file not shown.

Binary file not shown.

View File

@ -53,7 +53,6 @@ public class Game {
ImageIcon img = new ImageIcon("assets/Pacman_Right.png"); ImageIcon img = new ImageIcon("assets/Pacman_Right.png");
frame.setIconImage(img.getImage()); frame.setIconImage(img.getImage());
panel = new JPanel(); // darauf werden alle sichtbaren Elemente gespeichert panel = new JPanel(); // darauf werden alle sichtbaren Elemente gespeichert
ghosts = new Ghost[4]; // 4 Geister ghosts = new Ghost[4]; // 4 Geister
@ -147,6 +146,7 @@ public class Game {
} else { } else {
for (int i = 0; i < ghosts.length; i++) { for (int i = 0; i < ghosts.length; i++) {
ghosts[i].feared = false; ghosts[i].feared = false;
ghosts[i].ogSauce();
} }
} }
} }
@ -320,6 +320,32 @@ public class Game {
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
ghosts[i].feared = true; ghosts[i].feared = true;
Ghost.fearedTimer = 1000; Ghost.fearedTimer = 1000;
ghosts[i].changeSauce("feared");
if (ghosts[i].left) {
ghosts[i].right = true;
ghosts[i].left = false;
ghosts[i].down = false;
ghosts[i].up = false;
} else if (ghosts[i].right) {
ghosts[i].left = true;
ghosts[i].right = false;
ghosts[i].down = false;
ghosts[i].up = false;
} else if (ghosts[i].down) {
ghosts[i].up = true;
ghosts[i].right = false;
ghosts[i].left = false;
ghosts[i].down = false;
} else if (ghosts[i].up) {
ghosts[i].down = true;
ghosts[i].right = false;
ghosts[i].left = false;
ghosts[i].up = false;
}
} }
} }
@ -362,7 +388,6 @@ public class Game {
} }
} }
fps = 1000000000 / dt; fps = 1000000000 / dt;
// System.out.println("fps: " + fps); // System.out.println("fps: " + fps);
@ -394,8 +419,6 @@ public class Game {
} }
} }
// Methode zum verzögern (warten) in ms // Methode zum verzögern (warten) in ms
public void delay(int time) { public void delay(int time) {

View File

@ -16,19 +16,25 @@ public class Ghost extends Picture { // Die
public static int fearedTimer; public static int fearedTimer;
private double HCost; private double HCost;
private int type; private int type;
public Ghost(int type) {
public Ghost(int type) {
super("Pinky"); // Aufrufen der übergeordneten Klasse super("Pinky"); // Aufrufen der übergeordneten Klasse
this.type = type; this.type = type;
// xPos = 150 + 40 * index; // xPos = 150 + 40 * index;
this.ogSauce();
}
public void ogSauce() {
if (type == 0) { if (type == 0) {
this.changeSauce("Blinky"); this.changeSauce("Blinky");
} else if (type == 2) { } else if (type == 2) {
this.changeSauce("Inky"); this.changeSauce("Inky");
} else if (type == 3) { } else if (type == 3) {
this.changeSauce("Clyde"); this.changeSauce("Clyde");
} else if (type == 1) {
this.changeSauce("Pinky");
} }
} }
@ -48,7 +54,8 @@ public class Ghost extends Picture { // Die
HCost = (int) Math.sqrt(Math.pow((((xPos - 10) / 20) + mod_x) - ((player.getPos('x', 0) - 10) / 20), 2) HCost = (int) Math.sqrt(Math.pow((((xPos - 10) / 20) + mod_x) - ((player.getPos('x', 0) - 10) / 20), 2)
+ Math.pow((((yPos - 10) / 20) + mod_y) - ((player.getPos('y', 0) - 10) / 20), 2)); + Math.pow((((yPos - 10) / 20) + mod_y) - ((player.getPos('y', 0) - 10) / 20), 2));
} else if (type == 1) { } else if (type == 1) {
HCost = (int) Math.sqrt(Math.pow((((xPos - 10) / 20) + mod_x) - ((player.getPos('x', 0) - 10 + 80) / 20), 2) HCost = (int) Math
.sqrt(Math.pow((((xPos - 10) / 20) + mod_x) - ((player.getPos('x', 0) - 10 + 80) / 20), 2)
+ Math.pow((((yPos - 10) / 20) + mod_y) - ((player.getPos('y', 0) - 10) / 20), 2)); + Math.pow((((yPos - 10) / 20) + mod_y) - ((player.getPos('y', 0) - 10) / 20), 2));
} else if (type == 2) { } else if (type == 2) {
HCost = (int) Math.sqrt(Math.pow((((xPos - 10) / 20) + mod_x) - ((300 - 10 + 80) / 20), 2) HCost = (int) Math.sqrt(Math.pow((((xPos - 10) / 20) + mod_x) - ((300 - 10 + 80) / 20), 2)
@ -58,16 +65,15 @@ public class Ghost extends Picture { // Die
+ Math.pow((((yPos - 10) / 20) + mod_y) - ((player.getPos('y', 0) + 100 - 10) / 20), 2)); + Math.pow((((yPos - 10) / 20) + mod_y) - ((player.getPos('y', 0) + 100 - 10) / 20), 2));
} }
} } else {
else {
HCost = 10 * (1 / (Math.sqrt(Math.pow((((xPos - 10) / 20) + mod_x) - ((player.getPos('x', 0) - 10) / 20), 2) HCost = 10 * (1 / (Math.sqrt(Math.pow((((xPos - 10) / 20) + mod_x) - ((player.getPos('x', 0) - 10) / 20), 2)
+ Math.pow((((yPos - 10) / 20) + mod_y) - ((player.getPos('y', 0) - 10) / 20), 2)))); + Math.pow((((yPos - 10) / 20) + mod_y) - ((player.getPos('y', 0) - 10) / 20), 2))));
} }
return (int) HCost; return (int) HCost;
} }
public int getPos(char coordinate, long dt) { // Hier kommt die zuvor erwähnte delta time ins Spiel public int getPos(char coordinate, long dt) { // Hier kommt die zuvor erwähnte delta time ins Spiel
if (coordinate == 'x') { // Auslesen der 'x' - Koordinate: if (coordinate == 'x') { // Auslesen der 'x' - Koordinate:

View File

@ -1,6 +1,9 @@
public class Lives extends Picture{ public class Lives extends Picture{
private static final long serialVersionUID = -4715442447789971450L;
public Lives() { public Lives() {
super("heart"); super("heart");
} }