Number and Letter on the board
This commit is contained in:
parent
c0102b7116
commit
d64e2962c9
|
|
@ -101,7 +101,7 @@ public class JPanelChessBoard extends JPanel {
|
|||
if (myGame != null) {
|
||||
// Draw Interface from state of simulator
|
||||
g.setColor(new Color(238, 236, 208)); // Your default color
|
||||
g.fillRect(0, 0, getWidth(), getHeight());
|
||||
g.fillRect(0, 0, getWidth()+1, getHeight()+1);
|
||||
repaint();
|
||||
float cellWidth = cellWidth();
|
||||
float cellHeight = cellHeight();
|
||||
|
|
@ -149,6 +149,22 @@ public class JPanelChessBoard extends JPanel {
|
|||
for (Piece piece : myGame.getPieces()) {
|
||||
drawPiece(g,piece);
|
||||
}
|
||||
g.setColor(Color.BLACK);
|
||||
|
||||
|
||||
for (int x = 0; x < myGame.getWidth(); x++) {
|
||||
char letter = (char) ('a' + x);
|
||||
int xLetter = Math.round(x * cellWidth() + cellWidth() / 2) - 4;
|
||||
int yLetter = getHeight() - 5;
|
||||
g.drawString(String.valueOf(letter), xLetter, yLetter);
|
||||
}
|
||||
|
||||
for (int y = 0; y < myGame.getHeight(); y++) {
|
||||
int number = myGame.getHeight() - y;
|
||||
int xNumber = 5;
|
||||
int yNumber = Math.round(y * cellHeight() + cellHeight() / 2) + 5;
|
||||
g.drawString(String.valueOf(number), xNumber, yNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue