diff --git a/fighter/MyWorld.class b/fighter/MyWorld.class index 4ee4357..c2115de 100644 Binary files a/fighter/MyWorld.class and b/fighter/MyWorld.class differ diff --git a/fighter/MyWorld.ctxt b/fighter/MyWorld.ctxt index c854747..25b6c20 100644 --- a/fighter/MyWorld.ctxt +++ b/fighter/MyWorld.ctxt @@ -4,4 +4,7 @@ comment0.text=\r\n\ Write\ a\ description\ of\ class\ MyWorld\ here.\r\n\ \r\n\ comment1.params= comment1.target=MyWorld() comment1.text=\r\n\ Constructor\ for\ objects\ of\ class\ MyWorld.\r\n\ \r\n -numComments=2 +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 diff --git a/fighter/MyWorld.java b/fighter/MyWorld.java index 3b3080b..517251f 100644 --- a/fighter/MyWorld.java +++ b/fighter/MyWorld.java @@ -17,5 +17,18 @@ public class MyWorld extends World { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super(600, 400, 1); + prepare(); + } + + /** + * Prepare the world for the start of the program. + * That is: create the initial objects and add them to the world. + */ + private void prepare() + { + player1 player1 = new player1(); + addObject(player1,125,153); + player2 player2 = new player2(); + addObject(player2,429,152); } } diff --git a/fighter/images/man01.png b/fighter/images/man01.png new file mode 100644 index 0000000..dc71678 Binary files /dev/null and b/fighter/images/man01.png differ diff --git a/fighter/player.class b/fighter/player.class deleted file mode 100644 index 3487834..0000000 Binary files a/fighter/player.class and /dev/null differ diff --git a/fighter/player.java b/fighter/player.java deleted file mode 100644 index f5d7cae..0000000 --- a/fighter/player.java +++ /dev/null @@ -1,25 +0,0 @@ -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 -{ - /** - * Act - do whatever the player wants to do. This method is called whenever - * the 'Act' or 'Run' button gets pressed in the environment. - */ - public void act() - { - - } - - public void bewegung(){ - if(Greenfoot.isKeyDown("d")){ - move(5); - } - } -} diff --git a/fighter/player1.class b/fighter/player1.class new file mode 100644 index 0000000..4a779d1 Binary files /dev/null and b/fighter/player1.class differ diff --git a/fighter/player.ctxt b/fighter/player1.ctxt similarity index 76% rename from fighter/player.ctxt rename to fighter/player1.ctxt index 3c27fb3..30a2f23 100644 --- a/fighter/player.ctxt +++ b/fighter/player1.ctxt @@ -1,9 +1,13 @@ #BlueJ class context -comment0.target=player +comment0.target=player1 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() comment1.text=\r\n\ Act\ -\ do\ whatever\ the\ player\ 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\ bewegung() -numComments=3 +comment3.params= +comment3.target=void\ springen() +comment4.params= +comment4.target=void\ gravitation() +numComments=5 diff --git a/fighter/player1.java b/fighter/player1.java new file mode 100644 index 0000000..539539c --- /dev/null +++ b/fighter/player1.java @@ -0,0 +1,53 @@ +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 player1 extends Actor +{ + /** + * Act - do whatever the player wants to do. This method is called whenever + * the 'Act' or 'Run' button gets pressed in the environment. + */ + public void act() + { + bewegung(); + gravitation(); + springen(); + } + + public void bewegung(){ + if(Greenfoot.isKeyDown("d")){ + setRotation(0); + move(3); + } + if(Greenfoot.isKeyDown("a")){ + setRotation(0); + move(-3); + } + } + + public void springen(){ + if(Greenfoot.isKeyDown("space") && this.getY() > 370 ){ + for(int i = 12; i > -12; i--){ + setRotation(270); + move(i); + setRotation(0); + Greenfoot.delay(1); + bewegung(); + } + } + } + + public void gravitation(){ + if(this.getY() < 370){ + setRotation(90); + move(4); + setRotation(0); + + } + } +} diff --git a/fighter/player2.class b/fighter/player2.class new file mode 100644 index 0000000..fc341ba Binary files /dev/null and b/fighter/player2.class differ diff --git a/fighter/player2.ctxt b/fighter/player2.ctxt new file mode 100644 index 0000000..f92fe77 --- /dev/null +++ b/fighter/player2.ctxt @@ -0,0 +1,13 @@ +#BlueJ class context +comment0.target=player2 +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() +comment1.text=\r\n\ Act\ -\ do\ whatever\ the\ player\ 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\ bewegung() +comment3.params= +comment3.target=void\ springen() +comment4.params= +comment4.target=void\ gravitation() +numComments=5 diff --git a/fighter/player2.java b/fighter/player2.java new file mode 100644 index 0000000..e56dd62 --- /dev/null +++ b/fighter/player2.java @@ -0,0 +1,53 @@ +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 player2 extends Actor +{ + /** + * Act - do whatever the player wants to do. This method is called whenever + * the 'Act' or 'Run' button gets pressed in the environment. + */ + public void act() + { + bewegung(); + gravitation(); + springen(); + } + + public void bewegung(){ + if(Greenfoot.isKeyDown("right")){ + setRotation(0); + move(3); + } + if(Greenfoot.isKeyDown("left")){ + setRotation(0); + move(-3); + } + } + + public void springen(){ + if(Greenfoot.isKeyDown("-") && this.getY() > 370 ){ + for(int i = 12; i > -12; i--){ + setRotation(270); + move(i); + setRotation(0); + Greenfoot.delay(1); + bewegung(); + } + } + } + + public void gravitation(){ + if(this.getY() < 370){ + setRotation(90); + move(4); + setRotation(0); + + } + } +} diff --git a/fighter/project.greenfoot b/fighter/project.greenfoot index cc3105e..03f83f1 100644 --- a/fighter/project.greenfoot +++ b/fighter/project.greenfoot @@ -1,12 +1,14 @@ #Greenfoot project file -class.MyWorld.image=space.jpg +class.MyWorld.image=crumpled-paper.jpg +class.player1.image=man01.png +class.player2.image=man01.png editor.fx.0.height=737 editor.fx.0.width=814 editor.fx.0.x=151 editor.fx.0.y=86 height=686 package.numDependencies=0 -package.numTargets=3 +package.numTargets=4 project.charset=UTF-8 publish.hasSource=false publish.locked=true @@ -22,26 +24,33 @@ readme.x=10 readme.y=10 simulation.speed=48 target1.height=70 -target1.name=startScreen +target1.name=player1 target1.showInterface=false target1.type=ClassTarget target1.width=120 target1.x=0 target1.y=0 target2.height=70 -target2.name=MyWorld +target2.name=player2 target2.showInterface=false target2.type=ClassTarget target2.width=120 target2.x=0 target2.y=0 target3.height=70 -target3.name=player +target3.name=startScreen 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=1294 world.lastInstantiated=MyWorld