paar kleine SchönheitsÃderungen
parent
d55e432b06
commit
a169f0676a
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.
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/Point.class
BIN
bin/Point.class
Binary file not shown.
BIN
bin/Portal.class
BIN
bin/Portal.class
Binary file not shown.
|
@ -1,4 +1,4 @@
|
||||||
// Diese Klasse stellt die einzelnen Bicks (Wände) auf der Map dar.
|
// Diese Klasse stellt die BigPoints (punkte die man fressen kann um kurzzeittig die Geister töten zu können) auf der Map dar.
|
||||||
|
|
||||||
public class BigPoint extends Picture { // Die übergeordnete Klasse ist Picture
|
public class BigPoint extends Picture { // Die übergeordnete Klasse ist Picture
|
||||||
|
|
||||||
|
@ -8,8 +8,8 @@ public class BigPoint extends Picture { // Die
|
||||||
public int yPos; // Position auf dem Frame in y-Richtung
|
public int yPos; // Position auf dem Frame in y-Richtung
|
||||||
|
|
||||||
public BigPoint(int newXPos, int newYPos) { // Erstellen des Konstruktors mit den Koordinaten, an denen sich der
|
public BigPoint(int newXPos, int newYPos) { // Erstellen des Konstruktors mit den Koordinaten, an denen sich der
|
||||||
// Brick
|
// BigPoint
|
||||||
// beefinden soll.
|
// befinden soll.
|
||||||
|
|
||||||
super("bigpoint"); // Aufrufen der übergeordneten Klasse
|
super("bigpoint"); // Aufrufen der übergeordneten Klasse
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ public class Brick extends Picture { // Die
|
||||||
public int yPos; // Position auf dem Frame in y-Richtung
|
public int yPos; // Position auf dem Frame in y-Richtung
|
||||||
|
|
||||||
public Brick(int newXPos, int newYPos) { // Erstellen des Konstruktors mit den Koordinaten, an denen sich der Brick
|
public Brick(int newXPos, int newYPos) { // Erstellen des Konstruktors mit den Koordinaten, an denen sich der Brick
|
||||||
// beefinden soll.
|
// befinden soll.
|
||||||
|
|
||||||
super("brick"); // Aufrufen der übergeordneten Klasse
|
super("brick"); // Aufrufen der übergeordneten Klasse
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ public class Game {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
} 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,7 +184,6 @@ 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
|
||||||
|
|
||||||
|
|
||||||
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++) {
|
||||||
|
@ -248,8 +247,7 @@ public class Game {
|
||||||
minn = HCost[j];
|
minn = HCost[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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) {
|
||||||
|
@ -343,22 +341,22 @@ public class Game {
|
||||||
if (Map.Left != null) {
|
if (Map.Left != null) {
|
||||||
if (player.getPos('x', 0) < Map.Left.xPos + 20 && player.getPos('x', 0) > Map.Left.xPos - 20
|
if (player.getPos('x', 0) < Map.Left.xPos + 20 && player.getPos('x', 0) > Map.Left.xPos - 20
|
||||||
&& player.getPos('y', 0) < Map.Left.yPos + 20 && player.getPos('y', 0) > Map.Left.yPos - 20) {
|
&& player.getPos('y', 0) < Map.Left.yPos + 20 && player.getPos('y', 0) > Map.Left.yPos - 20) {
|
||||||
|
|
||||||
if (Map.Right != null) {
|
if (Map.Right != null) {
|
||||||
player.xPos = Map.Right.xPos - 20;
|
player.xPos = Map.Right.xPos - 20;
|
||||||
player.yPos = Map.Right.yPos;
|
player.yPos = Map.Right.yPos;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Map.Right != null) {
|
if (Map.Right != null) {
|
||||||
if (player.getPos('x', 0) < Map.Right.xPos + 20 && player.getPos('x', 0) > Map.Right.xPos - 20
|
if (player.getPos('x', 0) < Map.Right.xPos + 20 && player.getPos('x', 0) > Map.Right.xPos - 20
|
||||||
&& player.getPos('y', 0) < Map.Right.yPos + 20 && player.getPos('y', 0) > Map.Right.yPos - 20) {
|
&& player.getPos('y', 0) < Map.Right.yPos + 20 && player.getPos('y', 0) > Map.Right.yPos - 20) {
|
||||||
|
|
||||||
if (Map.Left != null) {
|
if (Map.Left != null) {
|
||||||
player.xPos = Map.Left.xPos + 20;
|
player.xPos = Map.Left.xPos + 20;
|
||||||
player.yPos = Map.Left.yPos;
|
player.yPos = Map.Left.yPos;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -414,7 +412,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;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
player.lives--;
|
player.lives--;
|
||||||
|
|
||||||
|
@ -439,8 +437,6 @@ public class Game {
|
||||||
|
|
||||||
fps = 1000000000 / dt;
|
fps = 1000000000 / dt;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
delay(delaytimer); // Ein delay zum Ende der Hauptschleife
|
delay(delaytimer); // Ein delay zum Ende der Hauptschleife
|
||||||
|
|
||||||
if (frames % 100 == 0) {
|
if (frames % 100 == 0) {
|
||||||
|
|
|
@ -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,8 +71,9 @@ public class Ghost extends Picture { // Die
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
HCost = 100 * (1 / (Math.sqrt(Math.pow((((xPos - 10) / 20) + mod_x) - ((player.getPos('x', 0) - 10) / 20), 2)
|
HCost = 100
|
||||||
+ Math.pow((((yPos - 10) / 20) + mod_y) - ((player.getPos('y', 0) - 10) / 20), 2))));
|
* (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))));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int) HCost;
|
return (int) HCost;
|
||||||
|
@ -118,7 +119,7 @@ public class Ghost extends Picture { // Die
|
||||||
yPos -= 1;
|
yPos -= 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
return (int) yPos; // (int)
|
return (int) yPos;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,15 @@
|
||||||
// Diese Klasse stellt die einzelnen Bicks (Wände) auf der Map dar.
|
// Diese Klasse stellt den Hintergrun im MapMenü
|
||||||
|
|
||||||
public class Hintergrund extends Picture {
|
public class Hintergrund extends Picture {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -8813034369041822237L;
|
private static final long serialVersionUID = -8813034369041822237L;
|
||||||
public int xPos;
|
public int xPos;
|
||||||
public int yPos;
|
public int yPos;
|
||||||
|
|
||||||
public Hintergrund() {
|
public Hintergrund() {
|
||||||
|
|
||||||
|
super("hintergrund");
|
||||||
|
|
||||||
super("hintergrund");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
|
// Diese Klasse stellt die Herzen dar.
|
||||||
public class Lives extends Picture {
|
public class Lives extends Picture {
|
||||||
|
|
||||||
private static final long serialVersionUID = -4715442447789971450L;
|
private static final long serialVersionUID = -4715442447789971450L;
|
||||||
|
|
||||||
public Lives() {
|
public Lives() {
|
||||||
|
|
||||||
super("heart");
|
super("heart");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,13 +22,10 @@ public class Main {
|
||||||
|
|
||||||
// Methode zum verzögern (warten) in ms
|
// Methode zum verzögern (warten) in ms
|
||||||
public static void delay(int time) {
|
public static void delay(int time) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(time);
|
Thread.sleep(time);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -46,8 +46,6 @@ public class Map {
|
||||||
|
|
||||||
reader = new BufferedReader(new FileReader("assets/Maps/" + selectedMap)); // Einlesen der .txt Datei
|
reader = new BufferedReader(new FileReader("assets/Maps/" + selectedMap)); // Einlesen der .txt Datei
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < 35; i++) { // für die ersten 35 Zeilen der Datei:
|
for (int i = 0; i < 35; i++) { // für die ersten 35 Zeilen der Datei:
|
||||||
String line = reader.readLine(); // Einlesen der jeweiligen Zeile
|
String line = reader.readLine(); // Einlesen der jeweiligen Zeile
|
||||||
for (int j = 0; j < 35; j++) { // für die ersten 35 Zeichen der jeweiligen Zeile
|
for (int j = 0; j < 35; j++) { // für die ersten 35 Zeichen der jeweiligen Zeile
|
||||||
|
|
|
@ -71,15 +71,14 @@ public class MapMenu extends JFrame {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
bob = new JComboBox<Object>(maps);
|
bob = new JComboBox<Object>(maps);
|
||||||
bob.setSelectedItem("Original");
|
bob.setSelectedItem("Original");
|
||||||
panel.add(bob);
|
panel.add(bob);
|
||||||
bob.setBounds(50, 10, 200, 30);
|
bob.setBounds(50, 10, 200, 30);
|
||||||
bob.setFont(new Font("Consolas", Font.PLAIN, 14));
|
bob.setFont(new Font("Consolas", Font.PLAIN, 14));
|
||||||
//bob.setAlignmentX(Label.CENTER);
|
// bob.setAlignmentX(Label.CENTER);
|
||||||
((JLabel)bob.getRenderer()).setHorizontalAlignment(SwingConstants.CENTER);
|
((JLabel) bob.getRenderer()).setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSelectedMap() {
|
public String getSelectedMap() {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Diese Klasse stellt die einzelnen Bicks (Wände) auf der Map dar.
|
// Diese Klasse stellt die einzelnen Punkte die man einsammeln kann um den Score zu vergrößern dar.
|
||||||
|
|
||||||
public class Point extends Picture { // Die übergeordnete Klasse ist Picture
|
public class Point extends Picture { // Die übergeordnete Klasse ist Picture
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
// Diese Klasse stellt die einzelnen Bicks (Wände) auf der Map dar.
|
// Diese Klasse stellt die Portale auf der Map dar.
|
||||||
|
|
||||||
public class Portal extends Picture {
|
public class Portal extends Picture {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -8813034369041822237L;
|
private static final long serialVersionUID = -8813034369041822237L;
|
||||||
public int xPos;
|
|
||||||
public int yPos;
|
|
||||||
|
|
||||||
public Portal(int newXPos, int newYPos) {
|
public int xPos;
|
||||||
|
public int yPos;
|
||||||
|
|
||||||
|
public Portal(int newXPos, int newYPos) {
|
||||||
|
|
||||||
|
super("portal");
|
||||||
|
|
||||||
super("portal");
|
|
||||||
|
|
||||||
xPos = newXPos;
|
xPos = newXPos;
|
||||||
yPos = newYPos;
|
yPos = newYPos;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue