diff --git a/libgdx/core/src/com/mountainreacher/chess/model/ClassicBoard.java b/libgdx/core/src/com/mountainreacher/chess/model/ClassicBoard.java index 7efdb54..c7ee55b 100644 --- a/libgdx/core/src/com/mountainreacher/chess/model/ClassicBoard.java +++ b/libgdx/core/src/com/mountainreacher/chess/model/ClassicBoard.java @@ -129,8 +129,9 @@ protected Piece kingIsInDanger(int kingTeam, int row, int column) { // Closeness with the other king if (piece.getFigure() == Piece.KING) { - if (Math.sqrt(Math.pow(piece.getRow() - row, 2) - + Math.pow(piece.getColumn() - column, 2)) < 2) { + int rowDistance = Math.abs(piece.getRow() - row); + int columnDistance = Math.abs(piece.getColumn() - column); + if(Math.max(rowDistance, columnDistance) < 2) { return piece; } } @@ -197,4 +198,4 @@ public void reset() { ((GenericPiece) piece).reset(); } } -} \ No newline at end of file +}