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

2013/11/6

turnTowards()

Cyan002 Cyan002

2013/11/6

#
How exactly does this method work? I'm am using it in the Greeps competition. So I am trying to causes the greeps to follow the purple paint trail. Currently I have this:
public void tomatoTrail()
    {
        if(seePaint("purple"))
        {
            turnTowards(getX(),getY());
            
            for(int i = 0; i <= 10; i++)
            {
                move();
            }
        }
    }
Cyan002 Cyan002

2013/11/6

#
Help would be greatly appreciated
danpost danpost

2013/11/6

#
In the greeps competition, you are only allowed to 'move' once per act. Your 'for' loop would disqualify you. Your 'turnTowards' method is having the greeps turn toward their own locations (facing themselves, if that is possible). After a quick test, I found that when using the actor's own location, the rotation will be reset back to zero (0).
You need to login to post a reply.