geister töten mit respawn zeit

master
leventius imperatus 2020-06-07 15:42:46 +02:00
parent a9fd79860e
commit d910b4a191
14 changed files with 142 additions and 106 deletions

View File

@ -5,7 +5,7 @@
# #
# #### ## ######## ## #### #
# #### ## ######## ## #### #
# ## ## ## #
# ##. ## .## #
###### ##### ## ##### ######
,,,,,# ##### ## ##### #,,,,,
,,,,,# ## ## #,,,,,
@ -23,7 +23,7 @@
#. ## P ## .#
### ## ## ######## ## ## ###
### ## ## ######## ## ## ###
# ## ## ## #
# ## .##. ## #
# ########## ## ########## #
# ########## ## ########## #
# #

10
bin/.gitignore vendored
View File

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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -138,7 +138,31 @@ public class Game {
lastT = System.nanoTime(); // delta time
frame.setVisible(true);
// -----------------------------------------------------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------------------------------------------------
while (true) { // Hauptschleife
for (int i = 0; i < ghosts.length; i++) {
if (ghosts[i].getIsDead()) {
if (ghosts[i].getDeathTimer() != 0) {
ghosts[i].setDeathTimer(ghosts[i].getDeathTimer() - 1);
System.out.println(ghosts[i].getDeathTimer());
} else {
ghosts[i].setIsDead(false);
ghosts[i].setPos('x', Map.ghost_posX[i]);
ghosts[i].setPos('y', Map.ghost_posY[i]);
}
}
}
frames++;
if (ghosts[0].feared == true) {
if (Ghost.fearedTimer != 0) {
@ -159,7 +183,7 @@ public class Game {
player.setLocation(player.getPos('x', dt), player.getPos('y', dt));
for (int i = 0; i < ghosts.length; i++) {
if (!ghosts[i].getIsDead()) {
ghost_possible[i][0] = false;
ghost_possible[i][1] = false;
ghost_possible[i][2] = false;
@ -219,7 +243,8 @@ public class Game {
minn = HCost[j];
}
}
System.out.println(HCost[0]+ " "+HCost[1]+ " "+ HCost[2] + " "+HCost[3] );
// System.out.println(HCost[0] + " " + HCost[1] + " " + HCost[2] + " " +
// HCost[3]);
for (int j = 0; j < 4; j++) {
if (HCost[j] == minn) {
if (j == 0) {
@ -254,7 +279,7 @@ public class Game {
}
}
}
// Kollision von Pac-Man mit Bricks:
for (int i = 0; i < 35; i++) { // für jeden Brick
for (int j = 0; j < 35; j++) { // für jeden Brick
@ -363,10 +388,13 @@ public class Game {
&& player.getPos('y', 0) < ghosts[i].getPos('y', 0) + 20
&& player.getPos('y', 0) > ghosts[i].getPos('y', 0) - 20)
if (ghosts[0].feared) {
ghosts[i].setPos('x', Map.ghost_posX[i]);
ghosts[i].setPos('y', Map.ghost_posY[i]);
ghosts[i].setIsDead(true);
ghosts[i].setDeathTimer(1000);
ghosts[i].setPos('x', -100);
ghosts[i].setPos('y', -100);
score += 1000;
System.out.println("Geist"+ i + " ist gestorben" + ghosts[i].getIsDead());
} else {
player.lives--;

View File

@ -12,8 +12,10 @@ public class Ghost extends Picture { // Die
public boolean left;
public boolean right;
public boolean feared = false;
public boolean feared;
public static int fearedTimer;
private int deathTimer;
private boolean isDead;
private double HCost;
private int type;
@ -74,6 +76,22 @@ public class Ghost extends Picture { // Die
}
public void setDeathTimer(int amount) {
this.deathTimer = amount;
}
public int getDeathTimer() {
return (int) this.deathTimer;
}
public void setIsDead(boolean b) {
this.isDead = b;
}
public boolean getIsDead() {
return this.isDead;
}
public int getPos(char coordinate, long dt) { // Hier kommt die zuvor erwähnte delta time ins Spiel
if (coordinate == 'x') { // Auslesen der 'x' - Koordinate: