
The left red checker with the circle is wrong (looking to upper right square). The right checker is correct (checking lower right). The left checker shouldn't have any circle at all. The red circle on the third row, 6th column should be what a correct left jump is and have a circle.
I realize this might be confusing to understand, but basically the yellow circle is appearing when it shouldn't be because the left jump logic is wrong. It should only be yellow when the lower right/left corners are occupied by black and the next diagonal is open. It is currently doing upper and lower right corners.
public void paint(Graphics page)
{
setBackground(Color.white);
fillBoard(page); // draws the method that will draw the checkers
placeCheckers(page, 7, Color.red); //method to place the red checkers
placeCheckers(page, 9, Color.black); //method to draw black checkers
CheckJumps(page); //check if checkers can jump
setSize (APP_WIDTH,APP_HEIGHT);
}
public void CheckJumps (Graphics page)
{
for (int row = 0; row < 6; row++)
for (int col = 0; col < sq[row].length; col++)
{
if (col < 2 && sq[row][col].getOccupy() && sq[row][col].getCheckerC() == Color.red)
CheckRightJump(page, row, col);
if (col > 5 && sq[row][col].getOccupy() && sq[row][col].getCheckerC() == Color.red)
CheckLeftJump(page, row, col);
if (col > 1 && col < 6 && sq[row][col].getOccupy() && sq[row][col].getCheckerC() == Color.red)
{
CheckRightJump(page, row, col);
CheckLeftJump(page, row, col);
}
}
}
//Checks valid right-hand jumps
public void CheckRightJump (Graphics page, int row, int col)
{
Circle c;
int x = row * (APP_WIDTH/MAXSIZE);
int y = col * (APP_HEIGHT/MAXSIZE);
if (sq[row+1][col+1].getOccupy() && sq[row+1][col+1].getCheckerC() == Color.black && !sq[row+2][col+2].getOccupy())
{
c = new Circle (x + 15, y + 15, 20, Color.yellow);
c.draw(page);
}
}
//Checks valid left-hand jumps
public void CheckLeftJump (Graphics page, int row, int col)
{
Circle c;
int x = row * (APP_WIDTH/MAXSIZE);
int y = col * (APP_HEIGHT/MAXSIZE);
if (sq[row+1][col-1].getOccupy() && sq[row+1][col-1].getCheckerC() == Color.black && !sq[row+2][col-2].getOccupy())
{
c = new Circle (x + 15, y + 15, 20, Color.yellow);
c.draw(page);
}
}
}

New Topic/Question
Reply


MultiQuote






|