-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBrickField.java
More file actions
67 lines (51 loc) · 2.34 KB
/
BrickField.java
File metadata and controls
67 lines (51 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import java.awt.Graphics2D;
import java.awt.Color;
import java.awt.BasicStroke;
import java.awt.GradientPaint;
public class BrickField {
public int brickGrid[][];
public int brickWidth;
public int brickHeight;
public BrickField(int rows, int columns) {
brickGrid = new int[rows][columns];
for (int i = 0; i < brickGrid.length; i++) {
for (int j = 0; j < brickGrid[0].length; j++) {
brickGrid[i][j] = 1;
}
}
brickWidth = 540 / columns;
brickHeight = 150 / rows;
}
public void draw(Graphics2D g) {
for (int i = 0; i < brickGrid.length; i++) {
for (int j = 0; j < brickGrid[0].length; j++) {
if (brickGrid[i][j] > 0) {
int x = j * brickWidth + 80;
int y = i * brickHeight + 50;
// Enhanced brick with gradient
Color topColor = new Color(220, 50, 50); // Bright red
Color bottomColor = new Color(150, 25, 25); // Darker red
GradientPaint gradient = new GradientPaint(
x, y, topColor,
x, y + brickHeight, bottomColor
);
g.setPaint(gradient);
g.fillRect(x, y, brickWidth, brickHeight);
g.setColor(new Color(255, 100, 100, 180));
g.fillRect(x, y, brickWidth, 3);
g.setColor(new Color(80, 10, 10, 120));
g.fillRect(x, y + brickHeight - 3, brickWidth, 3);
g.setStroke(new BasicStroke(2));
g.setColor(new Color(40, 5, 5));
g.drawRect(x, y, brickWidth, brickHeight);
g.setStroke(new BasicStroke(1));
g.setColor(new Color(255, 80, 80, 100));
g.drawRect(x + 2, y + 2, brickWidth - 4, brickHeight - 4);
}
}
}
}
public void setBrickValue(int value, int row, int col) {
brickGrid[row][col] = value;
}
}