-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMapGenerator.java
More file actions
37 lines (33 loc) · 1.06 KB
/
MapGenerator.java
File metadata and controls
37 lines (33 loc) · 1.06 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
package DemoGame;
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<map.length;i++){
for(int j=0;j<map[0].length;j++){
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[0].length; j++) {
if(map[i][j]>0){
g.setColor(Color.white);
g.fillRect(j*brickWidth+80,i*brickHeight+50,brickWidth,brickHeight);
g.setStroke(new BasicStroke(3));
g.setColor(Color.black);
g.drawRect(j*brickWidth+80,i*brickHeight+50,brickWidth,brickHeight);
}
}
}
}
public void setBrickValue(int value,int row,int col){
map[row][col]=value;
}
}