geister töten mit respawn zeit
parent
a9fd79860e
commit
d910b4a191
|
@ -5,7 +5,7 @@
|
|||
# #
|
||||
# #### ## ######## ## #### #
|
||||
# #### ## ######## ## #### #
|
||||
# ## ## ## #
|
||||
# ##. ## .## #
|
||||
###### ##### ## ##### ######
|
||||
,,,,,# ##### ## ##### #,,,,,
|
||||
,,,,,# ## ## #,,,,,
|
||||
|
@ -23,7 +23,7 @@
|
|||
#. ## P ## .#
|
||||
### ## ## ######## ## ## ###
|
||||
### ## ## ######## ## ## ###
|
||||
# ## ## ## #
|
||||
# ## .##. ## #
|
||||
# ########## ## ########## #
|
||||
# ########## ## ########## #
|
||||
# #
|
||||
|
|
|
@ -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.
BIN
bin/Brick.class
BIN
bin/Brick.class
Binary file not shown.
BIN
bin/Game.class
BIN
bin/Game.class
Binary file not shown.
BIN
bin/Ghost.class
BIN
bin/Ghost.class
Binary file not shown.
BIN
bin/Lives.class
BIN
bin/Lives.class
Binary file not shown.
BIN
bin/Main.class
BIN
bin/Main.class
Binary file not shown.
BIN
bin/Map.class
BIN
bin/Map.class
Binary file not shown.
Binary file not shown.
BIN
bin/Player.class
BIN
bin/Player.class
Binary file not shown.
BIN
bin/Point.class
BIN
bin/Point.class
Binary file not shown.
|
@ -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--;
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue