Skip to content

Instantly share code, notes, and snippets.

@andrefreitas
Last active December 16, 2015 01:09
Show Gist options
  • Save andrefreitas/5353121 to your computer and use it in GitHub Desktop.
Save andrefreitas/5353121 to your computer and use it in GitHub Desktop.
public boolean areAdjacent(int oldX, int oldY, int newX,int newY){
int deltaX=newX-oldX;
int deltaY=newY-oldY;
if(deltaY==0 && deltaX!=0){
for(int i=oldX+deltaX; i<7; i=i+deltaX){
if(board.getAt(newY, i)!=board.INVALID_POSITION){
if(i==newX)
return true;
else
return false;
}
}
}
else if(deltaX==0 && deltaY!=0){
for(int i=oldY+deltaY; i<7; i=i+deltaY){
System.out.println(newX+","+i);
if(board.getAt(newX, i)!=board.INVALID_POSITION){
if(i==newY)
return true;
else
return false;
}
}
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment