It doesn't have to be complex, it only has to be simply about a turtle moving in short zigzag motion. I need it right now, so if anyone out there is generous enough to do it for me, please do. Thanks in advance.
setRotation(45);
int k = 20;
while(k != 0)
{
move(1);
Greenfoot.delay(5);
k++;
}
turn(90);
k = 20;
while(k != 0)
{
move(1);
Greenfoot.delay(5);
k++;
}
public class Crab extends Actor {
private int zCounter;
public Crab() {
zCounter = 0;
}
/**
* Act - do whatever the crab wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
zCounter += 1;
if ( zCounter == 10 )
{
setRotation(45);
} else if ( zCounter == 20)
{
setRotation(-45);
zCounter = 0;
}
move(5);
}
}