Verfolgungsprojektil

This commit is contained in:
2026-09-15 20:06:13 +02:00
parent 293c235352
commit bbd34812cb
6 changed files with 49 additions and 9 deletions
+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);
}
}