plant wrote...
So does your player automatically move or do you have to move itplant wrote...
What is the significance of putting a return true or false statement in a Boolean method? Let's say canMove()==true, would I return true just to confirm the previous true valuepublic boolean wallFront()
{
Actor Block2 = getOneObjectAtOffset(1, 0, Block.class);
if (Block2 == null)
{
return false;
}
else
{
return true;
}
}
// is the same as
public boolean wallFront()
{
Actor Block2 = getOneObjectAtOffset(1, 0, Block.class);
return Block2 != null;
}
// is the same as
public boolean wallFront()
{
return getOneObjectAtOffset(1, 0, Block.class) != null;
}else if (Greenfoot.isKeyDown("right") && !wallFront())
// could be written as the following without the use of the 'wallFront' method
else if (Greenfoot.isKeyDown("right") && getOneObjectAtOffset(1, 0, Block.class) == null)
