-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbricks.java
40 lines (36 loc) · 917 Bytes
/
bricks.java
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
package BrickBreaker;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
public class bricks {
public int map[][];
public int brickwidth;
public int brickhight;
public bricks(int row,int col) {
map=new int[row][col];
for(int i=0;i<map.length;i++) {
for(int j=0;j<map[0].length;j++) {
map[i][j]=1;
}
}
brickwidth=540/col;
brickhight=150/row;
}
public void draw(Graphics2D g) {
for(int i=0;i<map.length;i++) {
for(int j=0;j<map[0].length;j++) {
if(map[i][j]>0) {
g.setColor(Color.white);
g.fillRect(j*brickwidth+80, i*brickhight+50, brickwidth, brickhight);
g.setStroke(new BasicStroke(3));
g.setColor(Color.black);
g.drawRect(j*brickwidth+80, i*brickhight+50, brickwidth, brickhight);
}
}
}
}
public void setbrickvalue(int val,int row,int col) {
map[row][col]=val;
}
}