From 28f85f09de47c6015f4b0f16d0099e1485ec9e95 Mon Sep 17 00:00:00 2001 From: Lenz Date: Sat, 6 Jun 2020 15:19:33 +0200 Subject: [PATCH] =?UTF-8?q?lebensanzeige=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/Map.txt | 2 +- assets/heart.png | Bin 0 -> 238 bytes bin/.gitignore | 1 + bin/Game.class | Bin 6675 -> 6934 bytes bin/Player.class | Bin 3510 -> 3510 bytes src/Game.java | 30 +++++++++++++++++++----------- src/Lives.java | 8 ++++++++ src/Player.java | 2 +- 8 files changed, 30 insertions(+), 13 deletions(-) create mode 100644 assets/heart.png create mode 100644 src/Lives.java diff --git a/assets/Map.txt b/assets/Map.txt index ec3ca9d..367d460 100644 --- a/assets/Map.txt +++ b/assets/Map.txt @@ -4,7 +4,7 @@ # ###### # # ##### ###### ###### ###### #### # # ##### ###### ###### #### # -# ##,### # +# ###### # # ##### ###### ,0123, ###### #### # # ### ###### ###### ###### ## # # # # P # # # diff --git a/assets/heart.png b/assets/heart.png new file mode 100644 index 0000000000000000000000000000000000000000..cca13137031f9b1638844433c921f2ef676c2d71 GIT binary patch literal 238 zcmeAS@N?(olHy`uVBq!ia0vp^LO{&V!3HE>w#^4|SkfJR9T^xl_H+M9WCij$3p^r= z85sBugD~Uq{1qucL5ULAh?3y^w370~qEv>0#LT=By}Z;C1rt33J>#Bd(*uBNay(re zLoEEy_IUF(CK4ZX+6^B9$fc7$Yy85}Sb4q9e0G!8BE&u=k literal 0 HcmV?d00001 diff --git a/bin/.gitignore b/bin/.gitignore index 0e08c32..cc3ed02 100644 --- a/bin/.gitignore +++ b/bin/.gitignore @@ -1 +1,2 @@ /Point.class +/Lives.class diff --git a/bin/Game.class b/bin/Game.class index 49c709fb0f8c2d5698243d2284a73e2bba99136b..d7cfcc19a0786f5650743a1758a1dab466c00711 100644 GIT binary patch literal 6934 zcma)B34B!5)&HM)@6DT;yg&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JMkmePONtA#`UhJaD(eP+~_)pn_MsBX2#$a_fY)QeF1*vF2Wl3Rk+oCJ=VI{<2Lub zxWoMv?sUJ0b?%c`uj#m3%fm0V3j9i|$35B-Y}9^;Uu(BvleQW6X}i&(?ZIa4Mcl8w zf(Nv>@O$k8Jg9wxhjbUV>V5G?eE?#54z}x~utOh5dLkatr{Gb24tDF6q_4!2dL8!Y z5j>?wu~%P(efo`fTE7*~=y&5;{T}Ss@5A%@gLpyTi39o`yr{o`gZe@INq-qH>2KoC z`cWLxKgY}Z3H-&Q@G8G^9`AeVm#dNHO=^^RyE@n0pmNR4D$m@a{N_$I+I)gz4yb|VVKvTtTTL)O#1GVP zX8z;ydSrg0Mlc(J8gq>r#SB*1Vop`(s$72eKc88f$5C$e2y@h-p2S?`C#JauB{0{J zZfuwP7H6EcN3F15z%+dj&aowQeG-PosT#cIP@XdN3rE5;PhIP1HeSPH4rcrv4>_2Z z=c0p|wP{a8P8pMzP8lWcAKru`;1%1>sdu@g| z(($#S9(5sO&NpoS59T5@k!vG!=l^DA8EU*nWBlqAH$69QI&FC7KN@aM&uW@{)&m^t kl9~q}nNTxm>*5qUY29|x)OT>$w&PMov?#NhWJ^!}KdVlr)&Kwi diff --git a/bin/Player.class b/bin/Player.class index 215dc9b8d26bd6ac074d424b43488618fa9d30d2..daa323be927ba65b345a866a938d35138a59061d 100644 GIT binary patch delta 16 Xcmdlcy-j*U93%7UGv%8T8AEvhI5`Fx delta 16 Ycmdlcy-j*U93%6!{Zlt5GKTU106FRgRR910 diff --git a/src/Game.java b/src/Game.java index 251597e..141b813 100644 --- a/src/Game.java +++ b/src/Game.java @@ -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++) { diff --git a/src/Lives.java b/src/Lives.java new file mode 100644 index 0000000..48f99f6 --- /dev/null +++ b/src/Lives.java @@ -0,0 +1,8 @@ + + +public class Lives extends Picture{ + public Lives() { + super("heart"); + } + +} diff --git a/src/Player.java b/src/Player.java index 6395325..113b02e 100644 --- a/src/Player.java +++ b/src/Player.java @@ -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