Merge remote-tracking branch 'origin/main'
# Conflicts: # SMIMS-Game/MyWorld.class # SMIMS-Game/project.greenfoot
This commit is contained in:
Binary file not shown.
@@ -34,9 +34,14 @@ public class Enemy extends Actor
|
||||
}
|
||||
|
||||
public void shootAtPlayer(){
|
||||
Player player = getWorld().getObjects(Player.class).get(0);
|
||||
shootTimer++;
|
||||
if (player.getX() - getX() < 0){
|
||||
setImage("Enemy.png");
|
||||
} else if (player.getX() - getX() > 0){
|
||||
setImage("EnemyRight.png");
|
||||
}
|
||||
if (shootTimer >= 100){
|
||||
Player player = getWorld().getObjects(Player.class).get(0);
|
||||
EnemyProjectile enemyProjectile = new EnemyProjectile();
|
||||
getWorld().addObject(enemyProjectile, getX(), getY());
|
||||
enemyProjectile.turnTowards(player.getX(), player.getY());
|
||||
|
||||
Binary file not shown.
@@ -26,7 +26,7 @@ public class EnemyProjectile extends Projectile
|
||||
return false;
|
||||
}
|
||||
//Check X-Value
|
||||
if (getX() <= 0 || getX() >= getWorld().getHeight()-1){
|
||||
if (getX() <= 0 || getX() >= getWorld().getWidth()-1){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
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.target=void\ act()
|
||||
comment4.params=
|
||||
comment4.target=void\ spawnItems()
|
||||
comment4.target=void\ drawNewHearts()
|
||||
comment5.params=
|
||||
comment5.target=void\ spawnEnemies()
|
||||
comment5.target=void\ spawnItems()
|
||||
comment6.params=
|
||||
comment6.target=void\ projectile()
|
||||
comment6.target=void\ spawnEnemies()
|
||||
comment7.params=
|
||||
comment7.target=void\ targetingProjectile()
|
||||
comment7.target=void\ projectile()
|
||||
comment8.params=
|
||||
comment8.target=void\ showScore()
|
||||
numComments=9
|
||||
comment8.target=void\ targetingProjectile()
|
||||
comment9.params=
|
||||
comment9.target=void\ showScore()
|
||||
numComments=10
|
||||
|
||||
@@ -84,6 +84,7 @@ public class MyWorld extends World
|
||||
spawnEnemies();
|
||||
targetingProjectile();
|
||||
spawnItems();
|
||||
drawNewHearts();
|
||||
if(PlattformCountdown==0) //Damit in regelmäßigen Abständen auf jeden Fall eine Plattform auftaucht
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
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(){
|
||||
itemTimer++;
|
||||
|
||||
Binary file not shown.
+3
-15
@@ -12,7 +12,7 @@ public class Player extends Actor
|
||||
int health = MAX_HEALTH;
|
||||
|
||||
int jumpBoostDuration = -1;
|
||||
int jumpBoostStrength = 5;
|
||||
int jumpBoostStrength = 3;
|
||||
|
||||
boolean projectileReady = false;
|
||||
int projectileTimer;
|
||||
@@ -54,11 +54,13 @@ public class Player extends Actor
|
||||
if (Greenfoot.isKeyDown("a"))
|
||||
{
|
||||
setLocation(getX() - speed, getY());
|
||||
setImage("Player.png");
|
||||
}
|
||||
|
||||
if (Greenfoot.isKeyDown("d"))
|
||||
{
|
||||
setLocation(getX() + speed, getY());
|
||||
setImage("Player.png");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,15 +122,6 @@ public class Player extends Actor
|
||||
getWorld().removeObjects(getIntersectingObjects(Projectile.class));
|
||||
getWorld().removeObjects(getIntersectingObjects(Enemy.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;
|
||||
case "Heal":
|
||||
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++;
|
||||
}
|
||||
break;
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 7.0 KiB |
@@ -1,8 +1,7 @@
|
||||
#Greenfoot project file
|
||||
class.BreakingPlattform.image=Breaking1.png
|
||||
class.Button.image=Start.png
|
||||
class.Enemy.image=Enemy.png
|
||||
class.EnemyProjectile.image=EnemyProjectile.png
|
||||
class.Button.image=button-red.png
|
||||
class.Enemy.image=bee.png
|
||||
class.GameOverWorld.image=GameOverBackground.png
|
||||
class.Ground.image=weave.jpg
|
||||
class.Groundflower.image=flower2.png
|
||||
@@ -13,15 +12,13 @@ class.MovingPlattform.image=Platform1.png
|
||||
class.MyWorld.image=GameBackground.png
|
||||
class.Plattform.image=Platform1.png
|
||||
class.Player.image=Player.png
|
||||
class.PlayerProjectile.image=PlayerProjectile.png
|
||||
class.PlayerProjectile.image=beeper.png
|
||||
class.Projectile.image=Projectile1.png
|
||||
class.Score.image=Score1.png
|
||||
class.Spike.image=singleSpike.png
|
||||
class.SpikedPlattform.image=Spikes.png
|
||||
class.SpikedPlattform.image=Spikes2.png
|
||||
class.StartWorld.image=StartBackground.png
|
||||
class.TargetingProjectile.image=TargetProjectile.png
|
||||
class.TemporaryGround.image=Ground.png
|
||||
class.UnactiveSpike.image=Spike_Copy.png
|
||||
class.TargetingProjectile.image=blue-draught.png
|
||||
class.UnactiveSpike.image=inactiveSpike.png
|
||||
dependency1.from=PlayerTestWorld
|
||||
dependency1.to=Ground
|
||||
dependency1.type=UsesDependency
|
||||
@@ -35,125 +32,122 @@ dependency12.from=MyWorld
|
||||
dependency12.to=Groundflower
|
||||
dependency12.type=UsesDependency
|
||||
dependency13.from=MyWorld
|
||||
dependency13.to=HealthItem
|
||||
dependency13.to=Enemy
|
||||
dependency13.type=UsesDependency
|
||||
dependency14.from=MyWorld
|
||||
dependency14.to=JumpBoostItem
|
||||
dependency14.to=Projectile
|
||||
dependency14.type=UsesDependency
|
||||
dependency15.from=MyWorld
|
||||
dependency15.to=Enemy
|
||||
dependency15.to=TargetingProjectile
|
||||
dependency15.type=UsesDependency
|
||||
dependency16.from=MyWorld
|
||||
dependency16.to=Projectile
|
||||
dependency16.from=GameOverWorld
|
||||
dependency16.to=Button
|
||||
dependency16.type=UsesDependency
|
||||
dependency17.from=MyWorld
|
||||
dependency17.to=TargetingProjectile
|
||||
dependency17.from=StartWorld
|
||||
dependency17.to=Button
|
||||
dependency17.type=UsesDependency
|
||||
dependency18.from=GameOverWorld
|
||||
dependency18.to=Button
|
||||
dependency18.from=UnactiveSpike
|
||||
dependency18.to=SpikedPlattform
|
||||
dependency18.type=UsesDependency
|
||||
dependency19.from=StartWorld
|
||||
dependency19.to=Button
|
||||
dependency19.from=UnactiveSpike
|
||||
dependency19.to=MyWorld
|
||||
dependency19.type=UsesDependency
|
||||
dependency2.from=PlayerTestWorld
|
||||
dependency2.to=Player
|
||||
dependency2.type=UsesDependency
|
||||
dependency20.from=UnactiveSpike
|
||||
dependency20.to=SpikedPlattform
|
||||
dependency20.to=Spike
|
||||
dependency20.type=UsesDependency
|
||||
dependency21.from=UnactiveSpike
|
||||
dependency21.from=Button
|
||||
dependency21.to=MyWorld
|
||||
dependency21.type=UsesDependency
|
||||
dependency22.from=UnactiveSpike
|
||||
dependency22.to=Spike
|
||||
dependency22.from=PowerUps
|
||||
dependency22.to=Player
|
||||
dependency22.type=UsesDependency
|
||||
dependency23.from=Button
|
||||
dependency23.to=MyWorld
|
||||
dependency23.from=HealthItem
|
||||
dependency23.to=Player
|
||||
dependency23.type=UsesDependency
|
||||
dependency24.from=PowerUps
|
||||
dependency24.from=JumpBoostItem
|
||||
dependency24.to=Player
|
||||
dependency24.type=UsesDependency
|
||||
dependency25.from=HealthItem
|
||||
dependency25.from=Groundflower
|
||||
dependency25.to=Player
|
||||
dependency25.type=UsesDependency
|
||||
dependency26.from=JumpBoostItem
|
||||
dependency26.from=Enemy
|
||||
dependency26.to=Player
|
||||
dependency26.type=UsesDependency
|
||||
dependency27.from=Groundflower
|
||||
dependency27.to=Player
|
||||
dependency27.from=Enemy
|
||||
dependency27.to=EnemyProjectile
|
||||
dependency27.type=UsesDependency
|
||||
dependency28.from=Enemy
|
||||
dependency28.to=Player
|
||||
dependency28.from=Spike
|
||||
dependency28.to=MyWorld
|
||||
dependency28.type=UsesDependency
|
||||
dependency29.from=Enemy
|
||||
dependency29.to=EnemyProjectile
|
||||
dependency29.from=Player
|
||||
dependency29.to=GameOverWorld
|
||||
dependency29.type=UsesDependency
|
||||
dependency3.from=PlayerTestWorld
|
||||
dependency3.to=JumpBoostItem
|
||||
dependency3.type=UsesDependency
|
||||
dependency30.from=Spike
|
||||
dependency30.to=MyWorld
|
||||
dependency30.from=Player
|
||||
dependency30.to=Plattform
|
||||
dependency30.type=UsesDependency
|
||||
dependency31.from=Player
|
||||
dependency31.to=GameOverWorld
|
||||
dependency31.to=PlayerProjectile
|
||||
dependency31.type=UsesDependency
|
||||
dependency32.from=Player
|
||||
dependency32.to=Plattform
|
||||
dependency32.to=TemporaryGround
|
||||
dependency32.type=UsesDependency
|
||||
dependency33.from=Player
|
||||
dependency33.to=PlayerProjectile
|
||||
dependency33.to=Projectile
|
||||
dependency33.type=UsesDependency
|
||||
dependency34.from=Player
|
||||
dependency34.to=TemporaryGround
|
||||
dependency34.to=Enemy
|
||||
dependency34.type=UsesDependency
|
||||
dependency35.from=Player
|
||||
dependency35.to=Projectile
|
||||
dependency35.to=Spike
|
||||
dependency35.type=UsesDependency
|
||||
dependency36.from=Player
|
||||
dependency36.to=Enemy
|
||||
dependency36.to=Heart
|
||||
dependency36.type=UsesDependency
|
||||
dependency37.from=Player
|
||||
dependency37.to=Spike
|
||||
dependency37.from=Healthbar
|
||||
dependency37.to=Player
|
||||
dependency37.type=UsesDependency
|
||||
dependency38.from=Player
|
||||
dependency38.to=Heart
|
||||
dependency38.from=Plattform
|
||||
dependency38.to=MyWorld
|
||||
dependency38.type=UsesDependency
|
||||
dependency39.from=Plattform
|
||||
dependency39.to=MyWorld
|
||||
dependency39.to=Player
|
||||
dependency39.type=UsesDependency
|
||||
dependency4.from=MyWorld
|
||||
dependency4.to=Player
|
||||
dependency4.type=UsesDependency
|
||||
dependency40.from=Plattform
|
||||
dependency40.to=Player
|
||||
dependency40.from=MovingPlattform
|
||||
dependency40.to=MyWorld
|
||||
dependency40.type=UsesDependency
|
||||
dependency41.from=MovingPlattform
|
||||
dependency41.to=MyWorld
|
||||
dependency41.to=Player
|
||||
dependency41.type=UsesDependency
|
||||
dependency42.from=MovingPlattform
|
||||
dependency42.from=TemporaryGround
|
||||
dependency42.to=Player
|
||||
dependency42.type=UsesDependency
|
||||
dependency43.from=TemporaryGround
|
||||
dependency43.to=Player
|
||||
dependency43.from=SpikedPlattform
|
||||
dependency43.to=Spike
|
||||
dependency43.type=UsesDependency
|
||||
dependency44.from=SpikedPlattform
|
||||
dependency44.to=Spike
|
||||
dependency44.to=GameOverWorld
|
||||
dependency44.type=UsesDependency
|
||||
dependency45.from=SpikedPlattform
|
||||
dependency45.to=GameOverWorld
|
||||
dependency45.to=MyWorld
|
||||
dependency45.type=UsesDependency
|
||||
dependency46.from=SpikedPlattform
|
||||
dependency46.to=MyWorld
|
||||
dependency46.to=UnactiveSpike
|
||||
dependency46.type=UsesDependency
|
||||
dependency47.from=SpikedPlattform
|
||||
dependency47.to=UnactiveSpike
|
||||
dependency47.from=TargetingProjectile
|
||||
dependency47.to=Player
|
||||
dependency47.type=UsesDependency
|
||||
dependency48.from=TargetingProjectile
|
||||
dependency48.to=Player
|
||||
dependency48.from=PlayerProjectile
|
||||
dependency48.to=Enemy
|
||||
dependency48.type=UsesDependency
|
||||
dependency49.from=PlayerProjectile
|
||||
dependency49.to=Enemy
|
||||
dependency49.type=UsesDependency
|
||||
dependency5.from=MyWorld
|
||||
dependency5.to=Score
|
||||
dependency5.type=UsesDependency
|
||||
@@ -169,13 +163,13 @@ dependency8.type=UsesDependency
|
||||
dependency9.from=MyWorld
|
||||
dependency9.to=MovingPlattform
|
||||
dependency9.type=UsesDependency
|
||||
editor.fx.0.height=739
|
||||
editor.fx.0.width=816
|
||||
editor.fx.0.x=734
|
||||
editor.fx.0.y=336
|
||||
height=1048
|
||||
package.numDependencies=49
|
||||
package.numTargets=25
|
||||
editor.fx.0.height=737
|
||||
editor.fx.0.width=814
|
||||
editor.fx.0.x=386
|
||||
editor.fx.0.y=48
|
||||
height=830
|
||||
package.numDependencies=48
|
||||
package.numTargets=26
|
||||
project.charset=UTF-8
|
||||
publish.hasSource=false
|
||||
publish.locked=true
|
||||
@@ -189,7 +183,7 @@ readme.name=@README
|
||||
readme.width=49
|
||||
readme.x=10
|
||||
readme.y=10
|
||||
simulation.speed=51
|
||||
simulation.speed=50
|
||||
target1.height=70
|
||||
target1.name=Heart
|
||||
target1.showInterface=false
|
||||
@@ -247,21 +241,21 @@ target16.width=120
|
||||
target16.x=0
|
||||
target16.y=0
|
||||
target17.height=70
|
||||
target17.name=BreakingPlattform
|
||||
target17.name=Healthbar
|
||||
target17.showInterface=false
|
||||
target17.type=ClassTarget
|
||||
target17.width=120
|
||||
target17.x=0
|
||||
target17.y=0
|
||||
target18.height=70
|
||||
target18.name=GameOverWorld
|
||||
target18.name=BreakingPlattform
|
||||
target18.showInterface=false
|
||||
target18.type=ClassTarget
|
||||
target18.width=120
|
||||
target18.x=0
|
||||
target18.y=0
|
||||
target19.height=70
|
||||
target19.name=StartWorld
|
||||
target19.name=GameOverWorld
|
||||
target19.showInterface=false
|
||||
target19.type=ClassTarget
|
||||
target19.width=120
|
||||
@@ -275,47 +269,54 @@ target2.width=120
|
||||
target2.x=0
|
||||
target2.y=0
|
||||
target20.height=70
|
||||
target20.name=Plattform
|
||||
target20.name=StartWorld
|
||||
target20.showInterface=false
|
||||
target20.type=ClassTarget
|
||||
target20.width=120
|
||||
target20.x=0
|
||||
target20.y=0
|
||||
target21.height=70
|
||||
target21.name=Projectile
|
||||
target21.name=Plattform
|
||||
target21.showInterface=false
|
||||
target21.type=ClassTarget
|
||||
target21.width=120
|
||||
target21.x=0
|
||||
target21.y=0
|
||||
target22.height=70
|
||||
target22.name=Score
|
||||
target22.name=Projectile
|
||||
target22.showInterface=false
|
||||
target22.type=ClassTarget
|
||||
target22.width=120
|
||||
target22.x=0
|
||||
target22.y=0
|
||||
target23.height=70
|
||||
target23.name=EnemyProjectile
|
||||
target23.name=Score
|
||||
target23.showInterface=false
|
||||
target23.type=ClassTarget
|
||||
target23.width=120
|
||||
target23.x=0
|
||||
target23.y=0
|
||||
target24.height=70
|
||||
target24.name=PlayerProjectile
|
||||
target24.name=EnemyProjectile
|
||||
target24.showInterface=false
|
||||
target24.type=ClassTarget
|
||||
target24.width=120
|
||||
target24.x=0
|
||||
target24.y=0
|
||||
target25.height=70
|
||||
target25.name=SpikedPlattform
|
||||
target25.name=PlayerProjectile
|
||||
target25.showInterface=false
|
||||
target25.type=ClassTarget
|
||||
target25.width=120
|
||||
target25.x=0
|
||||
target25.y=0
|
||||
target26.height=70
|
||||
target26.name=SpikedPlattform
|
||||
target26.showInterface=false
|
||||
target26.type=ClassTarget
|
||||
target26.width=120
|
||||
target26.x=0
|
||||
target26.y=0
|
||||
target3.height=70
|
||||
target3.name=Ground
|
||||
target3.showInterface=false
|
||||
@@ -366,7 +367,7 @@ target9.width=120
|
||||
target9.x=0
|
||||
target9.y=0
|
||||
version=3.1.0
|
||||
width=1936
|
||||
width=1550
|
||||
world.lastInstantiated=StartWorld
|
||||
xPosition=0
|
||||
yPosition=0
|
||||
|
||||
Reference in New Issue
Block a user