Breakout Aufgabe 1.5
This commit is contained in:
parent
f0c323beef
commit
82987f4710
@ -98,6 +98,9 @@ public class Field extends JPanel {
|
||||
// Calls the method for drawing the ball
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user