Im trying to write a chess game and I need it to check for check but i am stuck. Below is the code that i am trying at the moment, i'm only using bq(black queen) and moveUP (in the northern direction of the board) to check at the moment - there are bp (black pawns etc..) and of course moveDOWN, moveLEFT etc.
Any help would be appreciated.
public boolean isNotCheck(boolean b) {
index = start - end;
for (int i = 0; i < ChessModel.LENGTH - 1; i++) {
if(model.getSquareAt(i).image == wk)
{
for(int j = i; j < ChessModel.LENGTH -1; j += moveUP)
{
if(model.getSquareAt(j).image == bq)
{
JOptionPane.showMessageDialog(null, "Check");
return false;
}
}
}
}
return true;
}
Edited by: 807338 on Mar 2, 2011 3:15 AM