diff --git a/SMIMS-Game/BreakingPlattform.class b/SMIMS-Game/BreakingPlattform.class index c6d81c8..c5111c7 100644 Binary files a/SMIMS-Game/BreakingPlattform.class and b/SMIMS-Game/BreakingPlattform.class differ diff --git a/SMIMS-Game/BreakingPlattform.ctxt b/SMIMS-Game/BreakingPlattform.ctxt index 82d1599..4aa6736 100644 --- a/SMIMS-Game/BreakingPlattform.ctxt +++ b/SMIMS-Game/BreakingPlattform.ctxt @@ -1,9 +1,11 @@ #BlueJ class context comment0.target=BreakingPlattform comment0.text=\r\n\ Write\ a\ description\ of\ class\ BreakingPlattform\ 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\ BreakingPlattform\ wants\ to\ do.\ This\ method\ is\ called\ whenever\r\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\r\n +comment1.params=pBreakingCountdown +comment1.target=BreakingPlattform(int) comment2.params= -comment2.target=void\ breakPlattform() -numComments=3 +comment2.target=void\ act() +comment2.text=\r\n\ Act\ -\ do\ whatever\ the\ BreakingPlattform\ 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\ breakPlattform() +numComments=4 diff --git a/SMIMS-Game/BreakingPlattform.java b/SMIMS-Game/BreakingPlattform.java index 2fc9b35..64bfea4 100644 --- a/SMIMS-Game/BreakingPlattform.java +++ b/SMIMS-Game/BreakingPlattform.java @@ -8,25 +8,40 @@ import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) */ public class BreakingPlattform extends Plattform { - boolean IsBreaking= false; + boolean IsBreaking= false; + int BreakingCountdown; + public BreakingPlattform(int pBreakingCountdown) + { + BreakingCountdown=pBreakingCountdown; + } + /** * Act - do whatever the BreakingPlattform wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { - super.act(); if(this.PlayerOnPlattform() && IsBreaking==false) { - IsBreaking= true; + IsBreaking= true; + //Greenfoot.playSound("...") + this.setImage("BreakingPlattform2.png"); //untested + } + if(IsBreaking) + { + BreakingCountdown--; + if(BreakingCountdown==0) + { + this.breakPlattform(); + } + } + super.act(); } public void breakPlattform() { - if(this.PlayerOnPlattform()) - { - - } + //Animation + geloescht=true; } } diff --git a/SMIMS-Game/MovingPlattform.class b/SMIMS-Game/MovingPlattform.class index 3673817..5f4c1c9 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 9aca730..8271ab1 100644 --- a/SMIMS-Game/MovingPlattform.java +++ b/SMIMS-Game/MovingPlattform.java @@ -22,17 +22,17 @@ public class MovingPlattform extends Plattform public void act() { // Add your action code here. - super.act(); this.bewege(); + super.act(); } public void bewege() { MyWorld theWorld= (MyWorld) this.getWorld(); - move(speed); - if(this.getX()<5 || this.getX()<=theWorld.getWidth()) + this.setLocation(this.getX()+speed, this.getY()); + if(this.getX()<5 || this.getX()>=theWorld.getWidth()-5) { - this.loescheMich(); + speed=speed*(-1); } } } diff --git a/SMIMS-Game/MyWorld.class b/SMIMS-Game/MyWorld.class index c9c4726..3f3a62b 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 25b6c20..a71706b 100644 --- a/SMIMS-Game/MyWorld.ctxt +++ b/SMIMS-Game/MyWorld.ctxt @@ -7,4 +7,6 @@ comment1.text=\r\n\ Constructor\ for\ objects\ of\ class\ MyWorld.\r\n\ \r\n comment2.params= comment2.target=void\ prepare() comment2.text=\r\n\ Prepare\ the\ world\ for\ the\ start\ of\ the\ program.\r\n\ That\ is\:\ create\ the\ initial\ objects\ and\ add\ them\ to\ the\ world.\r\n -numComments=3 +comment3.params= +comment3.target=void\ act() +numComments=4 diff --git a/SMIMS-Game/MyWorld.java b/SMIMS-Game/MyWorld.java index b18d2c8..3c38b1a 100644 --- a/SMIMS-Game/MyWorld.java +++ b/SMIMS-Game/MyWorld.java @@ -8,7 +8,7 @@ import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) */ public class MyWorld extends World { - + int PlattformCountdown=20; /** * Constructor for objects of class MyWorld. * @@ -19,6 +19,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. @@ -28,4 +29,30 @@ public class MyWorld extends World Player player = new Player(); addObject(player,302,320); } + + public void act() + { + 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--; + if(Greenfoot.getRandomNumber(100000)>=99800) + { + addObject(new Plattform(), Greenfoot.getRandomNumber(400), 5); + } + if(Greenfoot.getRandomNumber(100000)>=99900) + { + addObject(new MovingPlattform(2), Greenfoot.getRandomNumber(400), 6); //Nach Rechts bewegende Plattform + } + if(Greenfoot.getRandomNumber(100000)>=99900) + { + addObject(new MovingPlattform(-2), Greenfoot.getRandomNumber(400), 6); //Nach Links bewegende Plattform + } + if(Greenfoot.getRandomNumber(100000)>=99750) + { + addObject(new BreakingPlattform(50), Greenfoot.getRandomNumber(400), 6); //Nach Links bewegende Plattform + } + } } diff --git a/SMIMS-Game/Plattform.class b/SMIMS-Game/Plattform.class index ebbf481..fe23c79 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 232991c..bc4312b 100644 --- a/SMIMS-Game/Plattform.java +++ b/SMIMS-Game/Plattform.java @@ -8,6 +8,7 @@ import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) */ public class Plattform extends Actor { + boolean geloescht= false; /** * Act - do whatever the Plattform wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. @@ -15,6 +16,10 @@ public class Plattform extends Actor public void act() { this.scrollNachUnten(); + if(geloescht) + { + this.loescheMich(); + } // Add your action code here. } @@ -24,7 +29,7 @@ public class Plattform extends Actor setLocation(this.getX(),this.getY()+2); // Nach unten turnen if(this.getY()>= welt.getHeight()-5 ||this.getY()<=0) { - this.loescheMich(); + geloescht= true; } } @@ -35,12 +40,12 @@ public class Plattform extends Actor public boolean PlayerOnPlattform() { - Actor Spieler= getOneObjectAtOffset(0, 5, Player.class); - if(Spieler!= null) + Player Spieler= (Player) getOneIntersectingObject(Player.class); + if(this.isTouching(Player.class)) { - if(Spieler.equals(Player.class)) + if(Spieler.getY()