Berechnung in welche Richtung die Geister sich bewegen können hinzugefügt (Beginn vom Pathfinding)
parent
20d7d916da
commit
b43fb65fb3
|
@ -1,8 +1,8 @@
|
|||
###############################0###
|
||||
# # ##
|
||||
# # ############### ###############
|
||||
############################# #####
|
||||
# # # # 0 #
|
||||
# # ############### ######### #####
|
||||
# # # ## ### #####
|
||||
# # # ########## ### ##### #####
|
||||
# # # ########## ### ##########
|
||||
# # # ################# ##### #####
|
||||
# # # # #### ####
|
||||
# # # # #################### ######
|
||||
|
|
BIN
bin/Game.class
BIN
bin/Game.class
Binary file not shown.
BIN
bin/Ghost.class
BIN
bin/Ghost.class
Binary file not shown.
|
@ -41,7 +41,12 @@ public class Game {
|
|||
|
||||
panel = new JPanel(); // darauf werden alle sichtbaren Elemente gespeichert
|
||||
|
||||
ghosts = new Ghost[4]; // 4 Geister
|
||||
ghosts = new Ghost[1]; // 4 Geister
|
||||
|
||||
boolean[] ghost_up_possible = new boolean[ghosts.length];
|
||||
boolean[] ghost_down_possible = new boolean[ghosts.length];
|
||||
boolean[] ghost_left_possible = new boolean[ghosts.length];
|
||||
boolean[] ghost_right_possible = new boolean[ghosts.length];
|
||||
|
||||
player = new Player(); // Pac-Man
|
||||
|
||||
|
@ -103,7 +108,36 @@ public class Game {
|
|||
ghosts[i].setLocation(ghosts[i].getPos('x', dt), ghosts[i].getPos('y', dt));
|
||||
}
|
||||
|
||||
for (int i = 0; i < ghosts.length; i++) {
|
||||
|
||||
if (Map.bricks[((ghosts[i].getPos('y', 0) - 10) / 20) - 1][(ghosts[i].getPos('x', 0) - 10)
|
||||
/ 20] == null) {
|
||||
ghost_up_possible[i] = true;
|
||||
}
|
||||
if (Map.bricks[((ghosts[i].getPos('y', 0) - 10) / 20) + 1][(ghosts[i].getPos('x', 0) - 10)
|
||||
/ 20] == null) {
|
||||
ghost_down_possible[i] = true;
|
||||
}
|
||||
if (Map.bricks[(ghosts[i].getPos('y', 0) - 10) / 20][((ghosts[i].getPos('x', 0) - 10) / 20)
|
||||
- 1] == null) {
|
||||
ghost_left_possible[i] = true;
|
||||
}
|
||||
if (Map.bricks[(ghosts[i].getPos('y', 0) - 10) / 20][((ghosts[i].getPos('x', 0) - 10) / 20)
|
||||
+ 1] == null) {
|
||||
ghost_right_possible[i] = true;
|
||||
}
|
||||
|
||||
System.out.println("up: " + ghost_up_possible[i] + " | down: " + ghost_down_possible[i] + " | left: "
|
||||
+ ghost_left_possible[i] + " | right: " + ghost_right_possible[i]);
|
||||
|
||||
// System.out.println((ghosts[i].getPos('y', 0) - 10) / 20);
|
||||
|
||||
ghost_up_possible[i] = false;
|
||||
ghost_down_possible[i] = false;
|
||||
ghost_left_possible[i] = false;
|
||||
ghost_right_possible[i] = false;
|
||||
|
||||
}
|
||||
|
||||
// Kollision von Pac-Man mit Bricks:
|
||||
for (int i = 0; i < 35; i++) { // für jeden Brick
|
||||
|
|
|
@ -7,6 +7,10 @@ public class Ghost extends Picture { // Die
|
|||
private int xPos;
|
||||
private int yPos;
|
||||
|
||||
private int HCost;
|
||||
private int GCost;
|
||||
private int FCost;
|
||||
|
||||
public Ghost(int index) {
|
||||
|
||||
super("Pinky"); // Aufrufen der übergeordneten Klasse
|
||||
|
@ -40,4 +44,25 @@ public class Ghost extends Picture { // Die
|
|||
}
|
||||
}
|
||||
|
||||
public void moveUp() {
|
||||
}
|
||||
|
||||
public void moveDown() {
|
||||
|
||||
}
|
||||
|
||||
public void moveRight() {
|
||||
|
||||
}
|
||||
|
||||
public void moveLeft() {
|
||||
|
||||
}
|
||||
|
||||
public int getHCost() {
|
||||
|
||||
|
||||
return HCost;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue