Refactor RenderBoard class and add a proper visualisation with Swing

This commit is contained in:
Dorian HAMDANI
2025-04-07 09:01:35 +02:00
parent 5db5fe280f
commit 4c0d488480
2 changed files with 79 additions and 20 deletions

View File

@@ -50,7 +50,7 @@ class RenderCanvas extends JPanel {
public RenderCanvas() {
setBorder(BorderFactory.createLineBorder(Color.black));
setBackground(Color.white);
board = new RenderBoard(8, 8); // Example board size
board = new RenderBoard(15, 15, 600, 600);
}
public Dimension getPreferredSize() {
@@ -62,11 +62,9 @@ class RenderCanvas extends JPanel {
int midX = getWidth() / 2;
int midY = getHeight() / 2;
int boardWidth = 400; // Example board width
int boardHeight = 400; // Example board height
int x = midX - (boardWidth / 2);
int y = midY - (boardHeight / 2);
board.drawBoard(g, x, y, boardWidth, boardHeight);
int x = midX - (this.board.renderWidth / 2);
int y = midY - (this.board.renderHeight / 2);
board.drawBoard(g, x, y);
}
public void draw(GomokuGame game) {