lebensanzeige hinzugefügt
parent
870424d1c5
commit
28f85f09de
|
@ -4,7 +4,7 @@
|
|||
# ###### #
|
||||
# ##### ###### ###### ###### #### #
|
||||
# ##### ###### ###### #### #
|
||||
# ##,### #
|
||||
# ###### #
|
||||
# ##### ###### ,0123, ###### #### #
|
||||
# ### ###### ###### ###### ## #
|
||||
# # # P # # #
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 238 B |
|
@ -1 +1,2 @@
|
|||
/Point.class
|
||||
/Lives.class
|
||||
|
|
BIN
bin/Game.class
BIN
bin/Game.class
Binary file not shown.
BIN
bin/Player.class
BIN
bin/Player.class
Binary file not shown.
|
@ -26,7 +26,9 @@ public class Game {
|
|||
|
||||
private JLabel scoreLabel;
|
||||
|
||||
private int delaytimer = 13;
|
||||
private JLabel liveLabels[];
|
||||
|
||||
private int delaytimer = 12;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private long fps = 60;
|
||||
|
@ -56,16 +58,18 @@ public class Game {
|
|||
|
||||
player = new Player(); // Pac-Man
|
||||
|
||||
liveLabels = new JLabel[3];
|
||||
for (int i = 0; i < liveLabels.length; i++) {
|
||||
liveLabels[i] = new Lives();
|
||||
panel.add(liveLabels[i]);
|
||||
liveLabels[i].setBounds(710, 30 + 20 * i, 20, 20);
|
||||
}
|
||||
|
||||
scoreLabel = new JLabel(Integer.toString(score));
|
||||
|
||||
panel.add(scoreLabel);
|
||||
|
||||
scoreLabel.setForeground(Color.WHITE);
|
||||
|
||||
scoreLabel.setBounds(710, -5, 500, 50);
|
||||
|
||||
Font f = new Font("Consolas", Font.BOLD, 25);
|
||||
|
||||
scoreLabel.setBounds(710, 0, 500, 50);
|
||||
Font f = new Font("Consolas", Font.BOLD, 24);
|
||||
scoreLabel.setFont(f);
|
||||
|
||||
panel.add(player); // Pac-Man wird dem Panel hinzugefügt
|
||||
|
@ -263,11 +267,10 @@ public class Game {
|
|||
&& player.getPos('x', 0) > Map.points[j][i].xPos - 5
|
||||
&& player.getPos('y', 0) < Map.points[j][i].yPos + 5
|
||||
&& player.getPos('y', 0) > Map.points[j][i].yPos - 5) {
|
||||
|
||||
|
||||
Map.points[j][i].setBounds(0, 0, 0, 0);
|
||||
|
||||
|
||||
Map.points[j][i] = null;
|
||||
|
||||
|
||||
score++;
|
||||
scoreLabel.setText(Integer.toString(score));
|
||||
|
@ -286,6 +289,11 @@ public class Game {
|
|||
&& player.getPos('y', 0) > ghosts[i].getPos('y', 0) - 20) {
|
||||
|
||||
player.lives--;
|
||||
|
||||
liveLabels[player.lives].setBounds(0, 0, 0, 0);
|
||||
if (player.lives == 0) {
|
||||
System.exit(0);
|
||||
}
|
||||
System.out.println(player.lives);
|
||||
delay(200);
|
||||
for (int j = 0; j < ghosts.length; j++) {
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
|
||||
public class Lives extends Picture{
|
||||
public Lives() {
|
||||
super("heart");
|
||||
}
|
||||
|
||||
}
|
|
@ -15,7 +15,7 @@ public class Player extends Picture implements KeyListener { // extends Picture
|
|||
|
||||
public int lives = 3;
|
||||
|
||||
private float speed = 0.0000001f; // Diee Geschwindigkeit von Pac-man. In alle Richtungen gleich. Muss so klein
|
||||
private float speed = 0.00000008f; // Diee Geschwindigkeit von Pac-man. In alle Richtungen gleich. Muss so klein
|
||||
// sein wegen delta time
|
||||
|
||||
public long timer; // Variable die speichert zu welchem Zeitpunkt eine Änderung der Richtung
|
||||
|
|
Loading…
Reference in New Issue