This site requires JavaScript, please enable it in your browser!
Greenfoot back
kc4tlm
kc4tlm wrote ...

2013/1/13

Help with Greep issue.

kc4tlm kc4tlm

2013/1/13

#
I have made my Greeps turn at the edges of the world and the water. However, when a Greep is loaded with a tomato, it will get stuck at the water's edge. It is driving me crazy. I know this ic competition for some, but it is a final project for me and I have tried all I know (or recall). I put my method here. Can you see what is wrong? Why would a tomato make a difference?
    /**
             * Water edge? Go another direction!
             */
    public void checkWater()
    {
              if (atWater())
               {
                  turn(180);
                  move();
                  
                }
            }
Here is a bit of my act method
  public void act()
    {
        super.act();   // do not delete! leave as first statement in act().
        if (carryingTomato()) {
            if(atShip()) {
                dropTomato();
            }
            else {
               
                turnHome();
                move();
                checkEdge();
                checkWater();
            }
        }
kc4tlm kc4tlm

2013/1/13

#
I think I worked it out. The order has much to do with it.
You need to login to post a reply.