I have this--> getObjectsInRange( 50, Survivor.class);
I'm a beginner though and I don't really know what to do with it.
List<Survivor> list = getObjectsInRange(50, Survivor.class);
for(int i = 0; i < list.size(); i++) {
Survivor s = list.get(i);
// todo: do things with the Survivor object
}if (!getObjectsInRange(50, Survivor.class).isEmpty()) // if list is not empty
{
Actor survivor = (Actor)getObjectsInRange(50, Survivor.class).get(0);
turnToward(survivor.getX(), survivor.getY());
}java.util.List survivors = getObjectsInRange(Survivor.class);
if (!survivors.isEmpty())
{
Actor survivor = (Actor)survivors.get(0);
turnToward(survivor.getX(), survivor.getY());
}private Actor getOneObjectInFront(Class c)
{
GreenfootImage myImage = getImage();
int distanceToFront = myImage.getHeight();
int xOffset = (int)Math.ceil(distanceToFront*Math.cos(Math.toRadians(getRotation())));
int yOffset = (int)Math.ceil(distanceToFront*Math.sin(Math.toRadians(getRotation())));
return (getOneObjectAtOffset(xOffset, yOffset, c));
}return ((Actor)getOneObjectAtOffset(xOffset, yOffset, c));