From ce68473591230778be8ab5d3c780a7588348bfd2 Mon Sep 17 00:00:00 2001 From: Ewen Date: Thu, 11 Nov 2021 14:44:57 +0100 Subject: [PATCH] Board in gui eingepackt --- src/Tetris/Board.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Tetris/Board.java b/src/Tetris/Board.java index 509e1f6..8190561 100644 --- a/src/Tetris/Board.java +++ b/src/Tetris/Board.java @@ -9,7 +9,8 @@ import javax.swing.Timer; public class Board extends JPanel { public static final int BOARD_WIDTH=10; - public static final int BOARD_HEIGHT =20; + public static final int BOARD_HEIGHT=20; + public static final int BLOCK_SIZE=30; private Timer loop; private Color[][] board = new Color[BOARD_WIDTH][BOARD_HEIGHT]; @@ -28,9 +29,16 @@ public class Board extends JPanel @Override protected void paintComponent(Graphics g) { super.paintComponent(g); - g.setColor(Color.blue); g.fillRect(0,0,getWidth(),getHeight()); - g.setColor(Color.black); - g.drawRect(10,10,200,200); + g.setColor(Color.DARK_GRAY); + + for(int row= 0; row< BOARD_HEIGHT;row++) + { + g.drawLine(0, BLOCK_SIZE * row, BLOCK_SIZE * BOARD_WIDTH, BLOCK_SIZE * row); + } + for(int col= 0; col< BOARD_WIDTH +1; col++) + { + g.drawLine(col * BLOCK_SIZE, 0, col * BLOCK_SIZE, BLOCK_SIZE * BOARD_HEIGHT); + } } }