Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4bc13d6d57 | |||
| bbd34812cb |
+11
-9
@@ -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.
|
||||
@@ -33,6 +34,7 @@ public class MyWorld extends World
|
||||
Score score = new Score();
|
||||
addObject(score, 200, 50);
|
||||
}
|
||||
|
||||
public void act()
|
||||
{
|
||||
if(PlattformCountdown==0) //Damit in regelmäßigen Abständen auf jeden Fall eine Plattform auftaucht
|
||||
@@ -65,14 +67,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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -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
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 269 B |
Reference in New Issue
Block a user