Below i have provided the section of code i need someone to help with. I'm basically trying to get the robot to move forward but then if a 'wall' is in the way to stop. Only problem is, when it reads it, it ignores the code before the 'if(contactWall..." and so doesn't move at all. If someone knows whats missing please help.
Thanks.
public void act() { if(endItNow()==true) { Greenfoot.stop(); } else { int x = getX(); int y = getY(); setLocation(x+1,y); if(contactWall()==true); setLocation(x,y); } } public boolean contactWall() { Actor wall = getOneObjectAtOffset(0,0,wall.class); if(wall !=null) { return true; } else { return false; } }