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/MovingPlattform.class b/SMIMS-Game/MovingPlattform.class index 39c1d00..074496b 100644 Binary files a/SMIMS-Game/MovingPlattform.class and b/SMIMS-Game/MovingPlattform.class differ diff --git a/SMIMS-Game/MovingPlattform.java b/SMIMS-Game/MovingPlattform.java index 7f6008c..ee1b3b7 100644 --- a/SMIMS-Game/MovingPlattform.java +++ b/SMIMS-Game/MovingPlattform.java @@ -9,7 +9,7 @@ import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) public class MovingPlattform extends Plattform { int speed; - + int temp=0; public MovingPlattform(int pSpeed) { speed= pSpeed; @@ -42,10 +42,11 @@ public class MovingPlattform extends Plattform { if(this.PlayerOnPlattform()) { - Actor DerSpieler = this.getOneObjectAtOffset(0, -40, Player.class); + World theWorld= this.getWorld(); + Player DerSpieler = theWorld.getObjects(Player.class).get(0); if(DerSpieler!=null) { - DerSpieler.setLocation(DerSpieler.getX()+speed, DerSpieler.getY()); + DerSpieler.setLocation(DerSpieler.getX()+speed*3, DerSpieler.getY()); } } } diff --git a/SMIMS-Game/Player.class b/SMIMS-Game/Player.class index 9749940..8693d15 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 a45fa9e..0a66f42 100644 --- a/SMIMS-Game/Player.java +++ b/SMIMS-Game/Player.java @@ -10,13 +10,13 @@ public class Player extends Actor { int MAX_HEALTH = 3; int health = MAX_HEALTH; - + int jumpBoostDuration = -1; int jumpBoostStrength = 5; - + boolean projectileReady = false; int projectileTimer; - + private int speed = 6; private int currentJumpStrength; private int defaultJumpStrength = 15; @@ -34,7 +34,7 @@ public class Player extends Actor handlePowerUps(); shootProjectile(); checkHealth(); - + //Check ob der Spieler am unteren Fensterrand ist if (getY()+1 >= getWorld().getHeight()){ Greenfoot.setWorld(new GameOverWorld()); @@ -93,8 +93,8 @@ public class Player extends Actor } } onGround = landed; - } - + } + public void shootProjectile(){ projectileTimer++; MouseInfo mouse = Greenfoot.getMouseInfo(); @@ -119,16 +119,16 @@ public class Player extends Actor getWorld().removeObjects(getIntersectingObjects(Projectile.class)); getWorld().removeObjects(getIntersectingObjects(Enemy.class)); getWorld().removeObjects(getIntersectingObjects(Spike.class)); - + } } - + public void checkHealth(){ if (health <= 0){ Greenfoot.setWorld(new GameOverWorld()); } } - + public void handlePowerUps(){ if (jumpBoostDuration >= 0){ jumpBoostDuration -= 1; @@ -136,7 +136,7 @@ public class Player extends Actor currentJumpStrength = defaultJumpStrength; } } - + public void reveivePowerUp(int duration, String type){ switch(type){ case "dummy": @@ -149,6 +149,16 @@ public class Player extends Actor if (health < MAX_HEALTH){ health++; } + 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 5c0ab24..b8a97cd 100644 --- a/SMIMS-Game/project.greenfoot +++ b/SMIMS-Game/project.greenfoot @@ -9,57 +9,56 @@ class.MovingPlattform.image=Unbenannt.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=Spike.png class.SpikedPlattform.image=SpikedPlattform.png class.StartWorld.image=StartBackground.png class.TargetingProjectile.image=blue-draught.png -class.UnactiveSpike.image=Spike_Copy.png +class.UnactiveSpike.image=SpikeUnactive.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=SpikedPlattform +dependency11.to=BreakingPlattform dependency11.type=UsesDependency dependency12.from=MyWorld -dependency12.to=Projectile +dependency12.to=SpikedPlattform dependency12.type=UsesDependency dependency13.from=MyWorld -dependency13.to=TargetingProjectile +dependency13.to=Projectile dependency13.type=UsesDependency -dependency14.from=Spike -dependency14.to=GameOverWorld +dependency14.from=MyWorld +dependency14.to=TargetingProjectile dependency14.type=UsesDependency dependency15.from=Spike -dependency15.to=MyWorld +dependency15.to=GameOverWorld dependency15.type=UsesDependency dependency16.from=Spike -dependency16.to=Player +dependency16.to=MyWorld dependency16.type=UsesDependency -dependency17.from=Player -dependency17.to=GameOverWorld +dependency17.from=Spike +dependency17.to=Player dependency17.type=UsesDependency dependency18.from=Player -dependency18.to=Plattform +dependency18.to=GameOverWorld dependency18.type=UsesDependency dependency19.from=Player -dependency19.to=PlayerProjectile +dependency19.to=Plattform dependency19.type=UsesDependency dependency2.from=PlayerTestWorld dependency2.to=Ground dependency2.type=UsesDependency dependency20.from=Player -dependency20.to=Projectile +dependency20.to=PlayerProjectile dependency20.type=UsesDependency dependency21.from=Player -dependency21.to=Enemy +dependency21.to=Projectile dependency21.type=UsesDependency -dependency22.from=Healthbar -dependency22.to=Player +dependency22.from=Player +dependency22.to=Enemy dependency22.type=UsesDependency dependency23.from=UnactiveSpike dependency23.to=SpikedPlattform @@ -70,60 +69,63 @@ dependency24.type=UsesDependency dependency25.from=UnactiveSpike dependency25.to=Spike dependency25.type=UsesDependency -dependency26.from=Plattform -dependency26.to=MyWorld +dependency26.from=Healthbar +dependency26.to=Player dependency26.type=UsesDependency dependency27.from=Plattform -dependency27.to=Player +dependency27.to=MyWorld dependency27.type=UsesDependency -dependency28.from=MovingPlattform -dependency28.to=MyWorld +dependency28.from=Plattform +dependency28.to=Player dependency28.type=UsesDependency dependency29.from=MovingPlattform -dependency29.to=Player +dependency29.to=MyWorld dependency29.type=UsesDependency dependency3.from=PlayerTestWorld dependency3.to=Player dependency3.type=UsesDependency -dependency30.from=SpikedPlattform -dependency30.to=Spike +dependency30.from=MovingPlattform +dependency30.to=Player dependency30.type=UsesDependency dependency31.from=SpikedPlattform -dependency31.to=GameOverWorld +dependency31.to=Spike dependency31.type=UsesDependency dependency32.from=SpikedPlattform -dependency32.to=MyWorld +dependency32.to=GameOverWorld dependency32.type=UsesDependency dependency33.from=SpikedPlattform -dependency33.to=UnactiveSpike +dependency33.to=MyWorld dependency33.type=UsesDependency -dependency34.from=TargetingProjectile -dependency34.to=Player +dependency34.from=SpikedPlattform +dependency34.to=UnactiveSpike dependency34.type=UsesDependency -dependency35.from=Button -dependency35.to=MyWorld +dependency35.from=TargetingProjectile +dependency35.to=Player dependency35.type=UsesDependency -dependency36.from=PowerUps -dependency36.to=Player +dependency36.from=Button +dependency36.to=MyWorld dependency36.type=UsesDependency -dependency37.from=HealthItem +dependency37.from=PowerUps dependency37.to=Player dependency37.type=UsesDependency -dependency38.from=JumpBoostItem +dependency38.from=HealthItem dependency38.to=Player dependency38.type=UsesDependency -dependency39.from=Enemy +dependency39.from=JumpBoostItem dependency39.to=Player dependency39.type=UsesDependency dependency4.from=PlayerTestWorld dependency4.to=JumpBoostItem dependency4.type=UsesDependency dependency40.from=Enemy -dependency40.to=EnemyProjectile +dependency40.to=Player dependency40.type=UsesDependency -dependency41.from=PlayerProjectile -dependency41.to=Enemy +dependency41.from=Enemy +dependency41.to=EnemyProjectile dependency41.type=UsesDependency +dependency42.from=PlayerProjectile +dependency42.to=Enemy +dependency42.type=UsesDependency dependency5.from=StartWorld dependency5.to=Button dependency5.type=UsesDependency @@ -137,14 +139,14 @@ dependency8.from=MyWorld dependency8.to=Plattform dependency8.type=UsesDependency dependency9.from=MyWorld -dependency9.to=MovingPlattform +dependency9.to=Healthbar dependency9.type=UsesDependency editor.fx.0.height=737 editor.fx.0.width=814 -editor.fx.0.x=330 -editor.fx.0.y=72 -height=830 -package.numDependencies=41 +editor.fx.0.x=360 +editor.fx.0.y=26 +height=822 +package.numDependencies=42 package.numTargets=23 project.charset=UTF-8 publish.hasSource=false @@ -287,7 +289,7 @@ target4.width=120 target4.x=0 target4.y=0 target5.height=70 -target5.name=Healthbar +target5.name=UnactiveSpike target5.showInterface=false target5.type=ClassTarget target5.width=120 @@ -301,7 +303,7 @@ target6.width=120 target6.x=0 target6.y=0 target7.height=70 -target7.name=UnactiveSpike +target7.name=Healthbar target7.showInterface=false target7.type=ClassTarget target7.width=120 @@ -322,7 +324,7 @@ target9.width=120 target9.x=0 target9.y=0 version=3.1.0 -width=1550 +width=715 world.lastInstantiated=MyWorld -xPosition=0 -yPosition=0 +xPosition=532 +yPosition=117