diff --git a/SMIMS-Game/MyWorld.class b/SMIMS-Game/MyWorld.class index a5ee6ac..7aeaf1c 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 1def3ed..3047bc1 100644 --- a/SMIMS-Game/MyWorld.java +++ b/SMIMS-Game/MyWorld.java @@ -11,7 +11,7 @@ public class MyWorld extends World int PlattformCountdown; int timer = 200; //Zeit, bevor das erste Projektil auftaucht //kann später noch beliebig angepasst werden - int targetTimer = 1000; + int targetTimer = 900; /** * Constructor for objects of class MyWorld. * @@ -22,6 +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. @@ -31,6 +32,7 @@ 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 @@ -63,14 +65,14 @@ public class MyWorld extends World else{ timer = timer - 1; } - //if(timer == 0){ - // TargetingProjectile targetingProjectile = new TargetingProjectile(); - // addObject(targetingProjectile, Greenfoot.getRandomNumber(300)+50,0); - // timer = 1000; - //} - //else{ - // timer = timer - 1; - //} + if(targetTimer == 0){ + TargetingProjectile targetingProjectile = new TargetingProjectile(); + addObject(targetingProjectile, Greenfoot.getRandomNumber(300)+50,0); + targetTimer = 900; + } + else{ + targetTimer = targetTimer - 1; + } } } diff --git a/SMIMS-Game/TargetingProjectile.class b/SMIMS-Game/TargetingProjectile.class new file mode 100644 index 0000000..0a739ae Binary files /dev/null and b/SMIMS-Game/TargetingProjectile.class differ diff --git a/SMIMS-Game/TargetingProjectile.ctxt b/SMIMS-Game/TargetingProjectile.ctxt new file mode 100644 index 0000000..c5d0167 --- /dev/null +++ b/SMIMS-Game/TargetingProjectile.ctxt @@ -0,0 +1,9 @@ +#BlueJ class context +comment0.target=TargetingProjectile +comment0.text=\r\n\ Write\ a\ description\ of\ class\ TargetingProjectile\ 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\ TargetingProjectile\ 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\ targetPlayer() +numComments=3 diff --git a/SMIMS-Game/TargetingProjectile.java b/SMIMS-Game/TargetingProjectile.java new file mode 100644 index 0000000..fb2b18e --- /dev/null +++ b/SMIMS-Game/TargetingProjectile.java @@ -0,0 +1,29 @@ +import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) + +/** + * Write a description of class TargetingProjectile here. + * + * @author (your name) + * @version (a version number or a date) + */ +public class TargetingProjectile extends Projectile +{ + /** + * Act - do whatever the TargetingProjectile wants to do. This method is called whenever + * the 'Act' or 'Run' button gets pressed in the environment. + */ + public void act() + { + targetPlayer(); + falling(); + } + + public void targetPlayer(){ + Player player = (Player) getWorld().getObjects(Player.class).get(0); + int playerX = player.getX(); + int playerY = player.getY(); + turnTowards(playerX, playerY); + move(5); + } + +} diff --git a/SMIMS-Game/images/blue-draught.png b/SMIMS-Game/images/blue-draught.png new file mode 100644 index 0000000..a3ceb9a Binary files /dev/null and b/SMIMS-Game/images/blue-draught.png differ