diff --git a/SMIMS-Game/BreakingPlattform.java b/SMIMS-Game/BreakingPlattform.java index 64bfea4..ef60cdf 100644 --- a/SMIMS-Game/BreakingPlattform.java +++ b/SMIMS-Game/BreakingPlattform.java @@ -25,7 +25,7 @@ public class BreakingPlattform extends Plattform { IsBreaking= true; //Greenfoot.playSound("...") - this.setImage("BreakingPlattform2.png"); //untested + this.setImage("BreakingPlattform2.png"); } if(IsBreaking) diff --git a/SMIMS-Game/Groundflower.class b/SMIMS-Game/Groundflower.class new file mode 100644 index 0000000..0d343b5 Binary files /dev/null and b/SMIMS-Game/Groundflower.class differ diff --git a/SMIMS-Game/Groundflower.ctxt b/SMIMS-Game/Groundflower.ctxt new file mode 100644 index 0000000..973ef36 --- /dev/null +++ b/SMIMS-Game/Groundflower.ctxt @@ -0,0 +1,11 @@ +#BlueJ class context +comment0.target=Groundflower +comment0.text=\r\n\ Write\ a\ description\ of\ class\ StarPowerUp\ here.\r\n\ \r\n\ @author\ (your\ name)\ \r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n +comment1.params= +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 diff --git a/SMIMS-Game/Groundflower.java b/SMIMS-Game/Groundflower.java new file mode 100644 index 0000000..90de034 --- /dev/null +++ b/SMIMS-Game/Groundflower.java @@ -0,0 +1,37 @@ +import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) + +/** + * Write a description of class StarPowerUp here. + * + * @author (your name) + * @version (a version number or a date) + */ +public class Groundflower extends PowerUps +{ + int duration= 60*8; //15 Sekunden + /** + * Act - do whatever the StarPowerUp wants to do. This method is called whenever + * the 'Act' or 'Run' button gets pressed in the environment. + */ + public void act() + { + bewegeNachUnten(); + this.touchedByPlayer(); + // Add your action code here. + } + + @ 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); + } + } +} diff --git a/SMIMS-Game/MyWorld.class b/SMIMS-Game/MyWorld.class index e1c9b02..a2634ef 100644 Binary files a/SMIMS-Game/MyWorld.class and b/SMIMS-Game/MyWorld.class differ diff --git a/SMIMS-Game/MyWorld.java b/SMIMS-Game/MyWorld.java index 2d78cda..1bc35f2 100644 --- a/SMIMS-Game/MyWorld.java +++ b/SMIMS-Game/MyWorld.java @@ -50,6 +50,7 @@ public class MyWorld extends World plattform2.setLocation(320,367); plattform2.setLocation(312,371); plattform2.setLocation(308,382); + } public void act() @@ -83,6 +84,7 @@ public class MyWorld extends World addObject(new SpikedPlattform(100), Greenfoot.getRandomNumber(400), 6); //Nach Links bewegende Plattform } + } public void projectile(){ diff --git a/SMIMS-Game/Player.class b/SMIMS-Game/Player.class index f00f6aa..4d3d469 100644 Binary files a/SMIMS-Game/Player.class and b/SMIMS-Game/Player.class differ diff --git a/SMIMS-Game/Player.java b/SMIMS-Game/Player.java index 0fbc75f..508b721 100644 --- a/SMIMS-Game/Player.java +++ b/SMIMS-Game/Player.java @@ -10,10 +10,10 @@ public class Player extends Actor { int jumpBoostDuration = -1; int jumpBoostStrength = 5; - + boolean projectileReady = false; int projectileTimer; - + private int speed = 6; private int currentJumpStrength; private int defaultJumpStrength = 15; @@ -30,7 +30,7 @@ public class Player extends Actor fall(); handlePowerUps(); shootProjectile(); - + //Check ob der Spieler am unteren Fensterrand ist if (getY()+1 >= getWorld().getHeight()){ Greenfoot.setWorld(new GameOverWorld()); @@ -89,8 +89,8 @@ public class Player extends Actor } } onGround = landed; - } - + } + public void shootProjectile(){ projectileTimer++; MouseInfo mouse = Greenfoot.getMouseInfo(); @@ -118,7 +118,7 @@ public class Player extends Actor return false; } } - + public void handlePowerUps(){ if (jumpBoostDuration >= 0){ jumpBoostDuration -= 1; @@ -126,7 +126,7 @@ public class Player extends Actor currentJumpStrength = defaultJumpStrength; } } - + public void reveivePowerUp(int duration, String type){ switch(type){ case "dummy": @@ -135,6 +135,16 @@ public class Player extends Actor currentJumpStrength = defaultJumpStrength; currentJumpStrength += jumpBoostStrength; jumpBoostDuration = duration; + case "GroundPower": + World theWorld= this.getWorld(); + if(!theWorld.getObjects(TemporaryGround.class).isEmpty()) + { + theWorld.getObjects(TemporaryGround.class).get(0).RefreshLifeToDuration(duration); + } + else + { + theWorld.addObject((new TemporaryGround(duration)), 200, 550); + } } } } diff --git a/SMIMS-Game/TemporaryGround.class b/SMIMS-Game/TemporaryGround.class new file mode 100644 index 0000000..5e2ff6b Binary files /dev/null and b/SMIMS-Game/TemporaryGround.class differ diff --git a/SMIMS-Game/TemporaryGround.ctxt b/SMIMS-Game/TemporaryGround.ctxt new file mode 100644 index 0000000..6babc9e --- /dev/null +++ b/SMIMS-Game/TemporaryGround.ctxt @@ -0,0 +1,15 @@ +#BlueJ class context +comment0.target=TemporaryGround +comment0.text=\r\n\ Write\ a\ description\ of\ class\ TemporaryGround\ here.\r\n\ \r\n\ @author\ (your\ name)\ \r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n +comment1.params=pLebensdauer +comment1.target=TemporaryGround(int) +comment2.params= +comment2.target=void\ act() +comment2.text=\r\n\ Act\ -\ do\ whatever\ the\ TemporaryGround\ wants\ to\ do.\ This\ method\ is\ called\ whenever\r\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\r\n +comment3.params= +comment3.target=void\ warning() +comment4.params= +comment4.target=void\ noMoreWarning() +comment5.params=pDuration +comment5.target=void\ RefreshLifeToDuration(int) +numComments=6 diff --git a/SMIMS-Game/TemporaryGround.java b/SMIMS-Game/TemporaryGround.java new file mode 100644 index 0000000..9d83b38 --- /dev/null +++ b/SMIMS-Game/TemporaryGround.java @@ -0,0 +1,59 @@ +import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) + +/** + * Write a description of class TemporaryGround here. + * + * @author (your name) + * @version (a version number or a date) + */ +public class TemporaryGround extends Plattform +{ + private int Lebensdauer; + boolean warningHasHappend=false; + boolean deWarningHasHappend=true; + public TemporaryGround(int pLebensdauer) + { + Lebensdauer=pLebensdauer; + } + + /** + * Act - do whatever the TemporaryGround wants to do. This method is called whenever + * the 'Act' or 'Run' button gets pressed in the environment. + */ + public void act() + { + // Add your action code here. + Lebensdauer--; + if(Lebensdauer==0) + { + this.loescheMich(); + } + if(Lebensdauer<60*3 && warningHasHappend==false) //3 Sekunden + { + this.warning(); + } + if(Lebensdauer>=60*3 && deWarningHasHappend==false) + { + this.noMoreWarning(); + } + } + + public void warning() + { + this.setImage("TemporaryIsBreaking.png"); + warningHasHappend=true; + deWarningHasHappend=false; + } + + public void noMoreWarning() + { + this.setImage("TemporaryGround.png"); + warningHasHappend=false; + deWarningHasHappend=true; + } + + public void RefreshLifeToDuration(int pDuration) + { + Lebensdauer=pDuration; + } +} diff --git a/SMIMS-Game/images/PlattformStart_Copy.png b/SMIMS-Game/images/PlattformStart_Copy.png new file mode 100644 index 0000000..b4e3c7f Binary files /dev/null and b/SMIMS-Game/images/PlattformStart_Copy.png differ diff --git a/SMIMS-Game/images/TemporaryGround.png b/SMIMS-Game/images/TemporaryGround.png new file mode 100644 index 0000000..e7d75f6 Binary files /dev/null and b/SMIMS-Game/images/TemporaryGround.png differ diff --git a/SMIMS-Game/images/TemporaryIsBreaking.jpg b/SMIMS-Game/images/TemporaryIsBreaking.jpg new file mode 100644 index 0000000..d4012ed Binary files /dev/null and b/SMIMS-Game/images/TemporaryIsBreaking.jpg differ diff --git a/SMIMS-Game/images/TemporaryIsBreaking.png b/SMIMS-Game/images/TemporaryIsBreaking.png new file mode 100644 index 0000000..e6cd9be Binary files /dev/null and b/SMIMS-Game/images/TemporaryIsBreaking.png differ diff --git a/SMIMS-Game/project.greenfoot b/SMIMS-Game/project.greenfoot index dcc22de..799973b 100644 --- a/SMIMS-Game/project.greenfoot +++ b/SMIMS-Game/project.greenfoot @@ -1,85 +1,128 @@ #Greenfoot project file class.BreakingPlattform.image=Unbenannt2.png -class.Button.image=button-red.png -class.GameOverWorld.image=GameOverBackground.png class.Ground.image=weave.jpg -class.JumpBoostItem.image=mushroom.png +class.Groundflower.image=beeper.png class.MovingPlattform.image=Unbenannt.png -class.MyWorld.image=GameBackground.png class.Plattform.image=Plattform.png class.Player.image=ppl2.png -class.Projectile.image=Projectile1.png class.Spike.image=Spike.png class.SpikedPlattform.image=SpikedPlattform.png -class.StartWorld.image=StartBackground.png -class.TargetingProjectile.image=blue-draught.png -class.UnactiveSpike.image=SpikeUnactive.png +class.TemporaryGround.image=TemporaryGround.png +class.UnactiveSpike.image=Spike_Copy.png dependency1.from=GameOverWorld dependency1.to=Button dependency1.type=UsesDependency dependency10.from=MyWorld -dependency10.to=BreakingPlattform +dependency10.to=MovingPlattform dependency10.type=UsesDependency dependency11.from=MyWorld -dependency11.to=Projectile +dependency11.to=BreakingPlattform dependency11.type=UsesDependency dependency12.from=MyWorld -dependency12.to=TargetingProjectile +dependency12.to=SpikedPlattform dependency12.type=UsesDependency -dependency13.from=Spike -dependency13.to=GameOverWorld +dependency13.from=MyWorld +dependency13.to=Groundflower dependency13.type=UsesDependency -dependency14.from=Spike -dependency14.to=Player +dependency14.from=MyWorld +dependency14.to=Projectile dependency14.type=UsesDependency -dependency15.from=Player -dependency15.to=GameOverWorld +dependency15.from=MyWorld +dependency15.to=TargetingProjectile dependency15.type=UsesDependency -dependency16.from=Player -dependency16.to=Plattform +dependency16.from=Spike +dependency16.to=GameOverWorld dependency16.type=UsesDependency -dependency17.from=Player -dependency17.to=Projectile +dependency17.from=Spike +dependency17.to=MyWorld dependency17.type=UsesDependency -dependency18.from=Plattform -dependency18.to=MyWorld +dependency18.from=Spike +dependency18.to=Player dependency18.type=UsesDependency -dependency19.from=Plattform -dependency19.to=Player +dependency19.from=Player +dependency19.to=GameOverWorld dependency19.type=UsesDependency dependency2.from=PlayerTestWorld dependency2.to=Ground dependency2.type=UsesDependency -dependency20.from=MovingPlattform -dependency20.to=MyWorld +dependency20.from=Player +dependency20.to=Plattform dependency20.type=UsesDependency -dependency21.from=SpikedPlattform -dependency21.to=Spike +dependency21.from=Player +dependency21.to=PlayerProjectile dependency21.type=UsesDependency -dependency22.from=SpikedPlattform -dependency22.to=GameOverWorld +dependency22.from=Player +dependency22.to=TemporaryGround dependency22.type=UsesDependency -dependency23.from=SpikedPlattform -dependency23.to=MyWorld +dependency23.from=Player +dependency23.to=Projectile dependency23.type=UsesDependency -dependency24.from=TargetingProjectile -dependency24.to=Player +dependency24.from=Player +dependency24.to=Enemy dependency24.type=UsesDependency -dependency25.from=Button -dependency25.to=MyWorld +dependency25.from=UnactiveSpike +dependency25.to=SpikedPlattform dependency25.type=UsesDependency -dependency26.from=PowerUps -dependency26.to=Player +dependency26.from=UnactiveSpike +dependency26.to=MyWorld dependency26.type=UsesDependency -dependency27.from=JumpBoostItem -dependency27.to=Player +dependency27.from=UnactiveSpike +dependency27.to=Spike dependency27.type=UsesDependency +dependency28.from=Plattform +dependency28.to=MyWorld +dependency28.type=UsesDependency +dependency29.from=Plattform +dependency29.to=Player +dependency29.type=UsesDependency dependency3.from=PlayerTestWorld dependency3.to=Player dependency3.type=UsesDependency +dependency30.from=MovingPlattform +dependency30.to=MyWorld +dependency30.type=UsesDependency +dependency31.from=MovingPlattform +dependency31.to=Player +dependency31.type=UsesDependency +dependency32.from=SpikedPlattform +dependency32.to=Spike +dependency32.type=UsesDependency +dependency33.from=SpikedPlattform +dependency33.to=GameOverWorld +dependency33.type=UsesDependency +dependency34.from=SpikedPlattform +dependency34.to=MyWorld +dependency34.type=UsesDependency +dependency35.from=SpikedPlattform +dependency35.to=UnactiveSpike +dependency35.type=UsesDependency +dependency36.from=TargetingProjectile +dependency36.to=Player +dependency36.type=UsesDependency +dependency37.from=Button +dependency37.to=MyWorld +dependency37.type=UsesDependency +dependency38.from=PowerUps +dependency38.to=Player +dependency38.type=UsesDependency +dependency39.from=Groundflower +dependency39.to=Player +dependency39.type=UsesDependency dependency4.from=PlayerTestWorld dependency4.to=JumpBoostItem dependency4.type=UsesDependency +dependency40.from=JumpBoostItem +dependency40.to=Player +dependency40.type=UsesDependency +dependency41.from=Enemy +dependency41.to=Player +dependency41.type=UsesDependency +dependency42.from=Enemy +dependency42.to=EnemyProjectile +dependency42.type=UsesDependency +dependency43.from=PlayerProjectile +dependency43.to=Enemy +dependency43.type=UsesDependency dependency5.from=StartWorld dependency5.to=Button dependency5.type=UsesDependency @@ -93,15 +136,15 @@ dependency8.from=MyWorld dependency8.to=Plattform dependency8.type=UsesDependency dependency9.from=MyWorld -dependency9.to=MovingPlattform +dependency9.to=TemporaryGround dependency9.type=UsesDependency -editor.fx.0.height=737 -editor.fx.0.width=814 -editor.fx.0.x=360 -editor.fx.0.y=26 -height=830 -package.numDependencies=27 -package.numTargets=18 +editor.fx.0.height=739 +editor.fx.0.width=816 +editor.fx.0.x=869 +editor.fx.0.y=190 +height=1048 +package.numDependencies=43 +package.numTargets=23 project.charset=UTF-8 publish.hasSource=false publish.locked=true @@ -124,68 +167,75 @@ target1.width=120 target1.x=0 target1.y=0 target10.height=70 -target10.name=StartWorld +target10.name=PlayerTestWorld target10.showInterface=false target10.type=ClassTarget target10.width=120 target10.x=0 target10.y=0 target11.height=70 -target11.name=Plattform +target11.name=StartWorld target11.showInterface=false target11.type=ClassTarget target11.width=120 target11.x=0 target11.y=0 target12.height=70 -target12.name=TargetingProjectile +target12.name=Plattform target12.showInterface=false target12.type=ClassTarget target12.width=120 target12.x=0 target12.y=0 target13.height=70 -target13.name=Projectile +target13.name=TargetingProjectile target13.showInterface=false target13.type=ClassTarget target13.width=120 target13.x=0 target13.y=0 target14.height=70 -target14.name=Score +target14.name=Projectile target14.showInterface=false target14.type=ClassTarget target14.width=120 target14.x=0 target14.y=0 target15.height=70 -target15.name=Button +target15.name=TemporaryGround target15.showInterface=false target15.type=ClassTarget target15.width=120 target15.x=0 target15.y=0 target16.height=70 -target16.name=PowerUps +target16.name=Score target16.showInterface=false target16.type=ClassTarget target16.width=120 target16.x=0 target16.y=0 target17.height=70 -target17.name=SpikedPlattform +target17.name=Button target17.showInterface=false target17.type=ClassTarget target17.width=120 target17.x=0 target17.y=0 target18.height=70 -target18.name=MyWorld +target18.name=EnemyProjectile target18.showInterface=false target18.type=ClassTarget target18.width=120 target18.x=0 target18.y=0 +target19.height=70 +target19.name=PowerUps +target19.showInterface=false +target19.type=ClassTarget +target19.width=120 +target19.x=0 +target19.y=0 target2.height=70 target2.name=Player target2.showInterface=false @@ -193,57 +243,85 @@ target2.type=ClassTarget target2.width=120 target2.x=0 target2.y=0 +target20.height=70 +target20.name=Enemy +target20.showInterface=false +target20.type=ClassTarget +target20.width=120 +target20.x=0 +target20.y=0 +target21.height=70 +target21.name=PlayerProjectile +target21.showInterface=false +target21.type=ClassTarget +target21.width=120 +target21.x=0 +target21.y=0 +target22.height=70 +target22.name=SpikedPlattform +target22.showInterface=false +target22.type=ClassTarget +target22.width=120 +target22.x=0 +target22.y=0 +target23.height=70 +target23.name=MyWorld +target23.showInterface=false +target23.type=ClassTarget +target23.width=120 +target23.x=0 +target23.y=0 target3.height=70 -target3.name=MovingPlattform +target3.name=Groundflower target3.showInterface=false target3.type=ClassTarget target3.width=120 target3.x=0 target3.y=0 target4.height=70 -target4.name=Ground +target4.name=MovingPlattform target4.showInterface=false target4.type=ClassTarget target4.width=120 target4.x=0 target4.y=0 target5.height=70 -target5.name=UnactiveSpike +target5.name=Ground target5.showInterface=false target5.type=ClassTarget target5.width=120 target5.x=0 target5.y=0 target6.height=70 -target6.name=JumpBoostItem +target6.name=UnactiveSpike target6.showInterface=false target6.type=ClassTarget target6.width=120 target6.x=0 target6.y=0 target7.height=70 -target7.name=BreakingPlattform +target7.name=JumpBoostItem target7.showInterface=false target7.type=ClassTarget target7.width=120 target7.x=0 target7.y=0 target8.height=70 -target8.name=GameOverWorld +target8.name=BreakingPlattform target8.showInterface=false target8.type=ClassTarget target8.width=120 target8.x=0 target8.y=0 target9.height=70 -target9.name=PlayerTestWorld +target9.name=GameOverWorld target9.showInterface=false target9.type=ClassTarget target9.width=120 target9.x=0 target9.y=0 version=3.1.0 -width=1550 -world.lastInstantiated=MyWorld +width=1936 +world.lastInstantiated=StartWorld xPosition=0 yPosition=0