in the greep game my problem is more than one greeps stop at tomato although i put in my code
else if (greeps==null) {
move();
}
if (!getWorld().getObjectsAt(getX(), getY(), Tomato.class).isEmpty()) {
//stop moving because of the tomato;
}if (!getWorld().getObjectsAt(getX(), getY(), Tomato.class).isEmpty() && !otherGreepAtThisPosition()) {
//stop moving because of the tomato and no other greep;
}
//to use this method you have to import java.util.List;
public booleanOtherGreepAtThisPosition() {
List<Greep> greeps = getWorld().getObjectsAt(getX(), getY(), Greep.class);
if (!greeps.isEmpty()) {
for (Greep greep : greeps) {
if (!this.equals(greep)) {
return true;
}
}
}
return false;
}