-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathBrickBreakerMapGenerator.java
More file actions
51 lines (43 loc) · 1.34 KB
/
BrickBreakerMapGenerator.java
File metadata and controls
51 lines (43 loc) · 1.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
package brickBreaker;
import java.awt.*;
public class MapGenerator {
public int[][] map;
public int brickWidth;
public int brickHeight;
public MapGenerator(int row, int col){
map = new int[row][col];
for(int i=0;i<row;i++){
for(int j=0;j<col;j++){
//1: not intersected with the ball
//0: intersected with the ball, not to be displayed
map[i][j] = 1;
}
}
brickWidth = 540/col;
brickHeight = 150/row;
}
public void draw(Graphics2D g){
for(int i=0;i<map.length;i++){
for(int j=0;j<map.length;j++){
if(map[i][j] > 0){
g.setColor(Color.white);
g.fillRect(j*brickWidth + 80, i*brickHeight + 50, brickWidth, brickHeight);
// awRect(j*brickWidth + 80, i*brickHeight + 50, brickWidth, brickHeight);
g.setStroke(new BasicStroke(3));
g.setColor(new Color(0x403D39));
g.drawRect(j*brickWidth + 80, i*brickHeight + 50, brickWidth, brickHeight);
}
else{
g.setColor(new Color(0x403D39));
g.fillRect(j*brickWidth + 80, i*brickHeight + 50, brickWidth, brickHeight);
// awRect(j*brickWidth + 80, i*brickHeight + 50, brickWidth, brickHeight);
g.setStroke(new BasicStroke(3));
g.setColor(new Color(0x403D39));
g.drawRect(j*brickWidth + 80, i*brickHeight + 50, brickWidth, brickHeight);
}
}
}
}
public void setBrickVal(int val, int row, int col){
}
}