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

2017/5/13

Problem with Greeps

TheGreenFoot TheGreenFoot

2017/5/13

#
Everytime one of my Greeps touches Water, Greenfoot gets stuck. I have this method which is called to avoid water:
        if(atWater())
        {
            while(atWater())
            {
                setRotation(getRotation() + 20);
            }
            if(getCurrentAction()==1)
            {
                setFlag(1, false);
                setFlag(2, false);
            }
            setMemory(20);
            move();
        }
I don't know what is wrong with it... pls help
danpost danpost

2017/5/13

#
That is the problem with Greeps. They are not very smart and you need to make the most of what brain-power they have. Unfortunateely, Greeps is used in competitions and publishing Greeps codes here on the site is discouraged by the Greenfoot team. So, you are on your own with this one -- sorry.
TheGreenFoot TheGreenFoot

2017/5/13

#
Sorry, I think you may not have understood me right. I don't need help with the Greeps Program itself, I just want to know why my Greenfoot always crashes(nothing happens, Greenfoot's screen gets white after a while). That would be very nice.
danpost danpost

2017/5/13

#
All you are doing while at water is turning. That does not change the state of being at water. So, the loop never ends (I think).
TheGreenFoot TheGreenFoot

2017/5/13

#
Ok thank you
You need to login to post a reply.