diff --git a/SMIMS-Game/MovingPlattform.class b/SMIMS-Game/MovingPlattform.class index 5f4c1c9..39c1d00 100644 Binary files a/SMIMS-Game/MovingPlattform.class and b/SMIMS-Game/MovingPlattform.class differ diff --git a/SMIMS-Game/MovingPlattform.ctxt b/SMIMS-Game/MovingPlattform.ctxt index c3f340b..e7cab49 100644 --- a/SMIMS-Game/MovingPlattform.ctxt +++ b/SMIMS-Game/MovingPlattform.ctxt @@ -8,4 +8,6 @@ comment2.target=void\ act() comment2.text=\r\n\ Act\ -\ do\ whatever\ the\ MovingPlattform\ 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\ bewege() -numComments=4 +comment4.params= +comment4.target=void\ bewegeSpielerMit() +numComments=5 diff --git a/SMIMS-Game/MovingPlattform.java b/SMIMS-Game/MovingPlattform.java index 8271ab1..7f6008c 100644 --- a/SMIMS-Game/MovingPlattform.java +++ b/SMIMS-Game/MovingPlattform.java @@ -23,6 +23,7 @@ public class MovingPlattform extends Plattform { // Add your action code here. this.bewege(); + this.bewegeSpielerMit(); super.act(); } @@ -34,5 +35,18 @@ public class MovingPlattform extends Plattform { speed=speed*(-1); } + + } + + public void bewegeSpielerMit() + { + if(this.PlayerOnPlattform()) + { + Actor DerSpieler = this.getOneObjectAtOffset(0, -40, Player.class); + if(DerSpieler!=null) + { + DerSpieler.setLocation(DerSpieler.getX()+speed, DerSpieler.getY()); + } + } } } diff --git a/SMIMS-Game/MyWorld.class b/SMIMS-Game/MyWorld.class index 65dd10f..bbb3170 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 94f1f87..6591938 100644 --- a/SMIMS-Game/MyWorld.java +++ b/SMIMS-Game/MyWorld.java @@ -10,7 +10,7 @@ public class MyWorld extends World { int PlattformCountdown; int timer = 200; //Zeit, bevor das erste Projektil auftaucht - //kann später noch beliebig angepasst werden + //kann später noch beliebig angepasst werden int targetTimer = 100; /** * Constructor for objects of class MyWorld. @@ -22,7 +22,7 @@ public class MyWorld extends World super(400, 600, 1); prepare(); } - + /** * Prepare the world for the start of the program. * That is: create the initial objects and add them to the world. @@ -59,7 +59,7 @@ public class MyWorld extends World if(PlattformCountdown==0) //Damit in regelmäßigen Abständen auf jeden Fall eine Plattform auftaucht { addObject(new Plattform(), Greenfoot.getRandomNumber(400), 5); - PlattformCountdown=100; + PlattformCountdown=50; } PlattformCountdown--; if(Greenfoot.getRandomNumber(100000)>=99800) @@ -78,9 +78,12 @@ public class MyWorld extends World { addObject(new BreakingPlattform(50), Greenfoot.getRandomNumber(400), 6); //Nach Links bewegende Plattform } - + if(Greenfoot.getRandomNumber(100000)>=99550) + { + addObject(new SpikedPlattform(50), Greenfoot.getRandomNumber(400), 6); //Nach Links bewegende Plattform + } } - + public void projectile(){ if(timer == 0){ Projectile projectile = new Projectile(); @@ -91,7 +94,7 @@ public class MyWorld extends World timer = timer - 1; } } - + public void targetingProjectile(){ if(targetTimer == 0){ TargetingProjectile targetingProjectile = new TargetingProjectile(); diff --git a/SMIMS-Game/Spike.class b/SMIMS-Game/Spike.class index 1f74616..56b67f8 100644 Binary files a/SMIMS-Game/Spike.class and b/SMIMS-Game/Spike.class differ diff --git a/SMIMS-Game/Spike.ctxt b/SMIMS-Game/Spike.ctxt index 3b85240..d02e8e5 100644 --- a/SMIMS-Game/Spike.ctxt +++ b/SMIMS-Game/Spike.ctxt @@ -6,4 +6,8 @@ comment1.target=Spike(int) comment2.params= comment2.target=void\ act() comment2.text=\r\n\ Act\ -\ do\ whatever\ the\ Spike\ wants\ to\ do.\ This\ method\ is\ called\ whenever\r\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\r\n -numComments=3 +comment3.params= +comment3.target=void\ loescheMich() +comment4.params= +comment4.target=void\ bewege() +numComments=5 diff --git a/SMIMS-Game/Spike.java b/SMIMS-Game/Spike.java index 2c53b13..0a69da3 100644 --- a/SMIMS-Game/Spike.java +++ b/SMIMS-Game/Spike.java @@ -21,10 +21,26 @@ public class Spike extends Actor public void act() { // Add your action code here. - this.setLocation(this.getX(), this.getY()+speed); if(this.isTouching(Player.class)) { Greenfoot.setWorld(new GameOverWorld()); } + this.bewege(); + } + + public void loescheMich() + { + MyWorld theWorld= (MyWorld) this.getWorld(); + theWorld.removeObject(this); + } + + public void bewege() + { + this.setLocation(this.getX(), this.getY()+speed); + MyWorld theWorld= (MyWorld) this.getWorld(); + if(this.getY()>=theWorld.getHeight()-5) + { + this.loescheMich(); + } } } diff --git a/SMIMS-Game/SpikedPlattform.class b/SMIMS-Game/SpikedPlattform.class index 71b8cc1..4ccb4ad 100644 Binary files a/SMIMS-Game/SpikedPlattform.class and b/SMIMS-Game/SpikedPlattform.class differ diff --git a/SMIMS-Game/SpikedPlattform.ctxt b/SMIMS-Game/SpikedPlattform.ctxt index 7f43c74..9671465 100644 --- a/SMIMS-Game/SpikedPlattform.ctxt +++ b/SMIMS-Game/SpikedPlattform.ctxt @@ -2,10 +2,12 @@ comment0.target=SpikedPlattform comment0.text=\r\n\ Write\ a\ description\ of\ class\ SpikedPlattform\ here.\r\n\ \r\n\ @author\ (your\ name)\ \r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n comment1.params=pSpikeCountdown -comment1.target=void\ act(int) -comment1.text=\r\n\ Act\ -\ do\ whatever\ the\ SpikedPlattform\ wants\ to\ do.\ This\ method\ is\ called\ whenever\r\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\r\n +comment1.target=SpikedPlattform(int) comment2.params= -comment2.target=void\ activateSpikes() +comment2.target=void\ act() +comment2.text=\r\n\ Act\ -\ do\ whatever\ the\ SpikedPlattform\ 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\ spikeTheSurface() -numComments=4 +comment3.target=void\ activateSpikes() +comment4.params= +comment4.target=void\ spikeTheSurface() +numComments=5 diff --git a/SMIMS-Game/SpikedPlattform.java b/SMIMS-Game/SpikedPlattform.java index efc2a57..4b7ae8d 100644 --- a/SMIMS-Game/SpikedPlattform.java +++ b/SMIMS-Game/SpikedPlattform.java @@ -12,11 +12,16 @@ public class SpikedPlattform extends Plattform boolean spikesActivated=false; boolean isSpiked=false; Spike[] hasSpikes= new Spike[5]; + public SpikedPlattform(int pSpikeCountdown) + { + SpikeCountdown=pSpikeCountdown; + } + /** * Act - do whatever the SpikedPlattform wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ - public void act(int pSpikeCountdown) + public void act() { // Add your action code here. if(this.PlayerOnPlattform() && spikesActivated== false) @@ -41,6 +46,11 @@ public class SpikedPlattform extends Plattform public void activateSpikes() { spikesActivated=true; + MyWorld theWorld= (MyWorld) this.getWorld(); + for(int i=-6; i<7; i++) + { + theWorld.addObject(new UnactiveSpike(2,SpikeCountdown, this ), this.getX()+i* (this.getImage().getWidth()/13), this.getY()-(this.getImage().getHeight()/2)); + } //Sound //setImage @@ -49,12 +59,8 @@ public class SpikedPlattform extends Plattform public void spikeTheSurface() { isSpiked=true; - MyWorld theWorld= (MyWorld) this.getWorld(); - for(int i=0; i<3; i++) - { - theWorld.addObject(new Spike(2), this.getX()-this.getImage().getWidth()+ i*this.getImage().getWidth()/3, this.getX()-this.getImage().getHeight()/2); - } - //Sound + + //Soun) //setImage } diff --git a/SMIMS-Game/UnactiveSpike.class b/SMIMS-Game/UnactiveSpike.class index d21a187..a1f05c4 100644 Binary files a/SMIMS-Game/UnactiveSpike.class and b/SMIMS-Game/UnactiveSpike.class differ diff --git a/SMIMS-Game/UnactiveSpike.ctxt b/SMIMS-Game/UnactiveSpike.ctxt index 2494fd4..27e00e4 100644 --- a/SMIMS-Game/UnactiveSpike.ctxt +++ b/SMIMS-Game/UnactiveSpike.ctxt @@ -1,7 +1,13 @@ #BlueJ class context comment0.target=UnactiveSpike comment0.text=\r\n\ Write\ a\ description\ of\ class\ UnactiveSpike\ 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\ UnactiveSpike\ wants\ to\ do.\ This\ method\ is\ called\ whenever\r\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\r\n -numComments=2 +comment1.params=pSpeed\ pCoundown\ pPlattform +comment1.target=UnactiveSpike(int,\ int,\ SpikedPlattform) +comment2.params= +comment2.target=void\ act() +comment2.text=\r\n\ Act\ -\ do\ whatever\ the\ UnactiveSpike\ 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\ loescheMich() +comment4.params= +comment4.target=void\ bewege() +numComments=5 diff --git a/SMIMS-Game/UnactiveSpike.java b/SMIMS-Game/UnactiveSpike.java index 256c2fb..cb62ea0 100644 --- a/SMIMS-Game/UnactiveSpike.java +++ b/SMIMS-Game/UnactiveSpike.java @@ -8,12 +8,51 @@ import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) */ public class UnactiveSpike extends Actor { + int countdown; + int speed; + boolean geloescht=false; + public UnactiveSpike(int pSpeed, int pCoundown, SpikedPlattform pPlattform) + { + speed=pSpeed; + countdown=pCoundown; + } + /** * Act - do whatever the UnactiveSpike 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. + this.bewege(); + countdown--; + if(countdown==0) + { + MyWorld theWorld= (MyWorld) this.getWorld(); + Spike BeispielSpike=new Spike(1); + GreenfootImage SpikeImage= BeispielSpike.getImage(); + theWorld.addObject(new Spike(speed), this.getX(), (this.getY()- this.getImage().getHeight()/2)-10); //die Zahl Minus damit ist endlich passt + geloescht=true; + } + if(geloescht) + { + this.loescheMich(); + } + + } + + public void loescheMich() + { + MyWorld theWorld= (MyWorld) this.getWorld(); + theWorld.removeObject(this); + } + + public void bewege() + { + this.setLocation(this.getX(), this.getY()+speed); + MyWorld theWorld= (MyWorld) this.getWorld(); + if(this.getY()>=theWorld.getHeight()-5) + { + geloescht=true; + } } } diff --git a/SMIMS-Game/images/Spike.png b/SMIMS-Game/images/Spike.png index 2e2b277..6b17906 100644 Binary files a/SMIMS-Game/images/Spike.png and b/SMIMS-Game/images/Spike.png differ diff --git a/SMIMS-Game/images/SpikeUnactive.png b/SMIMS-Game/images/SpikeUnactive.png deleted file mode 100644 index 12ad442..0000000 Binary files a/SMIMS-Game/images/SpikeUnactive.png and /dev/null differ diff --git a/SMIMS-Game/project.greenfoot b/SMIMS-Game/project.greenfoot index a169c86..e1610cf 100644 --- a/SMIMS-Game/project.greenfoot +++ b/SMIMS-Game/project.greenfoot @@ -1,51 +1,96 @@ #Greenfoot project file -class.Button.image=button-red.png -class.GameOverWorld.image=GameOverBackground.png +class.BreakingPlattform.image=Unbenannt2.png class.Ground.image=weave.jpg -class.MyWorld.image=GameBackground.png +class.MovingPlattform.image=Unbenannt.png +class.Plattform.image=Plattform.png class.Player.image=ppl2.png -class.Projectile.image=Projectile1.png -class.StartWorld.image=StartBackground.png -class.TargetingProjectile.image=blue-draught.png +class.Spike.image=Spike.png +class.SpikedPlattform.image=SpikedPlattform.png +class.UnactiveSpike.image=Spike_Copy.png dependency1.from=GameOverWorld dependency1.to=Button dependency1.type=UsesDependency dependency10.from=MyWorld -dependency10.to=Projectile +dependency10.to=BreakingPlattform dependency10.type=UsesDependency -dependency11.from=Player -dependency11.to=GameOverWorld +dependency11.from=MyWorld +dependency11.to=SpikedPlattform dependency11.type=UsesDependency -dependency12.from=Player -dependency12.to=Ground +dependency12.from=MyWorld +dependency12.to=Projectile dependency12.type=UsesDependency -dependency13.from=Player -dependency13.to=Projectile +dependency13.from=MyWorld +dependency13.to=TargetingProjectile dependency13.type=UsesDependency -dependency14.from=Plattform -dependency14.to=MyWorld +dependency14.from=Spike +dependency14.to=GameOverWorld dependency14.type=UsesDependency -dependency15.from=Plattform -dependency15.to=Player +dependency15.from=Spike +dependency15.to=MyWorld dependency15.type=UsesDependency -dependency16.from=MovingPlattform -dependency16.to=MyWorld +dependency16.from=Spike +dependency16.to=Player dependency16.type=UsesDependency -dependency17.from=Button -dependency17.to=MyWorld +dependency17.from=Player +dependency17.to=GameOverWorld dependency17.type=UsesDependency -dependency18.from=PowerUps -dependency18.to=Player +dependency18.from=Player +dependency18.to=Plattform dependency18.type=UsesDependency -dependency19.from=JumpBoostItem -dependency19.to=Player +dependency19.from=Player +dependency19.to=Projectile dependency19.type=UsesDependency dependency2.from=PlayerTestWorld dependency2.to=Ground dependency2.type=UsesDependency +dependency20.from=UnactiveSpike +dependency20.to=SpikedPlattform +dependency20.type=UsesDependency +dependency21.from=UnactiveSpike +dependency21.to=MyWorld +dependency21.type=UsesDependency +dependency22.from=UnactiveSpike +dependency22.to=Spike +dependency22.type=UsesDependency +dependency23.from=Plattform +dependency23.to=MyWorld +dependency23.type=UsesDependency +dependency24.from=Plattform +dependency24.to=Player +dependency24.type=UsesDependency +dependency25.from=MovingPlattform +dependency25.to=MyWorld +dependency25.type=UsesDependency +dependency26.from=MovingPlattform +dependency26.to=Player +dependency26.type=UsesDependency +dependency27.from=SpikedPlattform +dependency27.to=Spike +dependency27.type=UsesDependency +dependency28.from=SpikedPlattform +dependency28.to=GameOverWorld +dependency28.type=UsesDependency +dependency29.from=SpikedPlattform +dependency29.to=MyWorld +dependency29.type=UsesDependency dependency3.from=PlayerTestWorld dependency3.to=Player dependency3.type=UsesDependency +dependency30.from=SpikedPlattform +dependency30.to=UnactiveSpike +dependency30.type=UsesDependency +dependency31.from=TargetingProjectile +dependency31.to=Player +dependency31.type=UsesDependency +dependency32.from=Button +dependency32.to=MyWorld +dependency32.type=UsesDependency +dependency33.from=PowerUps +dependency33.to=Player +dependency33.type=UsesDependency +dependency34.from=JumpBoostItem +dependency34.to=Player +dependency34.type=UsesDependency dependency4.from=PlayerTestWorld dependency4.to=JumpBoostItem dependency4.type=UsesDependency @@ -56,21 +101,21 @@ dependency6.from=MyWorld dependency6.to=Player dependency6.type=UsesDependency dependency7.from=MyWorld -dependency7.to=Plattform +dependency7.to=Score dependency7.type=UsesDependency dependency8.from=MyWorld -dependency8.to=MovingPlattform +dependency8.to=Plattform dependency8.type=UsesDependency dependency9.from=MyWorld -dependency9.to=BreakingPlattform +dependency9.to=MovingPlattform 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=19 -package.numTargets=14 +editor.fx.0.height=1048 +editor.fx.0.width=1936 +editor.fx.0.x=-18 +editor.fx.0.y=4 +height=736 +package.numDependencies=34 +package.numTargets=18 project.charset=UTF-8 publish.hasSource=false publish.locked=true @@ -86,105 +131,133 @@ readme.x=10 readme.y=10 simulation.speed=50 target1.height=70 -target1.name=Player +target1.name=Spike target1.showInterface=false target1.type=ClassTarget target1.width=120 target1.x=0 target1.y=0 target10.height=70 -target10.name=TargetingProjectile +target10.name=StartWorld target10.showInterface=false target10.type=ClassTarget target10.width=120 target10.x=0 target10.y=0 target11.height=70 -target11.name=Projectile +target11.name=Plattform target11.showInterface=false target11.type=ClassTarget target11.width=120 target11.x=0 target11.y=0 target12.height=70 -target12.name=Button +target12.name=TargetingProjectile target12.showInterface=false target12.type=ClassTarget target12.width=120 target12.x=0 target12.y=0 target13.height=70 -target13.name=PowerUps +target13.name=Projectile target13.showInterface=false target13.type=ClassTarget target13.width=120 target13.x=0 target13.y=0 target14.height=70 -target14.name=MyWorld +target14.name=Score target14.showInterface=false target14.type=ClassTarget target14.width=120 target14.x=0 target14.y=0 +target15.height=70 +target15.name=Button +target15.showInterface=false +target15.type=ClassTarget +target15.width=120 +target15.x=0 +target15.y=0 +target16.height=70 +target16.name=PowerUps +target16.showInterface=false +target16.type=ClassTarget +target16.width=120 +target16.x=0 +target16.y=0 +target17.height=70 +target17.name=SpikedPlattform +target17.showInterface=false +target17.type=ClassTarget +target17.width=120 +target17.x=0 +target17.y=0 +target18.height=70 +target18.name=MyWorld +target18.showInterface=false +target18.type=ClassTarget +target18.width=120 +target18.x=0 +target18.y=0 target2.height=70 -target2.name=MovingPlattform +target2.name=Player target2.showInterface=false target2.type=ClassTarget target2.width=120 target2.x=0 target2.y=0 target3.height=70 -target3.name=Ground +target3.name=MovingPlattform target3.showInterface=false target3.type=ClassTarget target3.width=120 target3.x=0 target3.y=0 target4.height=70 -target4.name=JumpBoostItem +target4.name=Ground target4.showInterface=false target4.type=ClassTarget target4.width=120 target4.x=0 target4.y=0 target5.height=70 -target5.name=BreakingPlattform +target5.name=UnactiveSpike target5.showInterface=false target5.type=ClassTarget target5.width=120 target5.x=0 target5.y=0 target6.height=70 -target6.name=GameOverWorld +target6.name=JumpBoostItem target6.showInterface=false target6.type=ClassTarget target6.width=120 target6.x=0 target6.y=0 target7.height=70 -target7.name=PlayerTestWorld +target7.name=BreakingPlattform target7.showInterface=false target7.type=ClassTarget target7.width=120 target7.x=0 target7.y=0 target8.height=70 -target8.name=StartWorld +target8.name=GameOverWorld target8.showInterface=false target8.type=ClassTarget target8.width=120 target8.x=0 target8.y=0 target9.height=70 -target9.name=Plattform +target9.name=PlayerTestWorld target9.showInterface=false target9.type=ClassTarget target9.width=120 target9.x=0 target9.y=0 version=3.1.0 -width=1550 -world.lastInstantiated=MyWorld -xPosition=0 -yPosition=0 +width=856 +world.lastInstantiated=StartWorld +xPosition=481 +yPosition=94