Fix: Game crasht nicht mehr bei damage auf 0 Leben und PowerUps werden wieder gelöscht wenn sie den unteren Fensterrand

This commit is contained in:
2026-09-17 10:05:50 +02:00
parent 5cf095c370
commit 9a0d7e7f7a
6 changed files with 7 additions and 5 deletions
Binary file not shown.
+2 -2
View File
@@ -57,8 +57,8 @@ public class MyWorld extends World
plattform2.setLocation(320,367);
plattform2.setLocation(312,371);
plattform2.setLocation(308,382);
Healthbar healthbar = new Healthbar();
addObject(healthbar,50,50);
//Healthbar healthbar = new Healthbar();
//addObject(healthbar,50,50);
Heart heart = new Heart();
addObject(heart,371,27);
Heart heart2 = new Heart();
Binary file not shown.
+2
View File
@@ -121,9 +121,11 @@ public class Player extends Actor
getWorld().removeObjects(getWorld().getObjects(Spike.class));
getWorld().removeObjects(getIntersectingObjects(Spike.class));
if (getWorld().getObjects(Heart.class) != null){
getWorld().removeObject(getWorld().getObjects(Heart.class).get(0));
}
}
}
public void checkHealth(){
if (health <= 0){
Binary file not shown.
+2 -2
View File
@@ -34,8 +34,8 @@ public class PowerUps extends Actor
public void moveDown()
{
this.setLocation(this.getX(), this.getY()+2);
if(this.getY()>=this.getWorld().getHeight())
setLocation(this.getX(), this.getY()+2);
if(this.getY() >= getWorld().getHeight()-1)
{
deleteAfterActCycle = true;
}