always og. bei mapauswahl
parent
abc520f2bc
commit
963c537de6
BIN
bin/Game.class
BIN
bin/Game.class
Binary file not shown.
BIN
bin/Ghost.class
BIN
bin/Ghost.class
Binary file not shown.
|
@ -133,7 +133,7 @@ public class Game {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println(Map.Left + " " + Map.Right);
|
|
||||||
if (Map.Left != null && Map.Right != null) {
|
if (Map.Left != null && Map.Right != null) {
|
||||||
panel.add(Map.Left);
|
panel.add(Map.Left);
|
||||||
panel.add(Map.Right);
|
panel.add(Map.Right);
|
||||||
|
@ -158,7 +158,7 @@ public class Game {
|
||||||
if (ghosts[i].getIsDead()) {
|
if (ghosts[i].getIsDead()) {
|
||||||
if (ghosts[i].getDeathTimer() != 0) {
|
if (ghosts[i].getDeathTimer() != 0) {
|
||||||
ghosts[i].setDeathTimer(ghosts[i].getDeathTimer() - 1);
|
ghosts[i].setDeathTimer(ghosts[i].getDeathTimer() - 1);
|
||||||
// System.out.println(ghosts[i].getDeathTimer());
|
|
||||||
} else {
|
} else {
|
||||||
ghosts[i].setIsDead(false);
|
ghosts[i].setIsDead(false);
|
||||||
ghosts[i].setPos('x', Map.ghost_posX[i]);
|
ghosts[i].setPos('x', Map.ghost_posX[i]);
|
||||||
|
@ -184,8 +184,7 @@ public class Game {
|
||||||
dt = System.nanoTime() - lastT; // delta time
|
dt = System.nanoTime() - lastT; // delta time
|
||||||
lastT = System.nanoTime(); // delta time
|
lastT = System.nanoTime(); // delta time
|
||||||
|
|
||||||
// Zu Beginn jeden Schleifendurchlaufs wird die Position von Pac-Man neu
|
|
||||||
// gesetzt:
|
|
||||||
player.setLocation(player.getPos('x', dt), player.getPos('y', dt));
|
player.setLocation(player.getPos('x', dt), player.getPos('y', dt));
|
||||||
|
|
||||||
for (int i = 0; i < ghosts.length; i++) {
|
for (int i = 0; i < ghosts.length; i++) {
|
||||||
|
@ -249,8 +248,8 @@ public class Game {
|
||||||
minn = HCost[j];
|
minn = HCost[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// System.out.println(HCost[0] + " " + HCost[1] + " " + HCost[2] + " " +
|
|
||||||
// HCost[3]);
|
|
||||||
for (int j = 0; j < 4; j++) {
|
for (int j = 0; j < 4; j++) {
|
||||||
if (HCost[j] == minn) {
|
if (HCost[j] == minn) {
|
||||||
if (frames % Ghost.offFrames == 0) {
|
if (frames % Ghost.offFrames == 0) {
|
||||||
|
@ -415,8 +414,7 @@ public class Game {
|
||||||
ghosts[i].setPos('x', -100);
|
ghosts[i].setPos('x', -100);
|
||||||
ghosts[i].setPos('y', -100);
|
ghosts[i].setPos('y', -100);
|
||||||
score += 1000;
|
score += 1000;
|
||||||
System.out.println("Geist" + i + " ist gestorben" + ghosts[i].getIsDead());
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
player.lives--;
|
player.lives--;
|
||||||
|
|
||||||
|
@ -441,7 +439,7 @@ public class Game {
|
||||||
|
|
||||||
fps = 1000000000 / dt;
|
fps = 1000000000 / dt;
|
||||||
|
|
||||||
// System.out.println("fps: " + fps);
|
|
||||||
|
|
||||||
delay(delaytimer); // Ein delay zum Ende der Hauptschleife
|
delay(delaytimer); // Ein delay zum Ende der Hauptschleife
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class Ghost extends Picture { // Die
|
||||||
.sqrt(Math.pow((((xPos - 10) / 20) + mod_x) - ((player.getPos('x', 0) - 10 + 80) / 20), 2)
|
.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) - ((200 - 10 + 80) / 20), 2)
|
HCost = (int) Math.sqrt(Math.pow((((xPos - 10) / 20) + mod_x) - ((200 - 10 + 80) / 20), 2)
|
||||||
+ Math.pow((((yPos - 10) / 20) + mod_y) - ((200 - 10) / 20), 2));
|
+ Math.pow((((yPos - 10) / 20) + mod_y) - ((200 - 10) / 20), 2));
|
||||||
} else if (type == 3) {
|
} else if (type == 3) {
|
||||||
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)
|
||||||
|
@ -71,7 +71,7 @@ public class Ghost extends Picture { // Die
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
HCost = 10 * (1 / (Math.sqrt(Math.pow((((xPos - 10) / 20) + mod_x) - ((player.getPos('x', 0) - 10) / 20), 2)
|
HCost = 100 * (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))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ public class Main {
|
||||||
|
|
||||||
System.setProperty("sun.java2d.opengl", "true");
|
System.setProperty("sun.java2d.opengl", "true");
|
||||||
|
|
||||||
// Game game = new Game("map1.txt"); // Das Spiel wird gestartet
|
|
||||||
|
|
||||||
MapMenu menu = new MapMenu();
|
MapMenu menu = new MapMenu();
|
||||||
|
|
||||||
|
|
|
@ -71,9 +71,9 @@ public class MapMenu extends JFrame {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
bob = new JComboBox<Object>(maps);
|
bob = new JComboBox<Object>(maps);
|
||||||
bob.setSelectedIndex(4);
|
bob.setSelectedItem("Original");
|
||||||
panel.add(bob);
|
panel.add(bob);
|
||||||
bob.setBounds(70, 10, 120, 30);
|
bob.setBounds(70, 10, 120, 30);
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ public class MapMenu extends JFrame {
|
||||||
// Was passieren soll, wenn der Button gedrückt wird
|
// Was passieren soll, wenn der Button gedrückt wird
|
||||||
public void button_ActionPerformed(ActionEvent evt) throws SQLException {
|
public void button_ActionPerformed(ActionEvent evt) throws SQLException {
|
||||||
selectedMap = String.valueOf(bob.getSelectedItem());
|
selectedMap = String.valueOf(bob.getSelectedItem());
|
||||||
System.out.println(selectedMap + " is now the selected Map!");
|
|
||||||
rdy = true;
|
rdy = true;
|
||||||
this.setVisible(false);
|
this.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue