Hello,
I just started Greenfoot a week ago, I just started a project of my own and now I have a little query.
I have two identical actor sub-classes one called White and the other Black. How can I make the opposite one check to see if he can cut() first?
http://www.greenfoot.org/scenarios/4701
public class White extends Actor { private int regionNorth = 1; private int regionSouth = 1; private int regionWest = 1; private int regionEast = 1; private int region = 0; public void act() { checkRegion(); cut(); } public void cut() { Greenfoot.delay(1); region = regionNorth + regionSouth + regionWest + regionEast; if (region == 4){ setLocation(1,1); // this is just to see if it works } } public void checkRegion() { if( getWorld().getObjectsAt(getX(), getY()-1, Black.class).isEmpty() ){ regionNorth = 0; } if( getWorld().getObjectsAt(getX(), getY()+1, Black.class).isEmpty() ){ regionSouth = 0; } if( getWorld().getObjectsAt(getX()-1, getY(), Black.class).isEmpty() ){ regionWest = 0; } if( getWorld().getObjectsAt(getX()+1, getY(), Black.class).isEmpty() ){ regionEast = 0; } } }