diff --git a/src/break_out/view/Field.java b/src/break_out/view/Field.java index cb577a0..c5c63ba 100644 --- a/src/break_out/view/Field.java +++ b/src/break_out/view/Field.java @@ -96,7 +96,10 @@ public class Field extends JPanel { g2.setColor(new Color(200, 200, 200)); // Calls the method for drawing the ball - drawBall(g2); + drawBall(g2); + + // Calls the method for drawing the grid + drawGrid(g2); } @@ -111,4 +114,20 @@ public class Field extends JPanel { Constants.BALL_DIAMETER); } + /** + * Draws the grid + * @param g2 The graphics object + */ + private void drawGrid(Graphics2D g2) { + // vertical lines + for(int i = 1 ; i < Math.round(Constants.SCREEN_WIDTH/Constants.SQUARES_X); i++) { + g2.drawLine(i*Constants.SQUARES_X, 0, i*Constants.SQUARES_X, Constants.SCREEN_HEIGHT); + } + + // horizontal lines + for(int i = 1 ; i < Math.round(Constants.SCREEN_HEIGHT/Constants.SQUARES_Y); i++) { + g2.drawLine(0, i*Constants.SQUARES_Y, Constants.SCREEN_WIDTH, i*Constants.SQUARES_Y); + } + } + }