Compare commits
2 Commits
af551a1a57
...
fe6d466cd6
| Author | SHA1 | Date | |
|---|---|---|---|
| fe6d466cd6 | |||
| 047fe9597d |
Binary file not shown.
@@ -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
|
||||||
|
|||||||
@@ -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);
|
||||||
@@ -112,6 +113,21 @@ public class MyWorld extends World
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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++;
|
||||||
if (itemTimer >= 575){
|
if (itemTimer >= 575){
|
||||||
|
|||||||
Binary file not shown.
+2
-14
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user