Compare commits

...

2 Commits

Author SHA1 Message Date
Jonas fe6d466cd6 Merge remote-tracking branch 'origin/main' 2026-09-17 11:49:22 +02:00
Jonas 047fe9597d Herzen werden jetzt immer über den Platformen angezeigt 2026-09-17 11:49:14 +02:00
5 changed files with 26 additions and 20 deletions
Binary file not shown.
+8 -6
View File
@@ -10,13 +10,15 @@ comment2.text=\r\n\ Prepare\ the\ world\ for\ the\ start\ of\ the\ program.\r\n\
comment3.params= comment3.params=
comment3.target=void\ act() comment3.target=void\ act()
comment4.params= comment4.params=
comment4.target=void\ spawnItems() comment4.target=void\ drawNewHearts()
comment5.params= comment5.params=
comment5.target=void\ spawnEnemies() comment5.target=void\ spawnItems()
comment6.params= comment6.params=
comment6.target=void\ projectile() comment6.target=void\ spawnEnemies()
comment7.params= comment7.params=
comment7.target=void\ targetingProjectile() comment7.target=void\ projectile()
comment8.params= comment8.params=
comment8.target=void\ showScore() comment8.target=void\ targetingProjectile()
numComments=9 comment9.params=
comment9.target=void\ showScore()
numComments=10
+16
View File
@@ -84,6 +84,7 @@ public class MyWorld extends World
spawnEnemies(); spawnEnemies();
targetingProjectile(); targetingProjectile();
spawnItems(); spawnItems();
drawNewHearts();
if(PlattformCountdown==0) //Damit in regelmäßigen Abständen auf jeden Fall eine Plattform auftaucht if(PlattformCountdown==0) //Damit in regelmäßigen Abständen auf jeden Fall eine Plattform auftaucht
{ {
addObject(new Plattform(), 1+Greenfoot.getRandomNumber(398), 5); addObject(new Plattform(), 1+Greenfoot.getRandomNumber(398), 5);
@@ -111,6 +112,21 @@ public class MyWorld extends World
addObject(new SpikedPlattform(100), 1+Greenfoot.getRandomNumber(398), 6); //Nach Links bewegende Plattform addObject(new SpikedPlattform(100), 1+Greenfoot.getRandomNumber(398), 6); //Nach Links bewegende Plattform
} }
} }
public void drawNewHearts(){
Player player = getObjects(Player.class).get(0);
removeObjects(getObjects(Heart.class));
Heart heart = new Heart();
addObject(heart,371,27);
if (player.health >= 2){
Heart heart2 = new Heart();
addObject(heart2,343,27);
}
if (player.health == 3){
Heart heart3 = new Heart();
addObject(heart3,314,27);
}
}
public void spawnItems(){ public void spawnItems(){
itemTimer++; itemTimer++;
Binary file not shown.
+2 -14
View File
@@ -54,11 +54,13 @@ public class Player extends Actor
if (Greenfoot.isKeyDown("a")) if (Greenfoot.isKeyDown("a"))
{ {
setLocation(getX() - speed, getY()); setLocation(getX() - speed, getY());
setImage("Player.png");
} }
if (Greenfoot.isKeyDown("d")) if (Greenfoot.isKeyDown("d"))
{ {
setLocation(getX() + speed, getY()); setLocation(getX() + speed, getY());
setImage("Player.png");
} }
} }
@@ -120,15 +122,6 @@ public class Player extends Actor
getWorld().removeObjects(getIntersectingObjects(Projectile.class)); getWorld().removeObjects(getIntersectingObjects(Projectile.class));
getWorld().removeObjects(getIntersectingObjects(Enemy.class)); getWorld().removeObjects(getIntersectingObjects(Enemy.class));
getWorld().removeObjects(getWorld().getObjects(Spike.class)); getWorld().removeObjects(getWorld().getObjects(Spike.class));
getWorld().removeObjects(getIntersectingObjects(Spike.class));
if (getWorld().getObjects(Heart.class) != null){
if (health == 2){
getWorld().getObjects(Heart.class).get(2).setImage("a.png");
} else if (health == 1){
getWorld().getObjects(Heart.class).get(1).setImage("a.png");
}
}
} }
} }
@@ -157,11 +150,6 @@ public class Player extends Actor
break; break;
case "Heal": case "Heal":
if (health < MAX_HEALTH){ if (health < MAX_HEALTH){
if (health == 2){
getWorld().getObjects(Heart.class).get(2).setImage("Health.png");
} else if (health == 1){
getWorld().getObjects(Heart.class).get(1).setImage("Health.png");
}
health++; health++;
} }
break; break;