***could someone edit the movement so that the lobster moves foward and back at 60 px ***
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class GoldenBall here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Lobster extends Actor
{
/**
* Act - do whatever the GoldenBall wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
checkGoldenBall();
walk();
}
public boolean canMove(int x, int y)
{
Actor sand;
sand=getOneObjectAtOffset(x,y,sandroad.class);
//the section below checks if there is a block you can move to
// if there is it sets sand to a vlaue otherwise it says null
// The errors are in this section
boolean flag=false;
if (sand !=null)
{
flag=true;
}
return flag;
}
/**
* Check if Lobster eats the ball
*/
private void checkGoldenBall()
{
Actor GoldenBall= getOneIntersectingObject(GoldenBall.class);
if (GoldenBall !=null )
{
getWorld().removeObject(GoldenBall);
}
}
/**
* Make the lobster move
*/
private void walk()
{
Int pause= 60;
move(60);
If(pause>0);
{
pause--;
}
{
setRotation(getRotation-180);
pause= 60
}
}
}

