I cant seem to get the greeps to move once they hit the ship after dropping off a tomato,i think it has to do with the flags but cant figure it out
**will delete post once issue is solved so others cant copy code
import greenfoot.*; // (World, Actor, GreenfootImage, and Greenfoot)
/**
* A Greep is an alien creature that likes to collect tomatoes.
*
* @author (your name here)
* @version 0.1
*/
public class Greep extends Creature
{
// Remember: you cannot extend the Greep's memory. So:
// no additional fields (other than final fields) allowed in this class!
/**
* Default constructor for testing purposes.
*/
public Greep()
{
this(null);
}
/**
* Create a Greep with its home space ship.
*/
public Greep(Ship ship)
{
super(ship);
}
/**
* Do what a greep's gotta do.
*/
public void act()
{
super.act(); // do not delete! leave as first statement in act().
if (carryingTomato()) {
if (atShip()) {
dropTomato();
move();
}
else
{
if(randomChance(10))
{
turnHome();
atLake();
}
atLake();
checkFood();
atLake();
move();
}
}
else
{
atLake();
checkFood();
atLake();
xyz();
}
}
public void xyz()
{
Greep greeps = (Greep) getOneIntersectingObject(Greep.class);
if(!getFlag(1))
{
move();
}
if(getFlag(1))
{
stop();
}
}
public void stop()
{
move(0);
}
/**
* turn if at water
*/
private void atLake()
{
if(atWater())
{
turn(Greenfoot.getRandomNumber(30));
xyz();
}
else
{
xyz();
}
if (atWorldEdge())
{
turn(Greenfoot.getRandomNumber(8));
xyz();
}
}
/**
* Is there any food here where we are? If so, try to load some!
*/
public void checkFood()
{
// check whether there's a tomato pile here
TomatoPile tomatoes = (TomatoPile) getOneIntersectingObject(TomatoPile.class);
Greep greeps = (Greep) getOneIntersectingObject(Greep.class);
if (tomatoes != null) {
setFlag(1, true);
loadTomato();
// Note: this attempts to load a tomato onto *another* Greep. It won't
// do anything if we are alone here.
}
}
/**
* This method specifies the name of the author (for display on the result board).
*/
public static String getAuthorName()
{
return "Anonymous"; // write your name here!
}
/**
* This method specifies the image we want displayed at any time. (No need
* to change this for the competition.)
*/
public String getCurrentImage()
{
if (carryingTomato())
return "greep-with-food.png";
else
return "greep.png";
}
/**
* Act the proper way to follow the paint.
*/
public boolean seePaint()
{
if (seePaint("orange"))
{
}
return true;
}
/**
* Start a spit line.
*/
public void startSpit()
{
if (getFlag(2))
{
spit("orange");
}
}
public void followPaint()
{
turnHome();
turn(180);
}
}
