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.
|
@ -19,9 +19,9 @@ public class Game {
|
|||
// Delta time: siehe https://en.wikipedia.org/wiki/Delta_timing
|
||||
private long dt;
|
||||
private long lastT;
|
||||
|
||||
|
||||
private int delaytimer = 9;
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private long fps = 60;
|
||||
|
||||
|
@ -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
|
||||
|
@ -135,7 +169,7 @@ public class Game {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
player.calcDir(0); // Berechnen wo Pac-Man als nächstes hin soll
|
||||
|
||||
for (int i = 0; i < ghosts.length; i++) {
|
||||
|
@ -150,11 +184,11 @@ public class Game {
|
|||
}
|
||||
}
|
||||
fps = 1000000000 / dt;
|
||||
|
||||
|
||||
// System.out.println("fps: " + fps + " | delaytimer: " + delaytimer);
|
||||
|
||||
|
||||
delay(delaytimer); // Ein delay zum Ende der Hauptschleife
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,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) {
|
||||
|
||||
|
@ -39,5 +43,26 @@ public class Ghost extends Picture { // Die
|
|||
yPos = newPos;
|
||||
}
|
||||
}
|
||||
|
||||
public void moveUp() {
|
||||
}
|
||||
|
||||
public void moveDown() {
|
||||
|
||||
}
|
||||
|
||||
public void moveRight() {
|
||||
|
||||
}
|
||||
|
||||
public void moveLeft() {
|
||||
|
||||
}
|
||||
|
||||
public int getHCost() {
|
||||
|
||||
|
||||
return HCost;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue