I'm making a maze game for a programing final that I'm doing and I need help with the collisions for the walls. I've tried getOneIntersectingObject but haven't gotten it to work. PLEASE HELP!!! I'm going to put the code up soon.
public void collision()
{
Block theBlock = null;
theBlock = (Block)getOneIntersectingObject(Block.class);
if (theBlock != null)
{
if (Greenfoot.isKeyDown("right"))
{
setLocation(getX()+0, getY());
}
if (Greenfoot.isKeyDown("left"))
{
setLocation(getX()-0, getY());
}
if (Greenfoot.isKeyDown("up"))
{
setLocation(getX(), getY()-0);
}
if (Greenfoot.isKeyDown("down"))
{
setLocation(getX(), getY()+0);
}
}
}