I am quite new to Greenfoot and I am trying to make a zombie game where the player(s) have to survive for as long as possible. I have it so that the zombies switch to the other side of the screen upon touching the border but as well as this I would like my zombie horde to follow the player(s) as well as not overlap with other zombie sprites. Any help would be much appreciated and please try to explain to me in basic terms :).
The following is the code for my zombie....
public void act()
{
move(1);
if (getX()< 10 || getX()>1590){
setLocation(Greenfoot.getRandomNumber(11), Greenfoot.getRandomNumber(710));
}
if (getY()< 10 || getY()>700){
setLocation(Greenfoot.getRandomNumber(11), Greenfoot.getRandomNumber(710));
}
Actor collide;
collide = getOneIntersectingObject(Player_1.class);
if (collide !=null){
getWorld().removeObject(collide);
}
collide = getOneIntersectingObject(Player_2.class);
if (collide !=null){
getWorld().removeObject(collide);
}
}
}
