diff --git a/SMIMS-Game/Enemy.ctxt b/SMIMS-Game/Enemy.ctxt index 214f50f..b6b41cc 100644 --- a/SMIMS-Game/Enemy.ctxt +++ b/SMIMS-Game/Enemy.ctxt @@ -1,7 +1,11 @@ #BlueJ class context comment0.target=Enemy -comment1.params= -comment1.target=void\ act() +comment1.params=targetX\ targetY +comment1.target=Enemy(int,\ int) comment2.params= -comment2.target=void\ shootAtPlayer() -numComments=3 +comment2.target=void\ act() +comment3.params=targetX\ targetY +comment3.target=void\ moveToTargetLocation(int,\ int) +comment4.params= +comment4.target=void\ shootAtPlayer() +numComments=5 diff --git a/SMIMS-Game/Groundflower.class b/SMIMS-Game/Groundflower.class index 0d343b5..0874a3f 100644 Binary files a/SMIMS-Game/Groundflower.class and b/SMIMS-Game/Groundflower.class differ diff --git a/SMIMS-Game/Groundflower.ctxt b/SMIMS-Game/Groundflower.ctxt index 973ef36..4fd28d2 100644 --- a/SMIMS-Game/Groundflower.ctxt +++ b/SMIMS-Game/Groundflower.ctxt @@ -6,6 +6,4 @@ comment1.target=void\ act() comment1.text=\r\n\ Act\ -\ do\ whatever\ the\ StarPowerUp\ wants\ to\ do.\ This\ method\ is\ called\ whenever\r\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\r\n comment2.params= comment2.target=void\ collect() -comment3.params= -comment3.target=void\ bewegeNachUnten() -numComments=4 +numComments=3 diff --git a/SMIMS-Game/Groundflower.java b/SMIMS-Game/Groundflower.java index 90de034..266dfad 100644 --- a/SMIMS-Game/Groundflower.java +++ b/SMIMS-Game/Groundflower.java @@ -15,23 +15,16 @@ public class Groundflower extends PowerUps */ public void act() { - bewegeNachUnten(); - this.touchedByPlayer(); - // Add your action code here. + moveDown(); + touchedByPlayer(); + if (deleteAfterActCycle){ + getWorld().removeObject(this); + } } @ Override void collect() { Player player = getIntersectingObjects(Player.class).get(0); - player.reveivePowerUp(duration, "GroundPower"); - } - - public void bewegeNachUnten() - { - this.setLocation(this.getX(), this.getY()+2); - if(this.getY()>=this.getWorld().getHeight()) - { - this.getWorld().removeObject(this); - } + player.receivePowerUp(duration, "GroundPower"); } } diff --git a/SMIMS-Game/HealthItem.class b/SMIMS-Game/HealthItem.class index 7910582..417a134 100644 Binary files a/SMIMS-Game/HealthItem.class and b/SMIMS-Game/HealthItem.class differ diff --git a/SMIMS-Game/HealthItem.java b/SMIMS-Game/HealthItem.java index a927d50..315b0dc 100644 --- a/SMIMS-Game/HealthItem.java +++ b/SMIMS-Game/HealthItem.java @@ -11,11 +11,15 @@ public class HealthItem extends PowerUps int duration = 60*60; public void act() { + moveDown(); touchedByPlayer(); + if (deleteAfterActCycle){ + getWorld().removeObject(this); + } } @Override void collect(){ Player player = getIntersectingObjects(Player.class).get(0); - player.reveivePowerUp(duration, "Heal"); + player.receivePowerUp(duration, "Heal"); } } diff --git a/SMIMS-Game/JumpBoostItem.class b/SMIMS-Game/JumpBoostItem.class index b874d3f..a241d39 100644 Binary files a/SMIMS-Game/JumpBoostItem.class and b/SMIMS-Game/JumpBoostItem.class differ diff --git a/SMIMS-Game/JumpBoostItem.java b/SMIMS-Game/JumpBoostItem.java index 2368462..5188430 100644 --- a/SMIMS-Game/JumpBoostItem.java +++ b/SMIMS-Game/JumpBoostItem.java @@ -11,11 +11,15 @@ public class JumpBoostItem extends PowerUps int duration = 60*60; public void act() { + moveDown(); touchedByPlayer(); + if (deleteAfterActCycle){ + getWorld().removeObject(this); + } } @Override void collect(){ Player player = getIntersectingObjects(Player.class).get(0); - player.reveivePowerUp(duration, "JumpBoost"); + player.receivePowerUp(duration, "JumpBoost"); } } diff --git a/SMIMS-Game/MyWorld.class b/SMIMS-Game/MyWorld.class index bf6cbed..11455a4 100644 Binary files a/SMIMS-Game/MyWorld.class and b/SMIMS-Game/MyWorld.class differ diff --git a/SMIMS-Game/MyWorld.ctxt b/SMIMS-Game/MyWorld.ctxt index 2a6810e..fe75749 100644 --- a/SMIMS-Game/MyWorld.ctxt +++ b/SMIMS-Game/MyWorld.ctxt @@ -10,9 +10,11 @@ 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\ projectile() +comment4.target=void\ spawnEnemies() comment5.params= -comment5.target=void\ targetingProjectile() +comment5.target=void\ projectile() comment6.params= -comment6.target=void\ showScore() -numComments=7 +comment6.target=void\ targetingProjectile() +comment7.params= +comment7.target=void\ showScore() +numComments=8 diff --git a/SMIMS-Game/MyWorld.java b/SMIMS-Game/MyWorld.java index 456b66d..4e70578 100644 --- a/SMIMS-Game/MyWorld.java +++ b/SMIMS-Game/MyWorld.java @@ -13,6 +13,7 @@ public class MyWorld extends World //kann später noch beliebig angepasst werden int targetTimer = 1000; int time = 0; + int enemyTimer; int score = 0; /** * Constructor for objects of class MyWorld. @@ -64,6 +65,8 @@ public class MyWorld extends World addObject(heart2,343,27); Heart heart3 = new Heart(); addObject(heart3,314,27); + + addObject(new TemporaryGround(60*50), 200, 575); } public void act() @@ -79,6 +82,7 @@ public class MyWorld extends World score1.setImage("Score2.png"); showScore(); projectile(); + spawnEnemies(); targetingProjectile(); if(PlattformCountdown==0) //Damit in regelmäßigen Abständen auf jeden Fall eine Plattform auftaucht { @@ -107,8 +111,22 @@ public class MyWorld extends World addObject(new SpikedPlattform(100), Greenfoot.getRandomNumber(400), 6); //Nach Links bewegende Plattform } + if(Greenfoot.getRandomNumber(100000)>=99750) + { + addObject(new Groundflower(), Greenfoot.getRandomNumber(400), 6); //Nach Links bewegende Plattform + } } + + public void spawnEnemies(){ + enemyTimer++; + if (enemyTimer == 420){ + Enemy enemy = new Enemy(Greenfoot.getRandomNumber(getWidth()), Greenfoot.getRandomNumber(getHeight()/2)); + addObject(enemy, Greenfoot.getRandomNumber(300)+50,0); + enemyTimer = 0; + } + + } public void projectile(){ if(timer == 0){ Projectile projectile = new Projectile(); diff --git a/SMIMS-Game/Plattform.class b/SMIMS-Game/Plattform.class index fe23c79..870c595 100644 Binary files a/SMIMS-Game/Plattform.class and b/SMIMS-Game/Plattform.class differ diff --git a/SMIMS-Game/Plattform.java b/SMIMS-Game/Plattform.java index bc4312b..64ea5f9 100644 --- a/SMIMS-Game/Plattform.java +++ b/SMIMS-Game/Plattform.java @@ -43,7 +43,7 @@ public class Plattform extends Actor Player Spieler= (Player) getOneIntersectingObject(Player.class); if(this.isTouching(Player.class)) { - if(Spieler.getY() 0){ collect(); - getWorld().removeObject(this); + deleteAfterActCycle = true; } } void collect(){ Player player = getIntersectingObjects(Player.class).get(0); - player.reveivePowerUp(duration, "dummy"); + player.receivePowerUp(duration, "dummy"); + } + + public void moveDown() + { + this.setLocation(this.getX(), this.getY()+2); + if(this.getY()>=this.getWorld().getHeight()) + { + deleteAfterActCycle = true; + } } } diff --git a/SMIMS-Game/TemporaryGround.class b/SMIMS-Game/TemporaryGround.class index 5e2ff6b..d9c1db0 100644 Binary files a/SMIMS-Game/TemporaryGround.class and b/SMIMS-Game/TemporaryGround.class differ diff --git a/SMIMS-Game/TemporaryGround.ctxt b/SMIMS-Game/TemporaryGround.ctxt index 6babc9e..04dbe05 100644 --- a/SMIMS-Game/TemporaryGround.ctxt +++ b/SMIMS-Game/TemporaryGround.ctxt @@ -12,4 +12,6 @@ comment4.params= comment4.target=void\ noMoreWarning() comment5.params=pDuration comment5.target=void\ RefreshLifeToDuration(int) -numComments=6 +comment6.params= +comment6.target=void\ Buffer() +numComments=7 diff --git a/SMIMS-Game/TemporaryGround.java b/SMIMS-Game/TemporaryGround.java index 9d83b38..8709cc6 100644 --- a/SMIMS-Game/TemporaryGround.java +++ b/SMIMS-Game/TemporaryGround.java @@ -23,6 +23,7 @@ public class TemporaryGround extends Plattform public void act() { // Add your action code here. + this.Buffer(); Lebensdauer--; if(Lebensdauer==0) { @@ -56,4 +57,15 @@ public class TemporaryGround extends Plattform { Lebensdauer=pDuration; } + + public void Buffer() + { + { + Player player= this.getWorld().getObjects(Player.class).get(0); + if(this.intersects(player)) + { + player.setLocation(player.getX(), this.getY()-this.getImage().getHeight()); + } + } + } } diff --git a/SMIMS-Game/images/Spike_Copy.png b/SMIMS-Game/images/Spike_Copy.png index 33399b9..eeb0105 100644 Binary files a/SMIMS-Game/images/Spike_Copy.png and b/SMIMS-Game/images/Spike_Copy.png differ diff --git a/SMIMS-Game/project.greenfoot b/SMIMS-Game/project.greenfoot index 49d3f7a..63df7cd 100644 --- a/SMIMS-Game/project.greenfoot +++ b/SMIMS-Game/project.greenfoot @@ -1,22 +1,26 @@ #Greenfoot project file class.BreakingPlattform.image=Breaking1.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 +class.HealthItem.image=Health.png class.Heart.image=Health.png class.JumpBoostItem.image=mushroom.png class.MovingPlattform.image=Platform1.png class.MyWorld.image=GameBackground.png class.Plattform.image=Platform1.png class.Player.image=Player.png +class.PlayerProjectile.image=beeper.png class.Projectile.image=Projectile1.png class.Spike.image=singleSpike.png class.SpikedPlattform.image=Spikes2.png class.StartWorld.image=StartBackground.png class.TargetingProjectile.image=blue-draught.png class.UnactiveSpike.image=inactiveSpike.png -dependency1.from=GameOverWorld -dependency1.to=Button +dependency1.from=PlayerTestWorld +dependency1.to=Ground dependency1.type=UsesDependency dependency10.from=MyWorld dependency10.to=MovingPlattform @@ -28,126 +32,147 @@ dependency12.from=MyWorld dependency12.to=SpikedPlattform dependency12.type=UsesDependency dependency13.from=MyWorld -dependency13.to=Projectile +dependency13.to=Groundflower dependency13.type=UsesDependency dependency14.from=MyWorld -dependency14.to=TargetingProjectile +dependency14.to=Enemy dependency14.type=UsesDependency -dependency15.from=Spike -dependency15.to=GameOverWorld +dependency15.from=MyWorld +dependency15.to=Projectile dependency15.type=UsesDependency -dependency16.from=Spike -dependency16.to=MyWorld +dependency16.from=MyWorld +dependency16.to=TargetingProjectile dependency16.type=UsesDependency -dependency17.from=Spike -dependency17.to=Player +dependency17.from=GameOverWorld +dependency17.to=Button dependency17.type=UsesDependency -dependency18.from=Player -dependency18.to=GameOverWorld +dependency18.from=StartWorld +dependency18.to=Button dependency18.type=UsesDependency -dependency19.from=Player -dependency19.to=Plattform +dependency19.from=UnactiveSpike +dependency19.to=SpikedPlattform dependency19.type=UsesDependency dependency2.from=PlayerTestWorld -dependency2.to=Ground +dependency2.to=Player dependency2.type=UsesDependency -dependency20.from=Player -dependency20.to=PlayerProjectile +dependency20.from=UnactiveSpike +dependency20.to=MyWorld dependency20.type=UsesDependency -dependency21.from=Player -dependency21.to=Projectile +dependency21.from=UnactiveSpike +dependency21.to=Spike dependency21.type=UsesDependency -dependency22.from=Player -dependency22.to=Enemy +dependency22.from=Button +dependency22.to=MyWorld dependency22.type=UsesDependency -dependency23.from=Player -dependency23.to=Spike +dependency23.from=PowerUps +dependency23.to=Player dependency23.type=UsesDependency -dependency24.from=Player -dependency24.to=Heart +dependency24.from=HealthItem +dependency24.to=Player dependency24.type=UsesDependency -dependency25.from=UnactiveSpike -dependency25.to=SpikedPlattform +dependency25.from=JumpBoostItem +dependency25.to=Player dependency25.type=UsesDependency -dependency26.from=UnactiveSpike -dependency26.to=MyWorld +dependency26.from=Groundflower +dependency26.to=Player dependency26.type=UsesDependency -dependency27.from=UnactiveSpike -dependency27.to=Spike +dependency27.from=Enemy +dependency27.to=Player dependency27.type=UsesDependency -dependency28.from=Plattform -dependency28.to=MyWorld +dependency28.from=Enemy +dependency28.to=EnemyProjectile dependency28.type=UsesDependency -dependency29.from=Plattform -dependency29.to=Player +dependency29.from=Spike +dependency29.to=MyWorld dependency29.type=UsesDependency dependency3.from=PlayerTestWorld -dependency3.to=Player +dependency3.to=JumpBoostItem dependency3.type=UsesDependency -dependency30.from=MovingPlattform -dependency30.to=MyWorld +dependency30.from=Player +dependency30.to=GameOverWorld dependency30.type=UsesDependency -dependency31.from=MovingPlattform -dependency31.to=Player +dependency31.from=Player +dependency31.to=Plattform dependency31.type=UsesDependency -dependency32.from=SpikedPlattform -dependency32.to=Spike +dependency32.from=Player +dependency32.to=PlayerProjectile dependency32.type=UsesDependency -dependency33.from=SpikedPlattform -dependency33.to=GameOverWorld +dependency33.from=Player +dependency33.to=TemporaryGround dependency33.type=UsesDependency -dependency34.from=SpikedPlattform -dependency34.to=MyWorld +dependency34.from=Player +dependency34.to=Projectile dependency34.type=UsesDependency -dependency35.from=SpikedPlattform -dependency35.to=UnactiveSpike +dependency35.from=Player +dependency35.to=Enemy dependency35.type=UsesDependency -dependency36.from=TargetingProjectile -dependency36.to=Player +dependency36.from=Player +dependency36.to=Spike dependency36.type=UsesDependency -dependency37.from=Button -dependency37.to=MyWorld +dependency37.from=Player +dependency37.to=Heart dependency37.type=UsesDependency -dependency38.from=PowerUps +dependency38.from=Healthbar dependency38.to=Player dependency38.type=UsesDependency -dependency39.from=JumpBoostItem -dependency39.to=Player +dependency39.from=Plattform +dependency39.to=MyWorld dependency39.type=UsesDependency -dependency4.from=PlayerTestWorld -dependency4.to=JumpBoostItem +dependency4.from=MyWorld +dependency4.to=Player dependency4.type=UsesDependency -dependency40.from=Enemy +dependency40.from=Plattform dependency40.to=Player dependency40.type=UsesDependency -dependency41.from=Enemy -dependency41.to=EnemyProjectile +dependency41.from=MovingPlattform +dependency41.to=MyWorld dependency41.type=UsesDependency -dependency42.from=PlayerProjectile -dependency42.to=Enemy +dependency42.from=MovingPlattform +dependency42.to=Player dependency42.type=UsesDependency -dependency5.from=StartWorld -dependency5.to=Button +dependency43.from=TemporaryGround +dependency43.to=Player +dependency43.type=UsesDependency +dependency44.from=SpikedPlattform +dependency44.to=Spike +dependency44.type=UsesDependency +dependency45.from=SpikedPlattform +dependency45.to=GameOverWorld +dependency45.type=UsesDependency +dependency46.from=SpikedPlattform +dependency46.to=MyWorld +dependency46.type=UsesDependency +dependency47.from=SpikedPlattform +dependency47.to=UnactiveSpike +dependency47.type=UsesDependency +dependency48.from=TargetingProjectile +dependency48.to=Player +dependency48.type=UsesDependency +dependency49.from=PlayerProjectile +dependency49.to=Enemy +dependency49.type=UsesDependency +dependency5.from=MyWorld +dependency5.to=Score dependency5.type=UsesDependency dependency6.from=MyWorld -dependency6.to=Player +dependency6.to=Plattform dependency6.type=UsesDependency dependency7.from=MyWorld -dependency7.to=Score +dependency7.to=Healthbar dependency7.type=UsesDependency dependency8.from=MyWorld -dependency8.to=Plattform +dependency8.to=Heart dependency8.type=UsesDependency dependency9.from=MyWorld -dependency9.to=Heart +dependency9.to=TemporaryGround dependency9.type=UsesDependency editor.fx.0.height=737 editor.fx.0.width=814 -editor.fx.0.x=535 -editor.fx.0.y=44 +editor.fx.0.x=444 +editor.fx.0.y=78 height=830 -package.numDependencies=42 -package.numTargets=22 +package.numDependencies=49 +package.numTargets=26 project.charset=UTF-8 publish.hasSource=false publish.locked=true @@ -163,154 +188,182 @@ readme.x=10 readme.y=10 simulation.speed=50 target1.height=70 -target1.name=Spike +target1.name=Heart target1.showInterface=false target1.type=ClassTarget target1.width=120 target1.x=0 target1.y=0 target10.height=70 -target10.name=PlayerTestWorld +target10.name=Button target10.showInterface=false target10.type=ClassTarget target10.width=120 target10.x=0 target10.y=0 target11.height=70 -target11.name=StartWorld +target11.name=PowerUps target11.showInterface=false target11.type=ClassTarget target11.width=120 target11.x=0 target11.y=0 target12.height=70 -target12.name=Plattform +target12.name=Enemy target12.showInterface=false target12.type=ClassTarget target12.width=120 target12.x=0 target12.y=0 target13.height=70 -target13.name=TargetingProjectile +target13.name=MyWorld target13.showInterface=false target13.type=ClassTarget target13.width=120 target13.x=0 target13.y=0 target14.height=70 -target14.name=Projectile +target14.name=Spike target14.showInterface=false target14.type=ClassTarget target14.width=120 target14.x=0 target14.y=0 target15.height=70 -target15.name=Score +target15.name=Groundflower target15.showInterface=false target15.type=ClassTarget target15.width=120 target15.x=0 target15.y=0 target16.height=70 -target16.name=Button +target16.name=Player target16.showInterface=false target16.type=ClassTarget target16.width=120 target16.x=0 target16.y=0 target17.height=70 -target17.name=EnemyProjectile +target17.name=Healthbar target17.showInterface=false target17.type=ClassTarget target17.width=120 target17.x=0 target17.y=0 target18.height=70 -target18.name=PowerUps +target18.name=BreakingPlattform target18.showInterface=false target18.type=ClassTarget target18.width=120 target18.x=0 target18.y=0 target19.height=70 -target19.name=Enemy +target19.name=GameOverWorld target19.showInterface=false target19.type=ClassTarget target19.width=120 target19.x=0 target19.y=0 target2.height=70 -target2.name=Heart +target2.name=MovingPlattform target2.showInterface=false target2.type=ClassTarget target2.width=120 target2.x=0 target2.y=0 target20.height=70 -target20.name=PlayerProjectile +target20.name=StartWorld target20.showInterface=false target20.type=ClassTarget target20.width=120 target20.x=0 target20.y=0 target21.height=70 -target21.name=SpikedPlattform +target21.name=Plattform target21.showInterface=false target21.type=ClassTarget target21.width=120 target21.x=0 target21.y=0 target22.height=70 -target22.name=MyWorld +target22.name=Projectile target22.showInterface=false target22.type=ClassTarget target22.width=120 target22.x=0 target22.y=0 +target23.height=70 +target23.name=Score +target23.showInterface=false +target23.type=ClassTarget +target23.width=120 +target23.x=0 +target23.y=0 +target24.height=70 +target24.name=EnemyProjectile +target24.showInterface=false +target24.type=ClassTarget +target24.width=120 +target24.x=0 +target24.y=0 +target25.height=70 +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=Player +target3.name=Ground target3.showInterface=false target3.type=ClassTarget target3.width=120 target3.x=0 target3.y=0 target4.height=70 -target4.name=MovingPlattform +target4.name=HealthItem target4.showInterface=false target4.type=ClassTarget target4.width=120 target4.x=0 target4.y=0 target5.height=70 -target5.name=Ground +target5.name=UnactiveSpike target5.showInterface=false target5.type=ClassTarget target5.width=120 target5.x=0 target5.y=0 target6.height=70 -target6.name=UnactiveSpike +target6.name=JumpBoostItem target6.showInterface=false target6.type=ClassTarget target6.width=120 target6.x=0 target6.y=0 target7.height=70 -target7.name=JumpBoostItem +target7.name=PlayerTestWorld target7.showInterface=false target7.type=ClassTarget target7.width=120 target7.x=0 target7.y=0 target8.height=70 -target8.name=BreakingPlattform +target8.name=TargetingProjectile target8.showInterface=false target8.type=ClassTarget target8.width=120 target8.x=0 target8.y=0 target9.height=70 -target9.name=GameOverWorld +target9.name=TemporaryGround target9.showInterface=false target9.type=ClassTarget target9.width=120 @@ -318,6 +371,6 @@ target9.x=0 target9.y=0 version=3.1.0 width=1550 -world.lastInstantiated=StartWorld +world.lastInstantiated=MyWorld xPosition=0 yPosition=0