Merge remote-tracking branch 'origin/main'

This commit is contained in:
2026-09-15 20:06:32 +02:00
5 changed files with 49 additions and 9 deletions
+11 -9
View File
@@ -11,7 +11,7 @@ public class MyWorld extends World
int PlattformCountdown; int PlattformCountdown;
int timer = 200; //Zeit, bevor das erste Projektil auftaucht int timer = 200; //Zeit, bevor das erste Projektil auftaucht
//kann später noch beliebig angepasst werden //kann später noch beliebig angepasst werden
int targetTimer = 1000; int targetTimer = 900;
/** /**
* Constructor for objects of class MyWorld. * Constructor for objects of class MyWorld.
* *
@@ -22,6 +22,7 @@ public class MyWorld extends World
super(400, 600, 1); super(400, 600, 1);
prepare(); prepare();
} }
/** /**
* Prepare the world for the start of the program. * Prepare the world for the start of the program.
* That is: create the initial objects and add them to the world. * 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(); Score score = new Score();
addObject(score, 200, 50); addObject(score, 200, 50);
} }
public void act() public void act()
{ {
if(PlattformCountdown==0) //Damit in regelmäßigen Abständen auf jeden Fall eine Plattform auftaucht 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{ else{
timer = timer - 1; timer = timer - 1;
} }
//if(timer == 0){ if(targetTimer == 0){
// TargetingProjectile targetingProjectile = new TargetingProjectile(); TargetingProjectile targetingProjectile = new TargetingProjectile();
// addObject(targetingProjectile, Greenfoot.getRandomNumber(300)+50,0); addObject(targetingProjectile, Greenfoot.getRandomNumber(300)+50,0);
// timer = 1000; targetTimer = 900;
//} }
//else{ else{
// timer = timer - 1; targetTimer = targetTimer - 1;
//} }
} }
} }
Binary file not shown.
+9
View File
@@ -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
+29
View File
@@ -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