diff --git a/SMIMS-Game/BreakingPlattform.class b/SMIMS-Game/BreakingPlattform.class new file mode 100644 index 0000000..c6d81c8 Binary files /dev/null and b/SMIMS-Game/BreakingPlattform.class differ diff --git a/SMIMS-Game/BreakingPlattform.ctxt b/SMIMS-Game/BreakingPlattform.ctxt new file mode 100644 index 0000000..82d1599 --- /dev/null +++ b/SMIMS-Game/BreakingPlattform.ctxt @@ -0,0 +1,9 @@ +#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 +comment2.params= +comment2.target=void\ breakPlattform() +numComments=3 diff --git a/SMIMS-Game/BreakingPlattform.java b/SMIMS-Game/BreakingPlattform.java new file mode 100644 index 0000000..2fc9b35 --- /dev/null +++ b/SMIMS-Game/BreakingPlattform.java @@ -0,0 +1,32 @@ +import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) + +/** + * Write a description of class BreakingPlattform here. + * + * @author (your name) + * @version (a version number or a date) + */ +public class BreakingPlattform extends Plattform +{ + boolean IsBreaking= false; + /** + * 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; + } + } + + public void breakPlattform() + { + if(this.PlayerOnPlattform()) + { + + } + } +} diff --git a/SMIMS-Game/GameOverWorld.class b/SMIMS-Game/GameOverWorld.class new file mode 100644 index 0000000..64be4d7 Binary files /dev/null and b/SMIMS-Game/GameOverWorld.class differ diff --git a/SMIMS-Game/GameOverWorld.ctxt b/SMIMS-Game/GameOverWorld.ctxt new file mode 100644 index 0000000..e10a681 --- /dev/null +++ b/SMIMS-Game/GameOverWorld.ctxt @@ -0,0 +1,7 @@ +#BlueJ class context +comment0.target=GameOverWorld +comment0.text=\r\n\ Write\ a\ description\ of\ class\ GameOverWorld\ here.\r\n\ \r\n\ @author\ (your\ name)\ \r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n +comment1.params= +comment1.target=GameOverWorld() +comment1.text=\r\n\ Constructor\ for\ objects\ of\ class\ GameOverWorld.\r\n\ \r\n +numComments=2 diff --git a/SMIMS-Game/GameOverWorld.java b/SMIMS-Game/GameOverWorld.java new file mode 100644 index 0000000..8c4621c --- /dev/null +++ b/SMIMS-Game/GameOverWorld.java @@ -0,0 +1,21 @@ +import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) + +/** + * Write a description of class GameOverWorld here. + * + * @author (your name) + * @version (a version number or a date) + */ +public class GameOverWorld extends World +{ + + /** + * Constructor for objects of class GameOverWorld. + * + */ + public GameOverWorld() + { + // Create a new world with 600x400 cells with a cell size of 1x1 pixels. + super(400, 600, 1); + } +} diff --git a/SMIMS-Game/MovingPlattform.class b/SMIMS-Game/MovingPlattform.class new file mode 100644 index 0000000..3673817 Binary files /dev/null and b/SMIMS-Game/MovingPlattform.class differ diff --git a/SMIMS-Game/MovingPlattform.ctxt b/SMIMS-Game/MovingPlattform.ctxt new file mode 100644 index 0000000..c3f340b --- /dev/null +++ b/SMIMS-Game/MovingPlattform.ctxt @@ -0,0 +1,11 @@ +#BlueJ class context +comment0.target=MovingPlattform +comment0.text=\r\n\ Write\ a\ description\ of\ class\ MovingPlattform\ here.\r\n\ \r\n\ @author\ (your\ name)\ \r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n +comment1.params=pSpeed +comment1.target=MovingPlattform(int) +comment2.params= +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 diff --git a/SMIMS-Game/MovingPlattform.java b/SMIMS-Game/MovingPlattform.java new file mode 100644 index 0000000..9aca730 --- /dev/null +++ b/SMIMS-Game/MovingPlattform.java @@ -0,0 +1,38 @@ +import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) + +/** + * Write a description of class MovingPlattform here. + * + * @author (your name) + * @version (a version number or a date) + */ +public class MovingPlattform extends Plattform +{ + int speed; + + public MovingPlattform(int pSpeed) + { + speed= pSpeed; + } + + /** + * Act - do whatever the MovingPlattform 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. + super.act(); + this.bewege(); + } + + public void bewege() + { + MyWorld theWorld= (MyWorld) this.getWorld(); + move(speed); + if(this.getX()<5 || this.getX()<=theWorld.getWidth()) + { + this.loescheMich(); + } + } +} diff --git a/SMIMS-Game/MyWorld.class b/SMIMS-Game/MyWorld.class index c9c4726..26919f8 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..d3d6587 100644 --- a/SMIMS-Game/MyWorld.java +++ b/SMIMS-Game/MyWorld.java @@ -8,7 +8,8 @@ import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) */ public class MyWorld extends World { - + int timer = 200; + /** * Constructor for objects of class MyWorld. * @@ -28,4 +29,15 @@ public class MyWorld extends World Player player = new Player(); addObject(player,302,320); } + + public void act(){ + if(timer > 0){ + timer = timer - 1; + } + else{ + Projectile projectile = new Projectile(); + addObject(projectile,Greenfoot.getRandomNumber(300)+50,0); + timer = 200; + } + } } diff --git a/SMIMS-Game/Plattform.class b/SMIMS-Game/Plattform.class new file mode 100644 index 0000000..ebbf481 Binary files /dev/null and b/SMIMS-Game/Plattform.class differ diff --git a/SMIMS-Game/Plattform.ctxt b/SMIMS-Game/Plattform.ctxt new file mode 100644 index 0000000..cb8486f --- /dev/null +++ b/SMIMS-Game/Plattform.ctxt @@ -0,0 +1,13 @@ +#BlueJ class context +comment0.target=Plattform +comment0.text=\r\n\ Write\ a\ description\ of\ class\ Plattform\ 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\ Plattform\ 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\ scrollNachUnten() +comment3.params= +comment3.target=void\ loescheMich() +comment4.params= +comment4.target=boolean\ PlayerOnPlattform() +numComments=5 diff --git a/SMIMS-Game/Plattform.java b/SMIMS-Game/Plattform.java new file mode 100644 index 0000000..232991c --- /dev/null +++ b/SMIMS-Game/Plattform.java @@ -0,0 +1,55 @@ +import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) + +/** + * Write a description of class Plattform here. + * + * @author (your name) + * @version (a version number or a date) + */ +public class Plattform extends Actor +{ + /** + * Act - do whatever the Plattform wants to do. This method is called whenever + * the 'Act' or 'Run' button gets pressed in the environment. + */ + public void act() + { + this.scrollNachUnten(); + // Add your action code here. + } + + public void scrollNachUnten() + { + MyWorld welt= (MyWorld) getWorld(); + setLocation(this.getX(),this.getY()+2); // Nach unten turnen + if(this.getY()>= welt.getHeight()-5 ||this.getY()<=0) + { + this.loescheMich(); + } + } + + public void loescheMich() + { + getWorld().removeObject(this); + } + + public boolean PlayerOnPlattform() + { + Actor Spieler= getOneObjectAtOffset(0, 5, Player.class); + if(Spieler!= null) + { + if(Spieler.equals(Player.class)) + { + return true; + } + else + { + return false; + } + } + else + { + return false; + } + } +} diff --git a/SMIMS-Game/Player.ctxt b/SMIMS-Game/Player.ctxt index 9dcc8a3..c19adf5 100644 --- a/SMIMS-Game/Player.ctxt +++ b/SMIMS-Game/Player.ctxt @@ -1,11 +1,10 @@ #BlueJ class context comment0.target=Player +comment0.text=\r\n\ Write\ a\ description\ of\ class\ Player\ 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() comment2.params= -comment2.target=void\ moveLeftAndRight() +comment2.target=void\ player_movement() comment3.params= -comment3.target=void\ jump() -comment4.params= -comment4.target=void\ fall() -numComments=5 +comment3.target=boolean\ onGround() +numComments=4 diff --git a/SMIMS-Game/Player.java b/SMIMS-Game/Player.java index a5cb43b..9c7c0f4 100644 --- a/SMIMS-Game/Player.java +++ b/SMIMS-Game/Player.java @@ -1,5 +1,11 @@ -import greenfoot.*; +import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) +/** + * Write a description of class Player here. + * + * @author (your name) + * @version (a version number or a date) + */ public class Player extends Actor { private int speed = 6; @@ -11,6 +17,8 @@ public class Player extends Actor public void act() { + player_movement(); + collision(); moveLeftAndRight(); jump(); fall(); @@ -82,4 +90,16 @@ public class Player extends Actor onGround = false; } } + + public boolean collision(){ + if (getIntersectingObjects(Projectile.class).size()>0) + { + Greenfoot.setWorld(new GameOverWorld()); + return true; + } + else + { + return false; + } + } } diff --git a/SMIMS-Game/Projectile.class b/SMIMS-Game/Projectile.class new file mode 100644 index 0000000..b45c87f Binary files /dev/null and b/SMIMS-Game/Projectile.class differ diff --git a/SMIMS-Game/Projectile.ctxt b/SMIMS-Game/Projectile.ctxt new file mode 100644 index 0000000..8e3638e --- /dev/null +++ b/SMIMS-Game/Projectile.ctxt @@ -0,0 +1,9 @@ +#BlueJ class context +comment0.target=Projectile +comment0.text=\r\n\ Write\ a\ description\ of\ class\ Projectile\ 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\ Projectile\ 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\ falling() +numComments=3 diff --git a/SMIMS-Game/Projectile.java b/SMIMS-Game/Projectile.java new file mode 100644 index 0000000..f3bedb3 --- /dev/null +++ b/SMIMS-Game/Projectile.java @@ -0,0 +1,26 @@ +import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) + +/** + * Write a description of class Projectile here. + * + * @author (your name) + * @version (a version number or a date) + */ +public class Projectile extends Actor +{ + /** + * Act - do whatever the Projectile wants to do. This method is called whenever + * the 'Act' or 'Run' button gets pressed in the environment. + */ + public void act() + { + falling(); + } + + public void falling(){ + setLocation(getX(), getY() + 5); + if(getY() > getWorld().getHeight() -5){ + getWorld().removeObject(this); + } + } +} diff --git a/SMIMS-Game/images/Projectile1.jpeg b/SMIMS-Game/images/Projectile1.jpeg new file mode 100644 index 0000000..1875f86 Binary files /dev/null and b/SMIMS-Game/images/Projectile1.jpeg differ diff --git a/SMIMS-Game/images/Projectile1.png b/SMIMS-Game/images/Projectile1.png new file mode 100644 index 0000000..20705b7 Binary files /dev/null and b/SMIMS-Game/images/Projectile1.png differ diff --git a/SMIMS-Game/images/Wall.jpg b/SMIMS-Game/images/Wall.jpg new file mode 100644 index 0000000..66e4344 Binary files /dev/null and b/SMIMS-Game/images/Wall.jpg differ diff --git a/SMIMS-Game/images/bathroom-tile.jpg b/SMIMS-Game/images/bathroom-tile.jpg new file mode 100644 index 0000000..afee904 Binary files /dev/null and b/SMIMS-Game/images/bathroom-tile.jpg differ diff --git a/SMIMS-Game/images/bluerock.jpg b/SMIMS-Game/images/bluerock.jpg new file mode 100644 index 0000000..24e88ce Binary files /dev/null and b/SMIMS-Game/images/bluerock.jpg differ diff --git a/SMIMS-Game/images/sandstone.jpg b/SMIMS-Game/images/sandstone.jpg new file mode 100644 index 0000000..0280dfc Binary files /dev/null and b/SMIMS-Game/images/sandstone.jpg differ diff --git a/SMIMS-Game/project.greenfoot b/SMIMS-Game/project.greenfoot index aa644c0..73e93c0 100644 --- a/SMIMS-Game/project.greenfoot +++ b/SMIMS-Game/project.greenfoot @@ -1,19 +1,19 @@ #Greenfoot project file class.Ground.image=weave.jpg class.Player.image=ppl2.png -dependency1.from=PlayerTestWorld -dependency1.to=Ground +dependency1.from=MyWorld +dependency1.to=Player dependency1.type=UsesDependency dependency2.from=Player dependency2.to=Ground dependency2.type=UsesDependency -editor.fx.0.height=737 -editor.fx.0.width=814 -editor.fx.0.x=360 -editor.fx.0.y=26 -height=830 +editor.fx.0.height=0 +editor.fx.0.width=0 +editor.fx.0.x=0 +editor.fx.0.y=0 +height=736 package.numDependencies=2 -package.numTargets=4 +package.numTargets=3 project.charset=UTF-8 publish.hasSource=false publish.locked=true @@ -43,21 +43,14 @@ target2.width=120 target2.x=0 target2.y=0 target3.height=70 -target3.name=PlayerTestWorld +target3.name=MyWorld target3.showInterface=false target3.type=ClassTarget target3.width=120 target3.x=0 target3.y=0 -target4.height=70 -target4.name=MyWorld -target4.showInterface=false -target4.type=ClassTarget -target4.width=120 -target4.x=0 -target4.y=0 version=3.1.0 -width=1550 -world.lastInstantiated=PlayerTestWorld -xPosition=0 -yPosition=0 +width=856 +world.lastInstantiated=MyWorld +xPosition=652 +yPosition=76